[PATCH] Expose LambdaIntroducer::DefaultLoc in the AST's LambdaExpr.
James Dennett
jdennett at google.com
Sat Jul 20 19:04:33 PDT 2013
Add a RecursiveASTVisitor-based test.
My hope is that this will be replaced by something better.
http://llvm-reviews.chandlerc.com/D1192
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1192?vs=2929&id=2930#toc
Files:
unittests/Tooling/RecursiveASTVisitorTest.cpp
Index: unittests/Tooling/RecursiveASTVisitorTest.cpp
===================================================================
--- unittests/Tooling/RecursiveASTVisitorTest.cpp
+++ unittests/Tooling/RecursiveASTVisitorTest.cpp
@@ -102,7 +102,19 @@
return PendingBodies.empty();
}
private:
- std::stack<LambdaExpr *> PendingBodies;
+ std::stack<LambdaExpr *> PendingBodies;
+};
+
+// Matches the (optional) capture-default of a lambda-introducer.
+class LambdaDefaultCaptureVisitor
+ : public ExpectedLocationVisitor<LambdaDefaultCaptureVisitor> {
+public:
+ bool VisitLambdaExpr(LambdaExpr *Lambda) {
+ if (Lambda->getCaptureDefault() != LCD_None) {
+ Match("", Lambda->getCaptureDefaultLoc());
+ }
+ return true;
+ }
};
class TemplateArgumentLocTraverser
@@ -503,4 +515,11 @@
EXPECT_TRUE(Visitor.allBodiesHaveBeenTraversed());
}
+TEST(RecursiveASTVisitor, HasCaptureDefaultLoc) {
+ LambdaDefaultCaptureVisitor Visitor;
+ Visitor.ExpectMatch("", 1, 20);
+ EXPECT_TRUE(Visitor.runOver("void f() { int a; [=]{a;}; }",
+ LambdaDefaultCaptureVisitor::Lang_CXX11));
+}
+
} // end namespace clang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1192.2.patch
Type: text/x-patch
Size: 1157 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130720/9c73c463/attachment.bin>
More information about the cfe-commits
mailing list