summaryrefslogtreecommitdiff
path: root/src/shared/cplusplus
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/cplusplus')
-rw-r--r--src/shared/cplusplus/AST.cpp4
-rw-r--r--src/shared/cplusplus/AST.h2
-rw-r--r--src/shared/cplusplus/ASTMatcher.cpp6
-rw-r--r--src/shared/cplusplus/ASTPatternBuilder.h4
-rw-r--r--src/shared/cplusplus/ASTVisit.cpp2
-rw-r--r--src/shared/cplusplus/CheckStatement.cpp77
-rw-r--r--src/shared/cplusplus/CheckStatement.h8
-rw-r--r--src/shared/cplusplus/Parser.cpp2
8 files changed, 58 insertions, 47 deletions
diff --git a/src/shared/cplusplus/AST.cpp b/src/shared/cplusplus/AST.cpp
index 570bcd9711..084334a9ab 100644
--- a/src/shared/cplusplus/AST.cpp
+++ b/src/shared/cplusplus/AST.cpp
@@ -2226,8 +2226,8 @@ unsigned ObjCFastEnumerationAST::firstToken() const
unsigned ObjCFastEnumerationAST::lastToken() const
{
- if (body_statement)
- return body_statement->lastToken();
+ if (statement)
+ return statement->lastToken();
else if (rparen_token)
return rparen_token + 1;
else if (fast_enumeratable_expression)
diff --git a/src/shared/cplusplus/AST.h b/src/shared/cplusplus/AST.h
index f21d9042fd..a26384b74f 100644
--- a/src/shared/cplusplus/AST.h
+++ b/src/shared/cplusplus/AST.h
@@ -2690,7 +2690,7 @@ public:
unsigned in_token;
ExpressionAST *fast_enumeratable_expression;
unsigned rparen_token;
- StatementAST *body_statement;
+ StatementAST *statement;
public: // annotations
Block *symbol;
diff --git a/src/shared/cplusplus/ASTMatcher.cpp b/src/shared/cplusplus/ASTMatcher.cpp
index b7920f767f..138950c230 100644
--- a/src/shared/cplusplus/ASTMatcher.cpp
+++ b/src/shared/cplusplus/ASTMatcher.cpp
@@ -2439,9 +2439,9 @@ bool ASTMatcher::match(ObjCFastEnumerationAST *node, ObjCFastEnumerationAST *pat
pattern->rparen_token = node->rparen_token;
- if (! pattern->body_statement)
- pattern->body_statement = node->body_statement;
- else if (! AST::match(node->body_statement, pattern->body_statement, this))
+ if (! pattern->statement)
+ pattern->statement = node->statement;
+ else if (! AST::match(node->statement, pattern->statement, this))
return false;
return true;
diff --git a/src/shared/cplusplus/ASTPatternBuilder.h b/src/shared/cplusplus/ASTPatternBuilder.h
index 5fedf7f909..aa95d8fe35 100644
--- a/src/shared/cplusplus/ASTPatternBuilder.h
+++ b/src/shared/cplusplus/ASTPatternBuilder.h
@@ -880,13 +880,13 @@ public:
return __ast;
}
- ObjCFastEnumerationAST *ObjCFastEnumeration(DeclaratorAST *declarator = 0, ExpressionAST *initializer = 0, ExpressionAST *fast_enumeratable_expression = 0, StatementAST *body_statement = 0)
+ ObjCFastEnumerationAST *ObjCFastEnumeration(DeclaratorAST *declarator = 0, ExpressionAST *initializer = 0, ExpressionAST *fast_enumeratable_expression = 0, StatementAST *statement = 0)
{
ObjCFastEnumerationAST *__ast = new (&pool) ObjCFastEnumerationAST;
__ast->declarator = declarator;
__ast->initializer = initializer;
__ast->fast_enumeratable_expression = fast_enumeratable_expression;
- __ast->body_statement = body_statement;
+ __ast->statement = statement;
return __ast;
}
diff --git a/src/shared/cplusplus/ASTVisit.cpp b/src/shared/cplusplus/ASTVisit.cpp
index 877dd8df74..070cf7fd85 100644
--- a/src/shared/cplusplus/ASTVisit.cpp
+++ b/src/shared/cplusplus/ASTVisit.cpp
@@ -1066,7 +1066,7 @@ void ObjCFastEnumerationAST::accept0(ASTVisitor *visitor)
accept(declarator, visitor);
accept(initializer, visitor);
accept(fast_enumeratable_expression, visitor);
- accept(body_statement, visitor);
+ accept(statement, visitor);
}
visitor->endVisit(this);
}
diff --git a/src/shared/cplusplus/CheckStatement.cpp b/src/shared/cplusplus/CheckStatement.cpp
index b02ba83749..878d3fbbeb 100644
--- a/src/shared/cplusplus/CheckStatement.cpp
+++ b/src/shared/cplusplus/CheckStatement.cpp
@@ -155,61 +155,64 @@ bool CheckStatement::visit(ExpressionStatementAST *ast)
return false;
}
-bool CheckStatement::visit(ForeachStatementAST *ast)
+bool CheckStatement::forEachFastEnum(unsigned firstToken,
+ unsigned lastToken,
+ SpecifierListAST *type_specifier_list,
+ DeclaratorAST *declarator,
+ ExpressionAST *initializer,
+ ExpressionAST *expression,
+ StatementAST *statement,
+ Block *&symbol)
{
- Block *block = control()->newBlock(ast->foreach_token);
- block->setStartOffset(tokenAt(ast->firstToken()).offset);
- block->setEndOffset(tokenAt(ast->lastToken()).offset);
- ast->symbol = block;
+ Block *block = control()->newBlock(firstToken);
+ block->setStartOffset(tokenAt(firstToken).offset);
+ block->setEndOffset(tokenAt(lastToken).offset);
+ symbol = block;
_scope->enterSymbol(block);
Scope *previousScope = switchScope(block->members());
- if (ast->type_specifier_list && ast->declarator) {
- FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope);
+ if (type_specifier_list && declarator) {
+ FullySpecifiedType ty = semantic()->check(type_specifier_list, _scope);
const Name *name = 0;
- ty = semantic()->check(ast->declarator, ty, _scope, &name);
- unsigned location = ast->declarator->firstToken();
- if (CoreDeclaratorAST *core_declarator = ast->declarator->core_declarator)
+ ty = semantic()->check(declarator, ty, _scope, &name);
+ unsigned location = declarator->firstToken();
+ if (CoreDeclaratorAST *core_declarator = declarator->core_declarator)
location = core_declarator->firstToken();
Declaration *decl = control()->newDeclaration(location, name);
decl->setType(ty);
_scope->enterSymbol(decl);
} else {
- FullySpecifiedType exprTy = semantic()->check(ast->initializer, _scope);
+ FullySpecifiedType exprTy = semantic()->check(initializer, _scope);
(void) exprTy;
}
- FullySpecifiedType exprTy = semantic()->check(ast->expression, _scope);
- semantic()->check(ast->statement, _scope);
+ FullySpecifiedType exprTy = semantic()->check(expression, _scope);
+ semantic()->check(statement, _scope);
(void) switchScope(previousScope);
return false;
}
-bool CheckStatement::visit(ObjCFastEnumerationAST *ast)
+bool CheckStatement::visit(ForeachStatementAST *ast)
{
- Block *block = control()->newBlock(ast->for_token);
- block->setStartOffset(tokenAt(ast->firstToken()).offset);
- block->setEndOffset(tokenAt(ast->lastToken()).offset);
- ast->symbol = block;
- _scope->enterSymbol(block);
- Scope *previousScope = switchScope(block->members());
- if (ast->type_specifier_list && ast->declarator) {
- FullySpecifiedType ty = semantic()->check(ast->type_specifier_list, _scope);
- const Name *name = 0;
- ty = semantic()->check(ast->declarator, ty, _scope, &name);
- unsigned location = ast->declarator->firstToken();
- if (CoreDeclaratorAST *core_declarator = ast->declarator->core_declarator)
- location = core_declarator->firstToken();
- Declaration *decl = control()->newDeclaration(location, name);
- decl->setType(ty);
- _scope->enterSymbol(decl);
- } else {
- FullySpecifiedType exprTy = semantic()->check(ast->initializer, _scope);
- (void) exprTy;
- }
+ return forEachFastEnum(ast->firstToken(),
+ ast->lastToken(),
+ ast->type_specifier_list,
+ ast->declarator,
+ ast->initializer,
+ ast->expression,
+ ast->statement,
+ ast->symbol);
+}
- semantic()->check(ast->body_statement, _scope);
- (void) switchScope(previousScope);
- return false;
+bool CheckStatement::visit(ObjCFastEnumerationAST *ast)
+{
+ return forEachFastEnum(ast->firstToken(),
+ ast->lastToken(),
+ ast->type_specifier_list,
+ ast->declarator,
+ ast->initializer,
+ ast->fast_enumeratable_expression,
+ ast->statement,
+ ast->symbol);
}
bool CheckStatement::visit(ForStatementAST *ast)
diff --git a/src/shared/cplusplus/CheckStatement.h b/src/shared/cplusplus/CheckStatement.h
index e31d507a5e..5c1b1ff02d 100644
--- a/src/shared/cplusplus/CheckStatement.h
+++ b/src/shared/cplusplus/CheckStatement.h
@@ -90,6 +90,14 @@ protected:
virtual bool visit(WhileStatementAST *ast);
virtual bool visit(QtMemberDeclarationAST *ast);
+ bool forEachFastEnum(unsigned firstToken,
+ unsigned lastToken,
+ SpecifierListAST *type_specifier_list,
+ DeclaratorAST *declarator,
+ ExpressionAST *initializer,
+ ExpressionAST *expression,
+ StatementAST *statement,
+ Block *&symbol);
private:
StatementAST *_statement;
Scope *_scope;
diff --git a/src/shared/cplusplus/Parser.cpp b/src/shared/cplusplus/Parser.cpp
index d66457ea9e..b40c59c4b7 100644
--- a/src/shared/cplusplus/Parser.cpp
+++ b/src/shared/cplusplus/Parser.cpp
@@ -2433,7 +2433,7 @@ bool Parser::parseForStatement(StatementAST *&node)
parseExpression(ast->fast_enumeratable_expression);
match(T_RPAREN, &ast->rparen_token);
- parseStatement(ast->body_statement);
+ parseStatement(ast->statement);
node = ast;
return true;