diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-05-01 08:06:46 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-05-01 08:06:46 +0000 |
commit | 336f51e463340dc7b159bc38517ac4a68081302d (patch) | |
tree | 09a362d0686e1adeca21f51622fdb7a541dc6db1 | |
parent | 06207f6f5f248f678498d61d6dbb36774b7fe5ae (diff) |
Improve traversing of BlockExprs in RecursiveASTVisitor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@130650 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/RecursiveASTVisitor.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index 9edc7de114..930d19373c 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -1049,7 +1049,9 @@ bool RecursiveASTVisitor<Derived>::TraverseDeclContextHelper(DeclContext *DC) { for (DeclContext::decl_iterator Child = DC->decls_begin(), ChildEnd = DC->decls_end(); Child != ChildEnd; ++Child) { - TRY_TO(TraverseDecl(*Child)); + // BlockDecls are traversed through BlockExprs. + if (!isa<BlockDecl>(*Child)) + TRY_TO(TraverseDecl(*Child)); } return true; @@ -1068,10 +1070,12 @@ bool RecursiveASTVisitor<Derived>::Traverse##DECL (DECL *D) { \ DEF_TRAVERSE_DECL(AccessSpecDecl, { }) DEF_TRAVERSE_DECL(BlockDecl, { - // We don't traverse nodes in param_begin()/param_end(), as they - // appear in decls_begin()/decls_end() and thus are handled by the - // DEF_TRAVERSE_DECL macro already. + TRY_TO(TraverseTypeLoc(D->getSignatureAsWritten()->getTypeLoc())); TRY_TO(TraverseStmt(D->getBody())); + // This return statement makes sure the traversal of nodes in + // decls_begin()/decls_end() (done in the DEF_TRAVERSE_DECL macro) + // is skipped - don't remove it. + return true; }) DEF_TRAVERSE_DECL(FileScopeAsmDecl, { @@ -1883,7 +1887,10 @@ DEF_TRAVERSE_STMT(CXXMemberCallExpr, { }) DEF_TRAVERSE_STMT(AddrLabelExpr, { }) DEF_TRAVERSE_STMT(ArraySubscriptExpr, { }) DEF_TRAVERSE_STMT(BlockDeclRefExpr, { }) -DEF_TRAVERSE_STMT(BlockExpr, { }) +DEF_TRAVERSE_STMT(BlockExpr, { + TRY_TO(TraverseDecl(S->getBlockDecl())); + return true; // no child statements to loop through. +}) DEF_TRAVERSE_STMT(ChooseExpr, { }) DEF_TRAVERSE_STMT(CompoundLiteralExpr, { }) DEF_TRAVERSE_STMT(CXXBindTemporaryExpr, { }) |