From: Aaron Ballman Date: Mon, 18 Jan 2016 20:28:57 +0000 (+0000) Subject: Augments r258042; changes the AST matcher tests to use matchesNot and EXPECT_TRUE... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f58f101d18029c9c847953dd4e218d661417bc5d;p=clang Augments r258042; changes the AST matcher tests to use matchesNot and EXPECT_TRUE instead of EXPECT_FALSE. Adds a matcher test to ensure that static member functions are properly handled. Generates the documentation from the matcher. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@258070 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/LibASTMatchersReference.html b/docs/LibASTMatchersReference.html index 48f061c60c..d452c783a8 100644 --- a/docs/LibASTMatchersReference.html +++ b/docs/LibASTMatchersReference.html @@ -3292,6 +3292,23 @@ Usable as: Matcher<CXXConstructExpr>forEachArgumentWithParamMatcher<Expr> ArgMatcher, Matcher<ParmVarDecl> ParamMatcher +
Matches all arguments and their respective ParmVarDecl.
+
+Given
+  void f(int i);
+  int y;
+  f(y);
+callExpr(declRefExpr(to(varDecl(hasName("y")))),
+parmVarDecl(hasType(isInteger())))
+  matches f(y);
+with declRefExpr(...)
+  matching int y
+and parmVarDecl(...)
+  matching int i
+
+ + Matcher<CXXConstructExpr>hasAnyArgumentMatcher<Expr> InnerMatcher
Matches any argument of a call expression or a constructor call
 expression.
@@ -3546,6 +3563,23 @@ implemented in terms of implicit casts.
 
+Matcher<CallExpr>forEachArgumentWithParamMatcher<Expr> ArgMatcher, Matcher<ParmVarDecl> ParamMatcher +
Matches all arguments and their respective ParmVarDecl.
+
+Given
+  void f(int i);
+  int y;
+  f(y);
+callExpr(declRefExpr(to(varDecl(hasName("y")))),
+parmVarDecl(hasType(isInteger())))
+  matches f(y);
+with declRefExpr(...)
+  matching int y
+and parmVarDecl(...)
+  matching int i
+
+ + Matcher<CallExpr>hasAnyArgumentMatcher<Expr> InnerMatcher
Matches any argument of a call expression or a constructor call
 expression.
diff --git a/unittests/ASTMatchers/ASTMatchersTest.cpp b/unittests/ASTMatchers/ASTMatchersTest.cpp
index 46392dcd63..c76100a433 100644
--- a/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ b/unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1616,9 +1616,9 @@ TEST(ForEachArgumentWithParam, ReportsNoFalsePositives) {
       callExpr(forEachArgumentWithParam(ArgumentY, IntParam));
 
   // IntParam does not match.
-  EXPECT_FALSE(matches("void f(int* i) { int* y; f(y); }", CallExpr));
+  EXPECT_TRUE(notMatches("void f(int* i) { int* y; f(y); }", CallExpr));
   // ArgumentY does not match.
-  EXPECT_FALSE(matches("void f(int i) { int x; f(x); }", CallExpr));
+  EXPECT_TRUE(notMatches("void f(int i) { int x; f(x); }", CallExpr));
 }
 
 TEST(ForEachArgumentWithParam, MatchesCXXMemberCallExpr) {
@@ -1636,6 +1636,18 @@ TEST(ForEachArgumentWithParam, MatchesCXXMemberCallExpr) {
       "  S1[y];"
       "}",
       CallExpr, new VerifyIdIsBoundTo("param", 1)));
+
+  StatementMatcher CallExpr2 =
+      callExpr(forEachArgumentWithParam(ArgumentY, IntParam));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+      "struct S {"
+      "  static void g(int i);"
+      "};"
+      "void f() {"
+      "  int y = 1;"
+      "  S::g(y);"
+      "}",
+      CallExpr2, new VerifyIdIsBoundTo("param", 1)));
 }
 
 TEST(ForEachArgumentWithParam, MatchesCallExpr) {