From: Yitzhak Mandelbaum Date: Fri, 15 Feb 2019 14:43:10 +0000 (+0000) Subject: Exteded test of . X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e0d0812514be02832e2eead1eedfc0b86318be01;p=clang Exteded test of . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354136 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp b/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp index 3f4b1cfebc..7006361b4c 100644 --- a/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp +++ b/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp @@ -540,23 +540,27 @@ TEST(MatcherCXXMemberCallExpr, OnImplicitObjectArgument) { } TEST(Matcher, HasObjectExpr) { - auto M = memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))); - EXPECT_TRUE(matches( - R"cc( + auto Snippet1 = R"cc( struct X { int m; int f(X x) { return x.m; } }; - )cc", - M)); - EXPECT_TRUE(notMatches( - R"cc( + )cc"; + auto Snippet2 = R"cc( struct X { int m; int f(X x) { return m; } }; - )cc", - M)); + )cc"; + auto MatchesX = + memberExpr(hasObjectExpression(hasType(cxxRecordDecl(hasName("X"))))); + EXPECT_TRUE(matches(Snippet1, MatchesX)); + EXPECT_TRUE(notMatches(Snippet2, MatchesX)); + + auto MatchesXPointer = memberExpr( + hasObjectExpression(hasType(pointsTo(cxxRecordDecl(hasName("X")))))); + EXPECT_TRUE(notMatches(Snippet1, MatchesXPointer)); + EXPECT_TRUE(matches(Snippet2, MatchesXPointer)); } TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {