forked from qt-creator/qt-creator
Cleanup base base specifiers.
This commit is contained in:
@@ -286,11 +286,6 @@ void CheckUndefinedSymbols::endVisit(TemplateDeclarationAST *)
|
|||||||
|
|
||||||
bool CheckUndefinedSymbols::visit(ClassSpecifierAST *ast)
|
bool CheckUndefinedSymbols::visit(ClassSpecifierAST *ast)
|
||||||
{
|
{
|
||||||
if (ast->base_clause) {
|
|
||||||
unsigned line, col;
|
|
||||||
getTokenStartPosition(ast->firstToken(), &line, &col);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hasQ_OBJECT_CHECK = false;
|
bool hasQ_OBJECT_CHECK = false;
|
||||||
|
|
||||||
if (ast->symbol) {
|
if (ast->symbol) {
|
||||||
|
@@ -382,15 +382,13 @@ unsigned ClassSpecifierAST::lastToken() const
|
|||||||
if (lbrace_token)
|
if (lbrace_token)
|
||||||
return lbrace_token + 1;
|
return lbrace_token + 1;
|
||||||
|
|
||||||
for (BaseSpecifierAST *it = base_clause; it; it = it->next) {
|
else if (base_clause_list)
|
||||||
if (! it->next)
|
return base_clause_list->lastToken();
|
||||||
return it->lastToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (colon_token)
|
else if (colon_token)
|
||||||
return colon_token + 1;
|
return colon_token + 1;
|
||||||
|
|
||||||
if (name)
|
else if (name)
|
||||||
return name->lastToken();
|
return name->lastToken();
|
||||||
|
|
||||||
for (SpecifierAST *it = attributes; it; it = it->next) {
|
for (SpecifierAST *it = attributes; it; it = it->next) {
|
||||||
|
@@ -478,7 +478,6 @@ public:
|
|||||||
unsigned virtual_token;
|
unsigned virtual_token;
|
||||||
unsigned access_specifier_token;
|
unsigned access_specifier_token;
|
||||||
NameAST *name;
|
NameAST *name;
|
||||||
BaseSpecifierAST *next;
|
|
||||||
|
|
||||||
public: // annotations
|
public: // annotations
|
||||||
BaseClass *symbol;
|
BaseClass *symbol;
|
||||||
@@ -571,7 +570,7 @@ public:
|
|||||||
SpecifierAST *attributes;
|
SpecifierAST *attributes;
|
||||||
NameAST *name;
|
NameAST *name;
|
||||||
unsigned colon_token;
|
unsigned colon_token;
|
||||||
BaseSpecifierAST *base_clause;
|
BaseSpecifierListAST *base_clause_list;
|
||||||
unsigned lbrace_token;
|
unsigned lbrace_token;
|
||||||
DeclarationListAST *member_specifiers;
|
DeclarationListAST *member_specifiers;
|
||||||
unsigned rbrace_token;
|
unsigned rbrace_token;
|
||||||
|
@@ -163,8 +163,7 @@ void ClassSpecifierAST::accept0(ASTVisitor *visitor)
|
|||||||
for (SpecifierAST *it = attributes; it; it = it->next)
|
for (SpecifierAST *it = attributes; it; it = it->next)
|
||||||
accept(it, visitor);
|
accept(it, visitor);
|
||||||
accept(name, visitor);
|
accept(name, visitor);
|
||||||
for (BaseSpecifierAST *it = base_clause; it; it = it->next)
|
accept(base_clause_list, visitor);
|
||||||
accept(it, visitor);
|
|
||||||
for (DeclarationListAST *it = member_specifiers; it; it = it->next)
|
for (DeclarationListAST *it = member_specifiers; it; it = it->next)
|
||||||
accept(it, visitor);
|
accept(it, visitor);
|
||||||
}
|
}
|
||||||
|
@@ -195,6 +195,8 @@ typedef List<ExpressionAST *> ExpressionListAST;
|
|||||||
typedef List<DeclarationAST *> DeclarationListAST;
|
typedef List<DeclarationAST *> DeclarationListAST;
|
||||||
typedef List<StatementAST *> StatementListAST;
|
typedef List<StatementAST *> StatementListAST;
|
||||||
typedef List<DeclaratorAST *> DeclaratorListAST;
|
typedef List<DeclaratorAST *> DeclaratorListAST;
|
||||||
|
typedef List<BaseSpecifierAST *> BaseSpecifierListAST;
|
||||||
|
|
||||||
typedef List<NameAST *> ObjCIdentifierListAST;
|
typedef List<NameAST *> ObjCIdentifierListAST;
|
||||||
typedef List<ObjCMessageArgumentAST *> ObjCMessageArgumentListAST;
|
typedef List<ObjCMessageArgumentAST *> ObjCMessageArgumentListAST;
|
||||||
typedef List<ObjCSelectorArgumentAST *> ObjCSelectorArgumentListAST;
|
typedef List<ObjCSelectorArgumentAST *> ObjCSelectorArgumentListAST;
|
||||||
|
@@ -328,7 +328,8 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
|
|||||||
_scope->enterSymbol(klass);
|
_scope->enterSymbol(klass);
|
||||||
_fullySpecifiedType.setType(klass);
|
_fullySpecifiedType.setType(klass);
|
||||||
|
|
||||||
for (BaseSpecifierAST *base = ast->base_clause; base; base = base->next) {
|
for (BaseSpecifierListAST *it = ast->base_clause_list; it; it = it->next) {
|
||||||
|
BaseSpecifierAST *base = it->value;
|
||||||
Name *baseClassName = semantic()->check(base->name, _scope);
|
Name *baseClassName = semantic()->check(base->name, _scope);
|
||||||
BaseClass *baseClass = control()->newBaseClass(ast->firstToken(), baseClassName);
|
BaseClass *baseClass = control()->newBaseClass(ast->firstToken(), baseClassName);
|
||||||
base->symbol = baseClass;
|
base->symbol = baseClass;
|
||||||
|
@@ -1550,17 +1550,23 @@ bool Parser::parseClassSpecifier(SpecifierAST *&node)
|
|||||||
unsigned colon_token = 0;
|
unsigned colon_token = 0;
|
||||||
|
|
||||||
if (LA() == T_COLON || LA() == T_LBRACE) {
|
if (LA() == T_COLON || LA() == T_LBRACE) {
|
||||||
BaseSpecifierAST *base_clause = 0;
|
BaseSpecifierListAST *base_clause_list = 0;
|
||||||
|
|
||||||
if (LA() == T_COLON) {
|
if (LA() == T_COLON) {
|
||||||
colon_token = cursor();
|
colon_token = cursor();
|
||||||
parseBaseClause(base_clause);
|
|
||||||
|
parseBaseClause(base_clause_list);
|
||||||
|
|
||||||
if (LA() != T_LBRACE) {
|
if (LA() != T_LBRACE) {
|
||||||
_translationUnit->error(cursor(), "expected `{' before `%s'", tok().spell());
|
_translationUnit->error(cursor(), "expected `{' before `%s'", tok().spell());
|
||||||
unsigned saved = cursor();
|
|
||||||
|
const unsigned saved = cursor();
|
||||||
|
|
||||||
for (int n = 0; n < 3 && LA() != T_EOF_SYMBOL; ++n, consumeToken()) {
|
for (int n = 0; n < 3 && LA() != T_EOF_SYMBOL; ++n, consumeToken()) {
|
||||||
if (LA() == T_LBRACE)
|
if (LA() == T_LBRACE)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LA() != T_LBRACE)
|
if (LA() != T_LBRACE)
|
||||||
rewind(saved);
|
rewind(saved);
|
||||||
}
|
}
|
||||||
@@ -1571,7 +1577,7 @@ bool Parser::parseClassSpecifier(SpecifierAST *&node)
|
|||||||
ast->attributes = attributes;
|
ast->attributes = attributes;
|
||||||
ast->name = name;
|
ast->name = name;
|
||||||
ast->colon_token = colon_token;
|
ast->colon_token = colon_token;
|
||||||
ast->base_clause = base_clause;
|
ast->base_clause_list = base_clause_list;
|
||||||
|
|
||||||
if (LA() == T_LBRACE)
|
if (LA() == T_LBRACE)
|
||||||
ast->lbrace_token = consumeToken();
|
ast->lbrace_token = consumeToken();
|
||||||
@@ -1778,13 +1784,14 @@ bool Parser::parseInitDeclarator(DeclaratorAST *&node,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Parser::parseBaseClause(BaseSpecifierAST *&node)
|
bool Parser::parseBaseClause(BaseSpecifierListAST *&node)
|
||||||
{
|
{
|
||||||
DEBUG_THIS_RULE();
|
DEBUG_THIS_RULE();
|
||||||
if (LA() == T_COLON) {
|
|
||||||
consumeToken();
|
|
||||||
|
|
||||||
BaseSpecifierAST **ast = &node;
|
if (LA() == T_COLON) {
|
||||||
|
consumeToken(); // ### remove me
|
||||||
|
|
||||||
|
BaseSpecifierListAST **ast = &node;
|
||||||
if (parseBaseSpecifier(*ast)) {
|
if (parseBaseSpecifier(*ast)) {
|
||||||
ast = &(*ast)->next;
|
ast = &(*ast)->next;
|
||||||
|
|
||||||
@@ -1895,7 +1902,7 @@ bool Parser::parseExpressionList(ExpressionListAST *&node)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Parser::parseBaseSpecifier(BaseSpecifierAST *&node)
|
bool Parser::parseBaseSpecifier(BaseSpecifierListAST *&node)
|
||||||
{
|
{
|
||||||
DEBUG_THIS_RULE();
|
DEBUG_THIS_RULE();
|
||||||
BaseSpecifierAST *ast = new (_pool) BaseSpecifierAST;
|
BaseSpecifierAST *ast = new (_pool) BaseSpecifierAST;
|
||||||
@@ -1918,7 +1925,9 @@ bool Parser::parseBaseSpecifier(BaseSpecifierAST *&node)
|
|||||||
parseName(ast->name);
|
parseName(ast->name);
|
||||||
if (! ast->name)
|
if (! ast->name)
|
||||||
_translationUnit->error(cursor(), "expected class-name");
|
_translationUnit->error(cursor(), "expected class-name");
|
||||||
node = ast;
|
|
||||||
|
node = new (_pool) BaseSpecifierListAST;
|
||||||
|
node->value = ast;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -84,8 +84,8 @@ public:
|
|||||||
bool parseAsmOperand();
|
bool parseAsmOperand();
|
||||||
bool parseAsmClobberList();
|
bool parseAsmClobberList();
|
||||||
bool parseAssignmentExpression(ExpressionAST *&node);
|
bool parseAssignmentExpression(ExpressionAST *&node);
|
||||||
bool parseBaseClause(BaseSpecifierAST *&node);
|
bool parseBaseClause(BaseSpecifierListAST *&node);
|
||||||
bool parseBaseSpecifier(BaseSpecifierAST *&node);
|
bool parseBaseSpecifier(BaseSpecifierListAST *&node);
|
||||||
bool parseBlockDeclaration(DeclarationAST *&node);
|
bool parseBlockDeclaration(DeclarationAST *&node);
|
||||||
bool parseCppCastExpression(ExpressionAST *&node);
|
bool parseCppCastExpression(ExpressionAST *&node);
|
||||||
bool parseCastExpression(ExpressionAST *&node);
|
bool parseCastExpression(ExpressionAST *&node);
|
||||||
|
@@ -121,9 +121,9 @@ void tst_AST::template_id_1()
|
|||||||
QCOMPARE(ast->asTemplateId()->identifier_token, 1U);
|
QCOMPARE(ast->asTemplateId()->identifier_token, 1U);
|
||||||
QCOMPARE(ast->asTemplateId()->less_token, 2U);
|
QCOMPARE(ast->asTemplateId()->less_token, 2U);
|
||||||
QVERIFY(ast->asTemplateId()->template_arguments != 0);
|
QVERIFY(ast->asTemplateId()->template_arguments != 0);
|
||||||
QVERIFY(ast->asTemplateId()->template_arguments->template_argument != 0);
|
QVERIFY(ast->asTemplateId()->template_arguments->value != 0);
|
||||||
QVERIFY(ast->asTemplateId()->template_arguments->template_argument->asNumericLiteral() != 0);
|
QVERIFY(ast->asTemplateId()->template_arguments->value->asNumericLiteral() != 0);
|
||||||
QCOMPARE(ast->asTemplateId()->template_arguments->template_argument->asNumericLiteral()->literal_token, 3U);
|
QCOMPARE(ast->asTemplateId()->template_arguments->value->asNumericLiteral()->literal_token, 3U);
|
||||||
QVERIFY(ast->asTemplateId()->template_arguments->next == 0);
|
QVERIFY(ast->asTemplateId()->template_arguments->next == 0);
|
||||||
QCOMPARE(ast->asTemplateId()->greater_token, 4U);
|
QCOMPARE(ast->asTemplateId()->greater_token, 4U);
|
||||||
}
|
}
|
||||||
@@ -471,7 +471,7 @@ void tst_AST::cpp_initializer_or_function_declaration()
|
|||||||
QVERIFY(simple_named_ty != 0);
|
QVERIFY(simple_named_ty != 0);
|
||||||
QCOMPARE(simple_named_ty->identifier_token, 1U);
|
QCOMPARE(simple_named_ty->identifier_token, 1U);
|
||||||
|
|
||||||
DeclaratorAST *declarator = simple_decl->declarators->declarator;
|
DeclaratorAST *declarator = simple_decl->declarators->value;
|
||||||
QVERIFY(declarator != 0);
|
QVERIFY(declarator != 0);
|
||||||
QVERIFY(declarator->core_declarator != 0);
|
QVERIFY(declarator->core_declarator != 0);
|
||||||
QVERIFY(declarator->postfix_declarators != 0);
|
QVERIFY(declarator->postfix_declarators != 0);
|
||||||
@@ -664,7 +664,7 @@ void tst_AST::objc_msg_send_expression()
|
|||||||
|
|
||||||
{// check the assignment
|
{// check the assignment
|
||||||
QVERIFY(simpleDecl->declarators && !simpleDecl->declarators->next);
|
QVERIFY(simpleDecl->declarators && !simpleDecl->declarators->next);
|
||||||
DeclaratorAST *declarator = simpleDecl->declarators->declarator;
|
DeclaratorAST *declarator = simpleDecl->declarators->value;
|
||||||
QVERIFY(declarator);
|
QVERIFY(declarator);
|
||||||
QVERIFY(!declarator->attributes);
|
QVERIFY(!declarator->attributes);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user