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> {


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> {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to