From c874ca1c7378d62aff008d74cf744636730f2db4 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Thu, 16 Feb 2012 02:02:14 +0000 Subject: [PATCH] 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 --- include/clang/AST/RecursiveASTVisitor.h | 4 +++- test/Index/index-refs.cpp | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h index a113a94846..a0f4950a04 100644 --- a/include/clang/AST/RecursiveASTVisitor.h +++ b/include/clang/AST/RecursiveASTVisitor.h @@ -1663,7 +1663,9 @@ DEF_TRAVERSE_DECL(CXXDestructorDecl, { template bool RecursiveASTVisitor::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(D)) + TRY_TO(TraverseStmt(D->getInit())); return true; } diff --git a/test/Index/index-refs.cpp b/test/Index/index-refs.cpp index fa4b4b3a09..56afa08ec8 100644 --- a/test/Index/index-refs.cpp +++ b/test/Index/index-refs.cpp @@ -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 -- 2.50.1