Commit 24b6c858 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Cleanup postfix declarators.

parent a7219736
......@@ -458,7 +458,7 @@ bool CheckUndefinedSymbols::visit(SizeofExpressionAST *ast)
} else if (type_id->declarator
&& type_id->declarator->postfix_declarators
&& ! type_id->declarator->postfix_declarators->next
&& type_id->declarator->postfix_declarators->asArrayDeclarator() != 0) {
&& type_id->declarator->postfix_declarators->value->asArrayDeclarator() != 0) {
// this sizeof expression is ambiguos, e.g.
// sizeof(a[10])
// `a' can be a typeid or an expression.
......
......@@ -416,8 +416,8 @@ bool FindUsages::visit(ParameterDeclarationAST *ast)
if (! _inSimpleDeclaration) // visit the core declarator only if we are not in simple-declaration.
accept(declarator->core_declarator);
for (PostfixDeclaratorAST *fx_op = declarator->postfix_declarators; fx_op; fx_op = fx_op->next)
accept(fx_op);
for (PostfixDeclaratorListAST *it = declarator->postfix_declarators; it; it = it->next)
accept(it->value);
for (SpecifierAST *spec = declarator->post_attributes; spec; spec = spec->next)
accept(spec);
......
......@@ -1073,7 +1073,7 @@ bool CppCodeCompletion::completeConstructorOrFunction(const QList<TypeOfExpressi
doc->check();
if (SimpleDeclarationAST *sd = doc->translationUnit()->ast()->asSimpleDeclaration()) {
if (sd->declarators->value->postfix_declarators
&& sd->declarators->value->postfix_declarators->asFunctionDeclarator()) {
&& sd->declarators->value->postfix_declarators->value->asFunctionDeclarator()) {
autocompleteSignature = true;
}
}
......
......@@ -560,10 +560,8 @@ unsigned DeclaratorAST::lastToken() const
return it->lastToken();
}
for (PostfixDeclaratorAST *it = postfix_declarators; it; it = it->next) {
if (! it->next)
return it->lastToken();
}
if (postfix_declarators)
return postfix_declarators->lastToken();
if (core_declarator)
return core_declarator->lastToken();
......
......@@ -374,9 +374,6 @@ public:
class CPLUSPLUS_EXPORT PostfixDeclaratorAST: public AST
{
public:
PostfixDeclaratorAST *next;
public:
virtual PostfixDeclaratorAST *asPostfixDeclarator() { return this; }
};
......@@ -387,7 +384,7 @@ public:
SpecifierAST *attributes;
PtrOperatorAST *ptr_operators;
CoreDeclaratorAST *core_declarator;
PostfixDeclaratorAST *postfix_declarators;
PostfixDeclaratorListAST *postfix_declarators;
SpecifierAST *post_attributes;
unsigned equals_token;
ExpressionAST *initializer;
......
......@@ -73,8 +73,7 @@ void DeclaratorAST::accept0(ASTVisitor *visitor)
for (PtrOperatorAST *it = ptr_operators; it; it = it->next)
accept(it, visitor);
accept(core_declarator, visitor);
for (PostfixDeclaratorAST *it = postfix_declarators; it; it = it->next)
accept(it, visitor);
accept(postfix_declarators, visitor);
for (SpecifierAST *it = post_attributes; it; it = it->next)
accept(it, visitor);
accept(initializer, visitor);
......
......@@ -200,6 +200,7 @@ typedef List<EnumeratorAST *> EnumeratorListAST;
typedef List<MemInitializerAST *> MemInitializerListAST;
typedef List<NewArrayDeclaratorAST *> NewArrayDeclaratorListAST;
typedef List<PostfixAST *> PostfixListAST;
typedef List<PostfixDeclaratorAST *> PostfixDeclaratorListAST;
typedef List<NameAST *> ObjCIdentifierListAST;
typedef List<ObjCMessageArgumentAST *> ObjCMessageArgumentListAST;
......
......@@ -205,7 +205,6 @@ bool CheckDeclarator::visit(FunctionDeclaratorAST *ast)
fun->setVolatile(true);
}
accept(ast->next);
return false;
}
......@@ -215,7 +214,6 @@ bool CheckDeclarator::visit(ArrayDeclaratorAST *ast)
FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
FullySpecifiedType arrTy(ty);
_fullySpecifiedType = ty;
accept(ast->next);
return false;
}
......@@ -226,7 +224,6 @@ bool CheckDeclarator::visit(PointerToMemberAST *ast)
FullySpecifiedType ty(ptrTy);
_fullySpecifiedType = ty;
applyCvQualifiers(ast->cv_qualifier_seq);
accept(ast->next);
return false;
}
......@@ -236,7 +233,6 @@ bool CheckDeclarator::visit(PointerAST *ast)
FullySpecifiedType ty(ptrTy);
_fullySpecifiedType = ty;
applyCvQualifiers(ast->cv_qualifier_seq);
accept(ast->next);
return false;
}
......@@ -245,7 +241,6 @@ bool CheckDeclarator::visit(ReferenceAST *ast)
ReferenceType *refTy = control()->referenceType(_fullySpecifiedType);
FullySpecifiedType ty(refTy);
_fullySpecifiedType = ty;
accept(ast->next);
return false;
}
......
......@@ -1127,7 +1127,7 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, bool stopAtCppInitializer)
if (! parseCoreDeclarator(node))
return false;
PostfixDeclaratorAST **postfix_ptr = &node->postfix_declarators;
PostfixDeclaratorListAST **postfix_ptr = &node->postfix_declarators;
for (;;) {
unsigned startOfPostDeclarator = cursor();
......@@ -1155,7 +1155,7 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, bool stopAtCppInitializer)
ast->parameters = parameter_declaration_clause;
ast->as_cpp_initializer = initializer;
ast->rparen_token = rparen_token;
*postfix_ptr = ast;
*postfix_ptr = new (_pool) PostfixDeclaratorListAST(ast);
postfix_ptr = &(*postfix_ptr)->next;
blockErrors(blocked);
......@@ -1185,7 +1185,7 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, bool stopAtCppInitializer)
ast->rparen_token = consumeToken();
parseCvQualifiers(ast->cv_qualifier_seq);
parseExceptionSpecification(ast->exception_specification);
*postfix_ptr = ast;
*postfix_ptr = new (_pool) PostfixDeclaratorListAST(ast);
postfix_ptr = &(*postfix_ptr)->next;
} else if (LA() == T_LBRACKET) {
ArrayDeclaratorAST *ast = new (_pool) ArrayDeclaratorAST;
......@@ -1193,7 +1193,7 @@ bool Parser::parseDeclarator(DeclaratorAST *&node, bool stopAtCppInitializer)
if (LA() == T_RBRACKET || parseConstantExpression(ast->expression)) {
match(T_RBRACKET, &ast->rbracket_token);
}
*postfix_ptr = ast;
*postfix_ptr = new (_pool) PostfixDeclaratorListAST(ast);
postfix_ptr = &(*postfix_ptr)->next;
} else
break;
......@@ -1257,7 +1257,7 @@ bool Parser::parseAbstractDeclarator(DeclaratorAST *&node)
if (! parseAbstractCoreDeclarator(node))
return false;
PostfixDeclaratorAST *postfix_declarators = 0,
PostfixDeclaratorListAST *postfix_declarators = 0,
**postfix_ptr = &postfix_declarators;
for (;;) {
......@@ -1270,7 +1270,7 @@ bool Parser::parseAbstractDeclarator(DeclaratorAST *&node)
}
parseCvQualifiers(ast->cv_qualifier_seq);
parseExceptionSpecification(ast->exception_specification);
*postfix_ptr = ast;
*postfix_ptr = new (_pool) PostfixDeclaratorListAST(ast);
postfix_ptr = &(*postfix_ptr)->next;
} else if (LA() == T_LBRACKET) {
ArrayDeclaratorAST *ast = new (_pool) ArrayDeclaratorAST;
......@@ -1279,7 +1279,7 @@ bool Parser::parseAbstractDeclarator(DeclaratorAST *&node)
if (LA() == T_RBRACKET)
ast->rbracket_token = consumeToken();
}
*postfix_ptr = ast;
*postfix_ptr = new (_pool) PostfixDeclaratorListAST(ast);
postfix_ptr = &(*postfix_ptr)->next;
} else
break;
......@@ -2206,7 +2206,7 @@ bool Parser::maybeAmbiguousStatement(DeclarationStatementAST *ast) const
} else if (DeclaratorListAST *declarators = declaration->declarators) {
// no decl_specifiers...
if (DeclaratorAST *declarator = declarators->value) {
if (declarator->postfix_declarators && declarator->postfix_declarators->asFunctionDeclarator()
if (declarator->postfix_declarators && declarator->postfix_declarators->value->asFunctionDeclarator()
&& ! declarator->initializer) {
return false;
}
......
......@@ -484,7 +484,7 @@ void tst_AST::cpp_initializer_or_function_declaration()
QVERIFY(decl_id->name->asSimpleName() != 0);
QCOMPARE(decl_id->name->asSimpleName()->identifier_token, 2U);
FunctionDeclaratorAST *fun_declarator = declarator->postfix_declarators->asFunctionDeclarator();
FunctionDeclaratorAST *fun_declarator = declarator->postfix_declarators->value->asFunctionDeclarator();
QVERIFY(fun_declarator != 0);
QCOMPARE(fun_declarator->lparen_token, 3U);
QVERIFY(fun_declarator->parameters != 0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment