[PATCH] D22566: Make RecursiveASTVisitor visit lambda capture initialization expressions

Martin Böhme via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 26 08:26:50 PDT 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL276755: Make RecursiveASTVisitor visit lambda capture initialization expressions (authored by mboehme).

Changed prior to commit:
  https://reviews.llvm.org/D22566?vs=64665&id=65526#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22566

Files:
  cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
  cfe/trunk/unittests/Tooling/RecursiveASTVisitorTestExprVisitor.cpp

Index: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
===================================================================
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
@@ -2266,6 +2266,9 @@
        C != CEnd; ++C) {
     TRY_TO(TraverseLambdaCapture(S, C));
   }
+  for (Expr *Init : S->capture_inits()) {
+    TRY_TO_TRAVERSE_OR_ENQUEUE_STMT(Init);
+  }
 
   TypeLoc TL = S->getCallOperator()->getTypeSourceInfo()->getTypeLoc();
   FunctionProtoTypeLoc Proto = TL.castAs<FunctionProtoTypeLoc>();
Index: cfe/trunk/unittests/Tooling/RecursiveASTVisitorTestExprVisitor.cpp
===================================================================
--- cfe/trunk/unittests/Tooling/RecursiveASTVisitorTestExprVisitor.cpp
+++ cfe/trunk/unittests/Tooling/RecursiveASTVisitorTestExprVisitor.cpp
@@ -191,6 +191,14 @@
     "void x(); void y() { x(); }"));
 }
 
+TEST(RecursiveASTVisitor, VisitsLambdaCaptureInit) {
+  DeclRefExprVisitor Visitor;
+  Visitor.ExpectMatch("i", 1, 20);
+  EXPECT_TRUE(Visitor.runOver(
+    "void f() { int i; [i]{}; };",
+    DeclRefExprVisitor::Lang_CXX11));
+}
+
 /* FIXME: According to Richard Smith this is a bug in the AST.
 TEST(RecursiveASTVisitor, VisitsBaseClassTemplateArgumentsInInstantiation) {
   DeclRefExprVisitor Visitor;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22566.65526.patch
Type: text/x-patch
Size: 1316 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160726/1da8cd58/attachment-0001.bin>


More information about the cfe-commits mailing list