Fix the RecursiveASTVisitor to not traverse C++ default parameters twice.

llvm-svn: 150651
This commit is contained in:
Argyrios Kyrtzidis 2012-02-16 02:02:14 +00:00
parent ffbf9f1406
commit 85620ad239
2 changed files with 4 additions and 1 deletions

View File

@ -1663,7 +1663,9 @@ DEF_TRAVERSE_DECL(CXXDestructorDecl, {
template<typename Derived>
bool RecursiveASTVisitor<Derived>::TraverseVarHelper(VarDecl *D) {
TRY_TO(TraverseDeclaratorHelper(D));
TRY_TO(TraverseStmt(D->getInit()));
// Default params are taken care of when we traverse the ParmVarDecl.
if (!isa<ParmVarDecl>(D))
TRY_TO(TraverseStmt(D->getInit()));
return true;
}

View File

@ -107,3 +107,4 @@ void foo4(int p = default_param);
// CHECK: [indexEntityReference]: kind: variable | name: array_size | {{.*}} | loc: 59:22
// CHECK: [indexEntityReference]: kind: variable | name: default_param | {{.*}} | loc: 62:19
// CHECK-NOT: [indexEntityReference]: kind: variable | name: default_param | {{.*}} | loc: 62:19