]> granicus.if.org Git - clang/commitdiff
Exteded test of .
authorYitzhak Mandelbaum <yitzhakm@google.com>
Fri, 15 Feb 2019 14:43:10 +0000 (14:43 +0000)
committerYitzhak Mandelbaum <yitzhakm@google.com>
Fri, 15 Feb 2019 14:43:10 +0000 (14:43 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@354136 91177308-0d34-0410-b5e6-96231b3b80d8

unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

index 3f4b1cfebc8addf897a07112ecea96058da81eff..7006361b4c58ba0f3b3903ad93928375cf3f745a 100644 (file)
@@ -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) {