Author: Stephen Kelly Date: 2019-12-31T17:04:39Z New Revision: d89c4cb938070a6de11e624984e5bd0e989fb334
URL: https://github.com/llvm/llvm-project/commit/d89c4cb938070a6de11e624984e5bd0e989fb334 DIFF: https://github.com/llvm/llvm-project/commit/d89c4cb938070a6de11e624984e5bd0e989fb334.diff LOG: Match code following lambdas when ignoring invisible nodes Reviewers: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D71976 Added: Modified: clang/lib/ASTMatchers/ASTMatchFinder.cpp clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Removed: ################################################################################ diff --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp b/clang/lib/ASTMatchers/ASTMatchFinder.cpp index ab90c745791c..0d1f713db8d3 100644 --- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp +++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp @@ -248,7 +248,7 @@ class MatchChildASTVisitor 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 b9075927d745..03482e71fac4 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp @@ -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) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits