Fix the RecursiveASTVisitor to not traverse C++ default parameters twice.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150651 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h
index a113a948..a0f4950 100644
--- a/include/clang/AST/RecursiveASTVisitor.h
+++ b/include/clang/AST/RecursiveASTVisitor.h
@@ -1663,7 +1663,9 @@
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;
}
diff --git a/test/Index/index-refs.cpp b/test/Index/index-refs.cpp
index fa4b4b3..56afa08 100644
--- a/test/Index/index-refs.cpp
+++ b/test/Index/index-refs.cpp
@@ -107,3 +107,4 @@
// 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