From cca0d29bc9f5a4b535590417c377113e141408b0 Mon Sep 17 00:00:00 2001 From: Yitzhak Mandelbaum Date: Fri, 15 Feb 2019 14:43:06 +0000 Subject: [PATCH] Added test for matcher On. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354134 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../ASTMatchers/ASTMatchersTraversalTest.cpp | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp b/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp index 52950b37b0a3..52a51b0d3500 100644 --- a/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp @@ -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()));