[cfe-commits] r150651 - in /cfe/trunk: include/clang/AST/RecursiveASTVisitor.h test/Index/index-refs.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Wed Feb 15 18:02:14 PST 2012


Author: akirtzidis
Date: Wed Feb 15 20:02:14 2012
New Revision: 150651

URL: http://llvm.org/viewvc/llvm-project?rev=150651&view=rev
Log:
Fix the RecursiveASTVisitor to not traverse C++ default parameters twice.

Modified:
    cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
    cfe/trunk/test/Index/index-refs.cpp

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=150651&r1=150650&r2=150651&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Feb 15 20:02:14 2012
@@ -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;
 }
 

Modified: cfe/trunk/test/Index/index-refs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-refs.cpp?rev=150651&r1=150650&r2=150651&view=diff
==============================================================================
--- cfe/trunk/test/Index/index-refs.cpp (original)
+++ cfe/trunk/test/Index/index-refs.cpp Wed Feb 15 20:02:14 2012
@@ -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





More information about the cfe-commits mailing list