Match code following lambdas when ignoring invisible nodes
authorStephen Kelly <steveire@gmail.com>
Sun, 29 Dec 2019 19:19:35 +0000 (19:19 +0000)
committerStephen Kelly <steveire@gmail.com>
Tue, 31 Dec 2019 17:04:39 +0000 (17:04 +0000)
Reviewers: aaron.ballman

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71976

clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

index ab90c74..0d1f713 100644 (file)
@@ -248,7 +248,7 @@ public:
     if (!match(*Node->getBody()))
       return false;
 
-    return false;
+    return true;
   }
 
   bool shouldVisitTemplateInstantiations() const { return true; }
index b907592..03482e7 100644 (file)
@@ -1760,6 +1760,7 @@ void func13() {
 
 void func14() {
   [] <typename TemplateType> (TemplateType t, TemplateType u) { int e = t + u; };
+  float i = 42.0;
 }
 
 )cpp";
@@ -1849,6 +1850,11 @@ void func14() {
                      lambdaExpr(
                          forFunction(functionDecl(hasName("func14"))),
                          has(templateTypeParmDecl(hasName("TemplateType")))))));
+
+  EXPECT_TRUE(
+      matches(Code, traverse(ast_type_traits::TK_IgnoreUnlessSpelledInSource,
+                             functionDecl(hasName("func14"),
+                                          hasDescendant(floatLiteral())))));
 }
 
 TEST(IgnoringImpCasts, MatchesImpCasts) {