From d89c4cb938070a6de11e624984e5bd0e989fb334 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 29 Dec 2019 19:19:35 +0000 Subject: [PATCH] Match code following lambdas when ignoring invisible nodes Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71976 --- clang/lib/ASTMatchers/ASTMatchFinder.cpp | 2 +- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp b/clang/lib/ASTMatchers/ASTMatchFinder.cpp index ab90c74..0d1f713 100644 --- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp +++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp @@ -248,7 +248,7 @@ public: if (!match(*Node->getBody())) return false; - return false; + return true; } bool shouldVisitTemplateInstantiations() const { return true; } diff --git a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp index b907592..03482e7 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp @@ -1760,6 +1760,7 @@ void func13() { void func14() { [] (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) { -- 2.7.4