]> granicus.if.org Git - clang/commitdiff
When testing for anyOf(), the test should not be for an exact type match for all...
authorAaron Ballman <aaron@aaronballman.com>
Thu, 2 Jul 2015 14:02:41 +0000 (14:02 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Thu, 2 Jul 2015 14:02:41 +0000 (14:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241263 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ASTMatchers/ASTMatchersInternal.cpp
unittests/ASTMatchers/ASTMatchersTest.cpp

index 2c482e38dc08121ad6f13f0a2f286c3e9a73e9c7..b6ef8226a9a958ea98fab612e6119eef6b7ac232 100644 (file)
@@ -114,9 +114,9 @@ DynTypedMatcher DynTypedMatcher::constructVariadic(
   assert(InnerMatchers.size() > 0 && "Array must not be empty.");
   assert(std::all_of(InnerMatchers.begin(), InnerMatchers.end(),
                      [&InnerMatchers](const DynTypedMatcher &M) {
-           return InnerMatchers[0].SupportedKind.isSame(M.SupportedKind);
+           return InnerMatchers[0].canConvertTo(M.SupportedKind);
          }) &&
-         "SupportedKind must match!");
+         "SupportedKind must be convertible to a common type!");
 
   auto SupportedKind = InnerMatchers[0].SupportedKind;
   // We must relax the restrict kind here.
index 1fc7979bd073269e4aa51ac6a8be93b881764945..8ef3f15e4c086e166513406030ba971ae07bfb04 100644 (file)
@@ -482,6 +482,10 @@ TEST(DeclarationMatcher, MatchAnyOf) {
   EXPECT_TRUE(matches("int F() { return 1 + 2; }", MixedTypes));
   EXPECT_TRUE(matches("int F() { if (true) return 1; }", MixedTypes));
   EXPECT_TRUE(notMatches("int F() { return 1; }", MixedTypes));
+
+  EXPECT_TRUE(
+      matches("void f() try { } catch (int) { } catch (...) { }",
+              catchStmt(anyOf(hasDescendant(varDecl()), isCatchAll()))));
 }
 
 TEST(DeclarationMatcher, MatchHas) {