[PATCH] D71976: Match code following lambdas when ignoring invisible nodes

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 31 09:06:05 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd89c4cb93807: Match code following lambdas when ignoring invisible nodes (authored by stephenkelly).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71976/new/

https://reviews.llvm.org/D71976

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


Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===================================================================
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -1760,6 +1760,7 @@
 
 void func14() {
   [] <typename TemplateType> (TemplateType t, TemplateType u) { int e = t + u; };
+  float i = 42.0;
 }
 
 )cpp";
@@ -1849,6 +1850,11 @@
                      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) {
Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===================================================================
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -248,7 +248,7 @@
     if (!match(*Node->getBody()))
       return false;
 
-    return false;
+    return true;
   }
 
   bool shouldVisitTemplateInstantiations() const { return true; }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71976.235718.patch
Type: text/x-patch
Size: 1301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20191231/f2ccd8c0/attachment.bin>


More information about the cfe-commits mailing list