[PATCH] D94864: [ASTMatchers] Re-order the internals to allow another use-case
Stephen Kelly via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 19 14:11:02 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGecf696641e6c: [ASTMatchers] Allow use of mapAnyOf in more contexts (authored by stephenkelly).
Changed prior to commit:
https://reviews.llvm.org/D94864?vs=317175&id=317690#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94864/new/
https://reviews.llvm.org/D94864
Files:
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
Index: clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===================================================================
--- clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -491,6 +491,17 @@
Code, traverse(TK_IgnoreUnlessSpelledInSource,
mapAnyOf(ifStmt, forStmt).with(hasCondition(falseExpr)))));
+ EXPECT_TRUE(
+ matches(Code, cxxBoolLiteral(equals(true),
+ hasAncestor(mapAnyOf(ifStmt, forStmt)))));
+
+ EXPECT_TRUE(
+ matches(Code, cxxBoolLiteral(equals(false),
+ hasAncestor(mapAnyOf(ifStmt, forStmt)))));
+
+ EXPECT_TRUE(
+ notMatches(Code, floatLiteral(hasAncestor(mapAnyOf(ifStmt, forStmt)))));
+
Code = R"cpp(
void func(bool b) {}
struct S {
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===================================================================
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -1443,6 +1443,13 @@
operator()(const Matcher<T> &InnerMatcher) const {
return create(InnerMatcher);
}
+
+ template <typename... T>
+ ArgumentAdaptingMatcherFuncAdaptor<ArgumentAdapterT,
+ typename GetClade<T...>::Type, ToTypes>
+ operator()(const MapAnyOfHelper<T...> &InnerMatcher) const {
+ return create(InnerMatcher.with());
+ }
};
template <typename T> class TraversalMatcher : public MatcherInterface<T> {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94864.317690.patch
Type: text/x-patch
Size: 1575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210119/5db4e2cd/attachment.bin>
More information about the cfe-commits
mailing list