[clang] d89c4cb - Match code following lambdas when ignoring invisible nodes
Stephen Kelly via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 31 09:05:03 PST 2019
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) {
More information about the cfe-commits
mailing list