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; }
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; }
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits