Commit 36a0ea2b authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Removed DeclarationListAST node.

Done with Erik Verbruggen
parent 4089c906
......@@ -104,7 +104,7 @@ bool CheckUndefinedSymbols::isType(const QByteArray &name) const
TemplateDeclarationAST *templateDeclaration = _templateDeclarationStack.at(i);
for (DeclarationListAST *it = templateDeclaration->template_parameters; it; it = it->next) {
DeclarationAST *templateParameter = it->declaration;
DeclarationAST *templateParameter = it->value;
if (templateParameterName(templateParameter) == name)
return true;
......
......@@ -414,7 +414,7 @@ void Document::check(CheckMode mode)
if (TranslationUnitAST *ast = _translationUnit->ast()->asTranslationUnit()) {
for (DeclarationListAST *decl = ast->declarations; decl; decl = decl->next) {
semantic.check(decl->declaration, globals);
semantic.check(decl->value, globals);
}
} else if (ExpressionAST *ast = _translationUnit->ast()->asExpression()) {
semantic.check(ast, globals);
......
......@@ -552,21 +552,6 @@ unsigned CtorInitializerAST::lastToken() const
return colon_token + 1;
}
unsigned DeclarationListAST::firstToken() const
{
return declaration->firstToken();
}
unsigned DeclarationListAST::lastToken() const
{
for (const DeclarationListAST *it = this; it; it = it->next) {
if (! it->next)
return it->declaration->lastToken();
}
return 0;
}
unsigned DeclaratorAST::firstToken() const
{
if (attributes)
......@@ -1642,7 +1627,7 @@ unsigned TemplateTypeParameterAST::lastToken() const
for (DeclarationListAST *it = template_parameters; it; it = it->next) {
if (! it->next)
return it->declaration->lastToken();
return it->value->lastToken();
}
if (less_token)
......
......@@ -362,22 +362,6 @@ public:
virtual DeclarationAST *asDeclaration() { return this; }
};
class CPLUSPLUS_EXPORT DeclarationListAST: public AST
{
public:
DeclarationAST *declaration;
DeclarationListAST *next;
public:
virtual DeclarationListAST *asDeclarationList() { return this; }
virtual unsigned firstToken() const;
virtual unsigned lastToken() const;
protected:
virtual void accept0(ASTVisitor *visitor);
};
class CPLUSPLUS_EXPORT CoreDeclaratorAST: public AST
{
public:
......
......@@ -65,14 +65,6 @@ void TypeofSpecifierAST::accept0(ASTVisitor *visitor)
visitor->endVisit(this);
}
void DeclarationListAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
accept(declaration, visitor);
}
visitor->endVisit(this);
}
void DeclaratorAST::accept0(ASTVisitor *visitor)
{
if (visitor->visit(this)) {
......
......@@ -228,9 +228,6 @@ public:
virtual bool visit(ObjCFastEnumerationAST *) { return true; }
virtual bool visit(ObjCSynchronizedStatementAST *) { return true; }
virtual bool visit(DeclarationListAST *) { return true; }
virtual void endVisit(DeclarationListAST *) { }
virtual void endVisit(AccessDeclarationAST *) { }
virtual void endVisit(ArrayAccessAST *) { }
virtual void endVisit(ArrayDeclaratorAST *) { }
......
......@@ -84,7 +84,6 @@ class CoreDeclaratorAST;
class CppCastExpressionAST;
class CtorInitializerAST;
class DeclarationAST;
class DeclarationListAST;
class DeclarationStatementAST;
class DeclaratorAST;
class DeclaratorIdAST;
......@@ -202,7 +201,7 @@ class UsingDirectiveAST;
class WhileStatementAST;
typedef List<ExpressionAST *> ExpressionListAST;
typedef List<DeclarationAST *> DeclarationListAST;
} // end of namespace CPlusPlus
......
......@@ -363,7 +363,7 @@ bool CheckDeclaration::visit(MemInitializerAST *ast)
bool CheckDeclaration::visit(LinkageBodyAST *ast)
{
for (DeclarationListAST *decl = ast->declarations; decl; decl = decl->next) {
semantic()->check(decl->declaration, _scope);
semantic()->check(decl->value, _scope);
}
return false;
}
......@@ -428,7 +428,7 @@ bool CheckDeclaration::visit(TemplateDeclarationAST *ast)
Scope *scope = new Scope(_scope->owner());
for (DeclarationListAST *param = ast->template_parameters; param; param = param->next) {
semantic()->check(param->declaration, scope);
semantic()->check(param->value, scope);
}
semantic()->check(ast->declaration, _scope,
......@@ -547,7 +547,7 @@ bool CheckDeclaration::visit(ObjCProtocolDeclarationAST *ast)
int previousObjCVisibility = semantic()->switchObjCVisibility(Function::Public);
for (DeclarationListAST *it = ast->member_declarations; it; it = it->next) {
semantic()->check(it->declaration, protocol->members());
semantic()->check(it->value, protocol->members());
}
(void) semantic()->switchObjCVisibility(previousObjCVisibility);
......@@ -626,14 +626,14 @@ bool CheckDeclaration::visit(ObjCClassDeclarationAST *ast)
if (ast->inst_vars_decl) {
for (DeclarationListAST *it = ast->inst_vars_decl->instance_variables; it; it = it->next) {
semantic()->check(it->declaration, klass->members());
semantic()->check(it->value, klass->members());
}
}
(void) semantic()->switchObjCVisibility(Function::Public);
for (DeclarationListAST *it = ast->member_declarations; it; it = it->next) {
semantic()->check(it->declaration, klass->members());
semantic()->check(it->value, klass->members());
}
(void) semantic()->switchObjCVisibility(previousObjCVisibility);
......
......@@ -174,7 +174,7 @@ bool CheckDeclarator::visit(FunctionDeclaratorAST *ast)
if (ast->parameters) {
DeclarationListAST *parameter_declarations = ast->parameters->parameter_declarations;
for (DeclarationListAST *decl = parameter_declarations; decl; decl = decl->next) {
semantic()->check(decl->declaration, fun->arguments());
semantic()->check(decl->value, fun->arguments());
}
if (ast->parameters->dot_dot_dot_token)
......
......@@ -347,7 +347,7 @@ bool CheckSpecifier::visit(ClassSpecifierAST *ast)
int previousMethodKey = semantic()->switchMethodKey(Function::NormalMethod);
for (DeclarationListAST *member = ast->member_specifiers; member; member = member->next) {
semantic()->check(member->declaration, klass->members());
semantic()->check(member->value, klass->members());
}
(void) semantic()->switchMethodKey(previousMethodKey);
......
......@@ -435,7 +435,7 @@ bool Parser::parseTranslationUnit(TranslationUnitAST *&node)
if (parseDeclaration(declaration)) {
*decl = new (_pool) DeclarationListAST;
(*decl)->declaration = declaration;
(*decl)->value = declaration;
decl = &(*decl)->next;
} else {
rewind(start_declaration + 1);
......@@ -562,7 +562,7 @@ bool Parser::parseLinkageBody(DeclarationAST *&node)
DeclarationAST *declaration = 0;
if (parseDeclaration(declaration)) {
*declaration_ptr = new (_pool) DeclarationListAST;
(*declaration_ptr)->declaration = declaration;
(*declaration_ptr)->value = declaration;
declaration_ptr = &(*declaration_ptr)->next;
} else {
rewind(start_declaration + 1);
......@@ -1340,7 +1340,7 @@ bool Parser::parseTemplateParameterList(DeclarationListAST *&node)
DeclarationAST *declaration = 0;
if (parseTemplateParameter(declaration)) {
*template_parameter_ptr = new (_pool) DeclarationListAST;
(*template_parameter_ptr)->declaration = declaration;
(*template_parameter_ptr)->value = declaration;
template_parameter_ptr = &(*template_parameter_ptr)->next;
while (LA() == T_COMMA) {
......@@ -1349,7 +1349,7 @@ bool Parser::parseTemplateParameterList(DeclarationListAST *&node)
declaration = 0;
if (parseTemplateParameter(declaration)) {
*template_parameter_ptr = new (_pool) DeclarationListAST;
(*template_parameter_ptr)->declaration = declaration;
(*template_parameter_ptr)->value = declaration;
template_parameter_ptr = &(*template_parameter_ptr)->next;
}
}
......@@ -1480,7 +1480,7 @@ bool Parser::parseParameterDeclarationList(DeclarationListAST *&node)
DeclarationAST *declaration = 0;
if (parseParameterDeclaration(declaration)) {
*parameter_declaration_ptr = new (_pool) DeclarationListAST;
(*parameter_declaration_ptr)->declaration = declaration;
(*parameter_declaration_ptr)->value = declaration;
parameter_declaration_ptr = &(*parameter_declaration_ptr)->next;
while (LA() == T_COMMA) {
consumeToken();
......@@ -1491,7 +1491,7 @@ bool Parser::parseParameterDeclarationList(DeclarationListAST *&node)
declaration = 0;
if (parseParameterDeclaration(declaration)) {
*parameter_declaration_ptr = new (_pool) DeclarationListAST;
(*parameter_declaration_ptr)->declaration = declaration;
(*parameter_declaration_ptr)->value = declaration;
parameter_declaration_ptr = &(*parameter_declaration_ptr)->next;
}
}
......@@ -1587,7 +1587,7 @@ bool Parser::parseClassSpecifier(SpecifierAST *&node)
DeclarationAST *declaration = 0;
if (parseMemberSpecification(declaration)) {
*declaration_ptr = new (_pool) DeclarationListAST;
(*declaration_ptr)->declaration = declaration;
(*declaration_ptr)->value = declaration;
declaration_ptr = &(*declaration_ptr)->next;
} else {
rewind(start_declaration + 1);
......@@ -4380,7 +4380,7 @@ bool Parser::parseObjCInterface(DeclarationAST *&node,
DeclarationAST *declaration = 0;
while (parseObjCInterfaceMemberDeclaration(declaration)) {
*nextMembers = new (_pool) DeclarationListAST;
(*nextMembers)->declaration = declaration;
(*nextMembers)->value = declaration;
nextMembers = &((*nextMembers)->next);
}
......@@ -4411,7 +4411,7 @@ bool Parser::parseObjCInterface(DeclarationAST *&node,
DeclarationAST *declaration = 0;
while (parseObjCInterfaceMemberDeclaration(declaration)) {
*nextMembers = new (_pool) DeclarationListAST;
(*nextMembers)->declaration = declaration;
(*nextMembers)->value = declaration;
nextMembers = &((*nextMembers)->next);
}
......@@ -4482,7 +4482,7 @@ bool Parser::parseObjCProtocol(DeclarationAST *&node,
DeclarationAST *declaration = 0;
while (parseObjCInterfaceMemberDeclaration(declaration)) {
*nextMembers = new (_pool) DeclarationListAST;
(*nextMembers)->declaration = declaration;
(*nextMembers)->value = declaration;
nextMembers = &((*nextMembers)->next);
}
......@@ -4650,7 +4650,7 @@ bool Parser::parseObjCMethodDefinitionList(DeclarationListAST *&node)
if (declaration) {
*next = new (_pool) DeclarationListAST;
(*next)->declaration = declaration;
(*next)->value = declaration;
next = &((*next)->next);
}
}
......@@ -4738,7 +4738,7 @@ bool Parser::parseObjClassInstanceVariables(ObjCInstanceVariablesDeclarationAST
const unsigned start = cursor();
*next = new (_pool) DeclarationListAST;
parseObjCInstanceVariableDeclaration((*next)->declaration);
parseObjCInstanceVariableDeclaration((*next)->value);
if (start == cursor()) {
// skip stray token.
......
......@@ -497,12 +497,12 @@ void tst_AST::cpp_initializer_or_function_declaration()
QCOMPARE(param_clause->dot_dot_dot_token, 0U);
// check the parameter
DeclarationListAST *declarations = param_clause->parameter_declarations->asDeclarationList();
DeclarationListAST *declarations = param_clause->parameter_declarations;
QVERIFY(declarations);
QVERIFY(declarations->declaration);
QVERIFY(declarations->value);
QVERIFY(! declarations->next);
ParameterDeclarationAST *param = declarations->declaration->asParameterDeclaration();
ParameterDeclarationAST *param = declarations->value->asParameterDeclaration();
QVERIFY(param);
QVERIFY(param->type_specifier != 0);
QVERIFY(param->type_specifier->next == 0);
......
......@@ -59,7 +59,7 @@ public:
TranslationUnitAST *ast = unit->ast()->asTranslationUnit();
QVERIFY(ast);
for (DeclarationListAST *decl = ast->declarations; decl; decl = decl->next) {
sem.check(decl->declaration, globals);
sem.check(decl->value, globals);
}
}
......
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