summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp
diff options
context:
space:
mode:
authorJames Dennett <jdennett@google.com>2013-06-30 03:13:35 +0000
committerJames Dennett <jdennett@google.com>2013-06-30 03:13:35 +0000
commit9ad9959e51087cfe32692f61e951ba3dd6d71974 (patch)
tree9c2ac53512a8f4efc89502c79c8177b76542c574 /clang/unittests/Tooling/RecursiveASTVisitorTest.cpp
parenteb576c0a061bad79b718c71175939bce03ffec3f (diff)
downloadbcm5719-llvm-9ad9959e51087cfe32692f61e951ba3dd6d71974.tar.gz
bcm5719-llvm-9ad9959e51087cfe32692f61e951ba3dd6d71974.zip
Bug fix: Make RecursiveASTVisitor<T>::TraverseLambdaExpr call
WalkUpFromLambdaExpr, so that the Visit* functions are called on that AST node. llvm-svn: 185277
Diffstat (limited to 'clang/unittests/Tooling/RecursiveASTVisitorTest.cpp')
-rw-r--r--clang/unittests/Tooling/RecursiveASTVisitorTest.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp b/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp
index 81be19003b2..2d226fddfc4 100644
--- a/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp
+++ b/clang/unittests/Tooling/RecursiveASTVisitorTest.cpp
@@ -79,6 +79,14 @@ public:
}
};
+class LambdaExprVisitor : public ExpectedLocationVisitor<LambdaExprVisitor> {
+public:
+ bool VisitLambdaExpr(LambdaExpr *Lambda) {
+ Match("", Lambda->getIntroducerRange().getBegin());
+ return true;
+ }
+};
+
class TemplateArgumentLocTraverser
: public ExpectedLocationVisitor<TemplateArgumentLocTraverser> {
public:
@@ -150,7 +158,8 @@ TEST(RecursiveASTVisitor, VisitsCXXForRangeStmtRange) {
Visitor.ExpectMatch("x", 2, 30);
EXPECT_TRUE(Visitor.runOver(
"int x[5];\n"
- "void f() { for (int i : x) { x[0] = 1; } }"));
+ "void f() { for (int i : x) { x[0] = 1; } }",
+ DeclRefExprVisitor::Lang_CXX11));
}
TEST(RecursiveASTVisitor, VisitsCXXForRangeStmtLoopVariable) {
@@ -158,7 +167,8 @@ TEST(RecursiveASTVisitor, VisitsCXXForRangeStmtLoopVariable) {
Visitor.ExpectMatch("i", 2, 17);
EXPECT_TRUE(Visitor.runOver(
"int x[5];\n"
- "void f() { for (int i : x) {} }"));
+ "void f() { for (int i : x) {} }",
+ VarDeclVisitor::Lang_CXX11));
}
TEST(RecursiveASTVisitor, VisitsCallExpr) {
@@ -461,4 +471,11 @@ TEST(RecursiveASTVisitor, VisitsCompoundLiteralType) {
TypeLocVisitor::Lang_C));
}
+TEST(RecursiveASTVisitor, VisitsLambdaExpr) {
+ LambdaExprVisitor Visitor;
+ Visitor.ExpectMatch("", 1, 12);
+ EXPECT_TRUE(Visitor.runOver("void f() { []{ return; }(); }",
+ LambdaExprVisitor::Lang_CXX11));
+}
+
} // end namespace clang
OpenPOWER on IntegriCloud