aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhanyong Wan <wan@google.com>2010-06-30 18:34:52 +0000
committerZhanyong Wan <wan@google.com>2010-06-30 18:34:52 +0000
commit6beaf938c0a2587ac4b2b60a51fbb9a80f72b766 (patch)
tree723e27c5641a17dacaacf5038e36b46526c6751b
parent2fe13882a846b4152abf0734be43b3e141843818 (diff)
Fix RecursiveASTVisitor to traverse the ctor initializer list before
traversing the ctor body when traversing a CXXConstructorDecl. Reviewed by chandlerc and csilvers. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107304 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/RecursiveASTVisitor.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h
index 5192ce3607..3248a40eaa 100644
--- a/include/clang/AST/RecursiveASTVisitor.h
+++ b/include/clang/AST/RecursiveASTVisitor.h
@@ -992,6 +992,16 @@ bool RecursiveASTVisitor<Derived>::TraverseFunctionHelper(FunctionDecl *D) {
TRY_TO(TraverseType(D->getResultType()));
TRY_TO(TraverseDeclContextHelper(D)); // Parameters.
+
+ if (CXXConstructorDecl *Ctor = dyn_cast<CXXConstructorDecl>(D)) {
+ // Constructor initializers.
+ for (CXXConstructorDecl::init_iterator I = Ctor->init_begin(),
+ E = Ctor->init_end();
+ I != E; ++I) {
+ TRY_TO(TraverseConstructorInitializer(*I));
+ }
+ }
+
if (D->isThisDeclarationADefinition()) {
TRY_TO(TraverseStmt(D->getBody())); // Function body.
}
@@ -1011,18 +1021,9 @@ DEF_TRAVERSE_DECL(CXXMethodDecl, {
})
DEF_TRAVERSE_DECL(CXXConstructorDecl, {
- TRY_TO(TraverseFunctionHelper(D));
- // FIXME: traverse the initializers before traversing the
- // constructor body.
- for (CXXConstructorDecl::init_iterator I = D->init_begin(),
- E = D->init_end();
- I != E; ++I) {
- TRY_TO(TraverseConstructorInitializer(*I));
- }
-
// We skip decls_begin/decls_end, which are already covered by
// TraverseFunctionHelper().
- return true;
+ return TraverseFunctionHelper(D);
})
// CXXConversionDecl is the declaration of a type conversion operator.