r354134 - Added test for matcher On.

Yitzhak Mandelbaum via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 15 06:43:06 PST 2019


Author: ymandel
Date: Fri Feb 15 06:43:06 2019
New Revision: 354134

URL: http://llvm.org/viewvc/llvm-project?rev=354134&view=rev
Log:
Added test for matcher On.

Modified:
    cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Modified: cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp?rev=354134&r1=354133&r2=354134&view=diff
==============================================================================
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp (original)
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Fri Feb 15 06:43:06 2019
@@ -470,24 +470,26 @@ TEST(Matcher, isInstanceMessage) {
 }
 
 TEST(MatcherCXXMemberCallExpr, On) {
-  auto MatchesType = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X")))));
-  EXPECT_TRUE(matches(
-      R"cc(
+  auto Snippet1 = R"cc(
         struct Y {
           void m();
         };
-        struct X : public Y {};
-        void z(X x) { x.m(); }
-      )cc",
-      MatchesType));
-  EXPECT_TRUE(notMatches(
-      R"cc(
+        void z(Y y) { y.m(); }
+      )cc";
+  auto Snippet2 = R"cc(
         struct Y {
           void m();
         };
-        void z(Y y) { y.m(); }
-      )cc",
-      MatchesType));
+        struct X : public Y {};
+        void z(X x) { x.m(); }
+      )cc";
+  auto MatchesY = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("Y")))));
+  EXPECT_TRUE(matches(Snippet1, MatchesY));
+  EXPECT_TRUE(notMatches(Snippet2, MatchesY));
+
+  auto MatchesX = cxxMemberCallExpr(on(hasType(cxxRecordDecl(hasName("X")))));
+  EXPECT_TRUE(notMatches(Snippet1, MatchesX));
+  EXPECT_TRUE(matches(Snippet2, MatchesX));
 
   // Parens are ignored.
   auto MatchesCall = cxxMemberCallExpr(on(callExpr()));




More information about the cfe-commits mailing list