diff --git a/src/shared/cplusplus/AST.cpp b/src/shared/cplusplus/AST.cpp index 9cb2d1f7425bd99cebc758171b36b125350f6940..44d2b978ff920ce8a9f2ed7b886e9937a87d8933 100644 --- a/src/shared/cplusplus/AST.cpp +++ b/src/shared/cplusplus/AST.cpp @@ -401,22 +401,6 @@ unsigned ClassSpecifierAST::lastToken() const return classkey_token + 1; } - -unsigned StatementListAST::firstToken() const -{ - return statement->firstToken(); -} - -unsigned StatementListAST::lastToken() const -{ - for (const StatementListAST *it = this; it; it = it->next) { - if (! it->next) - return it->statement->lastToken(); - } - - return 0; -} - unsigned CompoundStatementAST::firstToken() const { return lbrace_token; @@ -429,7 +413,7 @@ unsigned CompoundStatementAST::lastToken() const for (StatementListAST *it = statements; it; it = it->next) { if (! it->next) - return it->statement->lastToken(); + return it->value->lastToken(); } return lbrace_token + 1; diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h index 3bc6f8e17461886bf4937616bc59cdb4727b0241..a3686849b4e2d416508a68552ff0fb2eeac0865a 100644 --- a/src/shared/cplusplus/AST.h +++ b/src/shared/cplusplus/AST.h @@ -607,22 +607,6 @@ protected: virtual void accept0(ASTVisitor *visitor); }; -class CPLUSPLUS_EXPORT StatementListAST: public AST -{ -public: - StatementAST *statement; - StatementListAST *next; - -public: - virtual StatementListAST *asStatementList() { return this; } - - virtual unsigned firstToken() const; - virtual unsigned lastToken() const; - -protected: - virtual void accept0(ASTVisitor *visitor); -}; - class CPLUSPLUS_EXPORT CompoundStatementAST: public StatementAST { public: diff --git a/src/shared/cplusplus/ASTVisit.cpp b/src/shared/cplusplus/ASTVisit.cpp index 23578a006bb72489962ece69d1bca0c522a6b976..f3239d356a826d12bc4177e3146dbabe30e0ce17 100644 --- a/src/shared/cplusplus/ASTVisit.cpp +++ b/src/shared/cplusplus/ASTVisit.cpp @@ -180,14 +180,6 @@ void CaseStatementAST::accept0(ASTVisitor *visitor) visitor->endVisit(this); } -void StatementListAST::accept0(ASTVisitor *visitor) -{ - if (visitor->visit(this)) { - accept(statement, visitor); - } - visitor->endVisit(this); -} - void CompoundStatementAST::accept0(ASTVisitor *visitor) { if (visitor->visit(this)) { diff --git a/src/shared/cplusplus/ASTVisitor.h b/src/shared/cplusplus/ASTVisitor.h index 8ad6d640aa2edc381f29973bd58aedb255b8a8b6..41fcc38151aff7eeeb5dc1ce6e48fcc556d1743e 100644 --- a/src/shared/cplusplus/ASTVisitor.h +++ b/src/shared/cplusplus/ASTVisitor.h @@ -171,7 +171,6 @@ public: virtual bool visit(SimpleNameAST *) { return true; } virtual bool visit(SimpleSpecifierAST *) { return true; } virtual bool visit(SizeofExpressionAST *) { return true; } - virtual bool visit(StatementListAST *) { return true; } virtual bool visit(StringLiteralAST *) { return true; } virtual bool visit(SwitchStatementAST *) { return true; } virtual bool visit(TemplateArgumentListAST *) { return true; } @@ -305,7 +304,6 @@ public: virtual void endVisit(SimpleNameAST *) { } virtual void endVisit(SimpleSpecifierAST *) { } virtual void endVisit(SizeofExpressionAST *) { } - virtual void endVisit(StatementListAST *) { } virtual void endVisit(StringLiteralAST *) { } virtual void endVisit(SwitchStatementAST *) { } virtual void endVisit(TemplateArgumentListAST *) { } diff --git a/src/shared/cplusplus/ASTfwd.h b/src/shared/cplusplus/ASTfwd.h index ccc08845c315b75db1c1abee839dc99d980d62ae..61d7cc1aac7aed4a5e4d8717a9c8b3d5abc461ac 100644 --- a/src/shared/cplusplus/ASTfwd.h +++ b/src/shared/cplusplus/ASTfwd.h @@ -178,7 +178,6 @@ class SimpleSpecifierAST; class SizeofExpressionAST; class SpecifierAST; class StatementAST; -class StatementListAST; class StringLiteralAST; class SwitchStatementAST; class TemplateArgumentListAST; @@ -202,6 +201,7 @@ class WhileStatementAST; typedef List<ExpressionAST *> ExpressionListAST; typedef List<DeclarationAST *> DeclarationListAST; +typedef List<StatementAST *> StatementListAST; } // end of namespace CPlusPlus diff --git a/src/shared/cplusplus/CheckStatement.cpp b/src/shared/cplusplus/CheckStatement.cpp index 79a4e2e33d7df61d35a8824805c6734ff0261cb0..f2edeae338a90a3f0bb6b7a493f6918b642a7e58 100644 --- a/src/shared/cplusplus/CheckStatement.cpp +++ b/src/shared/cplusplus/CheckStatement.cpp @@ -105,7 +105,7 @@ bool CheckStatement::visit(CompoundStatementAST *ast) _scope->enterSymbol(block); Scope *previousScope = switchScope(block->members()); for (StatementListAST *it = ast->statements; it; it = it->next) { - semantic()->check(it->statement, _scope); + semantic()->check(it->value, _scope); } (void) switchScope(previousScope); return false; diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp index 76c374d93f5053849edd094022c70a8986d6bf49..1f121631a931b95c9120c47f863a1b65fcfe9608 100644 --- a/src/shared/cplusplus/Parser.cpp +++ b/src/shared/cplusplus/Parser.cpp @@ -2439,7 +2439,7 @@ bool Parser::parseCompoundStatement(StatementAST *&node) skipUntilStatement(); } else { *statement_ptr = new (_pool) StatementListAST; - (*statement_ptr)->statement = statement; + (*statement_ptr)->value = statement; statement_ptr = &(*statement_ptr)->next; } } diff --git a/tests/auto/cplusplus/ast/tst_ast.cpp b/tests/auto/cplusplus/ast/tst_ast.cpp index ea6d196889a85f89ae6bb3e148b6c94ed83a074d..43b2cb409f70bffa2fb4ed3b3ee85cc97aed165b 100644 --- a/tests/auto/cplusplus/ast/tst_ast.cpp +++ b/tests/auto/cplusplus/ast/tst_ast.cpp @@ -557,8 +557,8 @@ void tst_AST::normal_array_access() QVERIFY(bodyStatements); QVERIFY(bodyStatements->next); QVERIFY(bodyStatements->next->next); - QVERIFY(bodyStatements->next->next->statement); - ExpressionAST *expr = bodyStatements->next->next->statement->asReturnStatement()->expression; + QVERIFY(bodyStatements->next->next->value); + ExpressionAST *expr = bodyStatements->next->next->value->asReturnStatement()->expression; QVERIFY(expr); PostfixExpressionAST *postfixExpr = expr->asPostfixExpression(); @@ -598,8 +598,8 @@ void tst_AST::array_access_with_nested_expression() QVERIFY(func); StatementListAST *bodyStatements = func->function_body->asCompoundStatement()->statements; - QVERIFY(bodyStatements && bodyStatements->next && bodyStatements->next->next && bodyStatements->next->next->statement); - ExpressionAST *expr = bodyStatements->next->next->statement->asReturnStatement()->expression; + QVERIFY(bodyStatements && bodyStatements->next && bodyStatements->next->next && bodyStatements->next->next->value); + ExpressionAST *expr = bodyStatements->next->next->value->asReturnStatement()->expression; QVERIFY(expr); CastExpressionAST *castExpr = expr->asCastExpression(); @@ -643,10 +643,10 @@ void tst_AST::objc_msg_send_expression() QVERIFY(func); StatementListAST *bodyStatements = func->function_body->asCompoundStatement()->statements; - QVERIFY(bodyStatements && bodyStatements->next && !bodyStatements->next->next && bodyStatements->next->statement); + QVERIFY(bodyStatements && bodyStatements->next && !bodyStatements->next->next && bodyStatements->next->value); {// check the NSObject declaration - DeclarationStatementAST *firstStatement = bodyStatements->statement->asDeclarationStatement(); + DeclarationStatementAST *firstStatement = bodyStatements->value->asDeclarationStatement(); QVERIFY(firstStatement); DeclarationAST *objDecl = firstStatement->declaration; QVERIFY(objDecl); @@ -692,7 +692,7 @@ void tst_AST::objc_msg_send_expression() } {// check the return statement - ExpressionAST *expr = bodyStatements->next->statement->asReturnStatement()->expression; + ExpressionAST *expr = bodyStatements->next->value->asReturnStatement()->expression; QVERIFY(expr); ObjCMessageExpressionAST *msgExpr = expr->asObjCMessageExpression(); @@ -729,9 +729,9 @@ void tst_AST::objc_msg_send_expression_without_selector() StatementListAST *bodyStatements = func->function_body->asCompoundStatement()->statements; QVERIFY(bodyStatements && bodyStatements->next); - QVERIFY(bodyStatements->next->statement); - QVERIFY(bodyStatements->next->statement->asReturnStatement()); - QVERIFY(!bodyStatements->next->statement->asReturnStatement()->expression); + QVERIFY(bodyStatements->next->value); + QVERIFY(bodyStatements->next->value->asReturnStatement()); + QVERIFY(!bodyStatements->next->value->asReturnStatement()->expression); } QTEST_APPLESS_MAIN(tst_AST)