Skip to content

Commit

Permalink
Added test for matcher On.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354134 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
ymand committed Feb 15, 2019
1 parent 2ca23c2 commit cca0d29
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down

0 comments on commit cca0d29

Please sign in to comment.