diff --git a/clang/docs/LibASTMatchersReference.html b/clang/docs/LibASTMatchersReference.html --- a/clang/docs/LibASTMatchersReference.html +++ b/clang/docs/LibASTMatchersReference.html @@ -3053,6 +3053,17 @@ +Matcher<CXXConstructExpr>argumentCountAsWrittenIsunsigned N +
Checks that a call expression or a constructor call expression has
+a specific number of arguments (EXCLUDING absent default arguments).
+
+Example: callExpr(argumentCountAsWrittenIs(2)) matches f(0, 0) but not f(0)
+  void f(int x, int y = 0);
+  f(0, 0);
+  f(0);
+
+ + Matcher<CXXConstructExpr>argumentCountIsunsigned N
Checks that a call expression or a constructor call expression has
 a specific number of arguments (including absent default arguments).
@@ -3710,6 +3721,17 @@
 
+Matcher<CXXUnresolvedConstructExpr>argumentCountAsWrittenIsunsigned N +
Checks that a call expression or a constructor call expression has
+a specific number of arguments (EXCLUDING absent default arguments).
+
+Example: callExpr(argumentCountAsWrittenIs(2)) matches f(0, 0) but not f(0)
+  void f(int x, int y = 0);
+  f(0, 0);
+  f(0);
+
+ + Matcher<CXXUnresolvedConstructExpr>argumentCountIsunsigned N
Checks that a call expression or a constructor call expression has
 a specific number of arguments (including absent default arguments).
@@ -3720,6 +3742,17 @@
 
+Matcher<CallExpr>argumentCountAsWrittenIsunsigned N +
Checks that a call expression or a constructor call expression has
+a specific number of arguments (EXCLUDING absent default arguments).
+
+Example: callExpr(argumentCountAsWrittenIs(2)) matches f(0, 0) but not f(0)
+  void f(int x, int y = 0);
+  f(0, 0);
+  f(0);
+
+ + Matcher<CallExpr>argumentCountIsunsigned N
Checks that a call expression or a constructor call expression has
 a specific number of arguments (including absent default arguments).
@@ -4831,6 +4864,17 @@
 
+Matcher<ObjCMessageExpr>argumentCountAsWrittenIsunsigned N +
Checks that a call expression or a constructor call expression has
+a specific number of arguments (EXCLUDING absent default arguments).
+
+Example: callExpr(argumentCountAsWrittenIs(2)) matches f(0, 0) but not f(0)
+  void f(int x, int y = 0);
+  f(0, 0);
+  f(0);
+
+ + Matcher<ObjCMessageExpr>argumentCountIsunsigned N
Checks that a call expression or a constructor call expression has
 a specific number of arguments (including absent default arguments).
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4420,6 +4420,29 @@
   return NumArgs == N;
 }
 
+/// Checks that a call expression or a constructor call expression has
+/// a specific number of arguments (EXCLUDING absent default arguments).
+///
+/// Example: callExpr(argumentCountAsWrittenIs(2)) matches f(0, 0) but not f(0)
+/// \code
+///   void f(int x, int y = 0);
+///   f(0, 0);
+///   f(0);
+/// \endcode
+AST_POLYMORPHIC_MATCHER_P(argumentCountAsWrittenIs,
+                          AST_POLYMORPHIC_SUPPORTED_TYPES(
+                              CallExpr, CXXConstructExpr,
+                              CXXUnresolvedConstructExpr, ObjCMessageExpr),
+                          unsigned, N) {
+  unsigned NumArgs = Node.getNumArgs();
+  while (NumArgs) {
+    if (!isa(Node.getArg(NumArgs - 1)))
+      break;
+    --NumArgs;
+  }
+  return NumArgs == N;
+}
+
 /// Matches the n'th argument of a call expression or a constructor
 /// call expression.
 ///
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -135,6 +135,7 @@
   REGISTER_MATCHER(anyOf);
   REGISTER_MATCHER(anything);
   REGISTER_MATCHER(argumentCountIs);
+  REGISTER_MATCHER(argumentCountAsWrittenIs);
   REGISTER_MATCHER(arraySubscriptExpr);
   REGISTER_MATCHER(arrayType);
   REGISTER_MATCHER(asString);