[cfe-commits] r158907 - in /cfe/trunk: include/clang/AST/RecursiveASTVisitor.h unittests/Tooling/RecursiveASTVisitorTest.cpp

Daniel Jasper djasper at google.com
Thu Jun 21 01:50:04 PDT 2012


Author: djasper
Date: Thu Jun 21 03:50:04 2012
New Revision: 158907

URL: http://llvm.org/viewvc/llvm-project?rev=158907&view=rev
Log:
Make the RecursiveASTVisitor visit the body of a range-based for loop
again. This was broken in r158395.

Modified:
    cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
    cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=158907&r1=158906&r2=158907&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Thu Jun 21 03:50:04 2012
@@ -1878,6 +1878,7 @@
   if (!shouldVisitImplicitCode()) {
     TRY_TO(TraverseStmt(S->getLoopVarStmt()));
     TRY_TO(TraverseStmt(S->getRangeInit()));
+    TRY_TO(TraverseStmt(S->getBody()));
     // Visit everything else only if shouldVisitImplicitCode().
     return true;
   }

Modified: cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp?rev=158907&r1=158906&r2=158907&view=diff
==============================================================================
--- cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RecursiveASTVisitorTest.cpp Thu Jun 21 03:50:04 2012
@@ -261,9 +261,10 @@
 TEST(RecursiveASTVisitor, VisitsCXXForRangeStmtRange) {
   DeclRefExprVisitor Visitor;
   Visitor.ExpectMatch("x", 2, 25);
+  Visitor.ExpectMatch("x", 2, 30);
   EXPECT_TRUE(Visitor.runOver(
     "int x[5];\n"
-    "void f() { for (int i : x) {} }"));
+    "void f() { for (int i : x) { x[0] = 1; } }"));
 }
 
 TEST(RecursiveASTVisitor, VisitsCXXForRangeStmtLoopVariable) {





More information about the cfe-commits mailing list