merge some simple call diagnostics.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59831 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def
index 443e311..6a85df0 100644
--- a/include/clang/Basic/DiagnosticKinds.def
+++ b/include/clang/Basic/DiagnosticKinds.def
@@ -1252,13 +1252,9 @@
 DIAG(err_typecheck_call_not_function, ERROR,
      "called object type '%0' is not a function or function pointer")
 DIAG(err_typecheck_call_too_few_args, ERROR,
-     "too few arguments to function")
-DIAG(err_typecheck_block_too_few_args, ERROR,
-     "too few arguments to block")
+     "too few arguments to %select{function|block|method}0 call")
 DIAG(err_typecheck_call_too_many_args, ERROR,
-     "too many arguments to function")
-DIAG(err_typecheck_block_too_many_args, ERROR,
-     "too many arguments to block call")
+     "too many arguments to %select{function|block|method}0 call")
 DIAG(err_typecheck_closure_too_many_args, ERROR,
      "too many arguments to closure call")
 DIAG(err_typecheck_call_invalid_ordered_compare, ERROR,
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index eb961d1..0947445 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -153,9 +153,9 @@
 bool Sema::SemaBuiltinVAStart(CallExpr *TheCall) {
   Expr *Fn = TheCall->getCallee();
   if (TheCall->getNumArgs() > 2) {
-    Diag(TheCall->getArg(2)->getLocStart(), 
+    Diag(TheCall->getArg(2)->getLocStart(),
          diag::err_typecheck_call_too_many_args)
-      << Fn->getSourceRange()
+      << 0 /*function call*/ << Fn->getSourceRange()
       << SourceRange(TheCall->getArg(2)->getLocStart(), 
                      (*(TheCall->arg_end()-1))->getLocEnd());
     return true;
@@ -202,10 +202,12 @@
 /// friends.  This is declared to take (...), so we have to check everything.
 bool Sema::SemaBuiltinUnorderedCompare(CallExpr *TheCall) {
   if (TheCall->getNumArgs() < 2)
-    return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args);
+    return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args)
+      << 0 /*function call*/;
   if (TheCall->getNumArgs() > 2)
     return Diag(TheCall->getArg(2)->getLocStart(), 
                 diag::err_typecheck_call_too_many_args)
+      << 0 /*function call*/
       << SourceRange(TheCall->getArg(2)->getLocStart(),
                      (*(TheCall->arg_end()-1))->getLocEnd());
   
@@ -242,7 +244,7 @@
 Action::ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) {
   if (TheCall->getNumArgs() < 3)
     return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args)
-      << TheCall->getSourceRange();
+      << 0 /*function call*/ << TheCall->getSourceRange();
 
   QualType FAType = TheCall->getArg(0)->getType();
   QualType SAType = TheCall->getArg(1)->getType();
@@ -266,9 +268,9 @@
   if (TheCall->getNumArgs() != numElements+2) {
     if (TheCall->getNumArgs() < numElements+2)
       return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_few_args)
-               << TheCall->getSourceRange();
+               << 0 /*function call*/ << TheCall->getSourceRange();
     return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_many_args)
-             << TheCall->getSourceRange();
+             << 0 /*function call*/ << TheCall->getSourceRange();
   }
 
   for (unsigned i = 2; i < TheCall->getNumArgs(); i++) {
@@ -304,7 +306,7 @@
 
   if (NumArgs > 3)
     return Diag(TheCall->getLocEnd(), diag::err_typecheck_call_too_many_args)
-             << TheCall->getSourceRange();
+             << 0 /*function call*/ << TheCall->getSourceRange();
 
   // Argument 0 is checked for us and the remaining arguments must be
   // constant integers.
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 7c4c15e..ba1bb25 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1369,27 +1369,21 @@
     // If too few arguments are available (and we don't have default
     // arguments for the remaining parameters), don't make the call.
     if (NumArgs < NumArgsInProto) {
-      if (FDecl && NumArgs >= FDecl->getMinRequiredArguments()) {
-        // Use default arguments for missing arguments
-        NumArgsToCheck = NumArgsInProto;
-        TheCall->setNumArgs(NumArgsInProto);
-      } else
-        return Diag(RParenLoc, 
-                    !Fn->getType()->isBlockPointerType()
-                      ? diag::err_typecheck_call_too_few_args
-                      : diag::err_typecheck_block_too_few_args)
-          << Fn->getSourceRange();
+      if (!FDecl || NumArgs < FDecl->getMinRequiredArguments())
+        return Diag(RParenLoc, diag::err_typecheck_call_too_few_args)
+          << Fn->getType()->isBlockPointerType() << Fn->getSourceRange();
+      // Use default arguments for missing arguments
+      NumArgsToCheck = NumArgsInProto;
+      TheCall->setNumArgs(NumArgsInProto);
     }
 
     // If too many are passed and not variadic, error on the extras and drop
     // them.
     if (NumArgs > NumArgsInProto) {
       if (!Proto->isVariadic()) {
-        Diag(Args[NumArgsInProto]->getLocStart(), 
-               !Fn->getType()->isBlockPointerType()
-                 ? diag::err_typecheck_call_too_many_args
-                 : diag::err_typecheck_block_too_many_args)
-          << Fn->getSourceRange()
+        Diag(Args[NumArgsInProto]->getLocStart(),
+             diag::err_typecheck_call_too_many_args)
+          << Fn->getType()->isBlockPointerType() << Fn->getSourceRange()
           << SourceRange(Args[NumArgsInProto]->getLocStart(),
                          Args[NumArgs-1]->getLocEnd());
         // This deletes the extra arguments.
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index b73449e..d092793 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -161,7 +161,7 @@
     if (NumArgs != NumNamedArgs) {
       Diag(Args[NumNamedArgs]->getLocStart(), 
            diag::err_typecheck_call_too_many_args)
-        << Method->getSourceRange()
+        << 2 /*method*/ << Method->getSourceRange()
         << SourceRange(Args[NumNamedArgs]->getLocStart(),
                        Args[NumArgs-1]->getLocEnd());
     }
diff --git a/test/Sema/builtins.c b/test/Sema/builtins.c
index d02adf3..bbbad42 100644
--- a/test/Sema/builtins.c
+++ b/test/Sema/builtins.c
@@ -28,7 +28,7 @@
   CFSTR("\242"); // expected-warning {{ CFString literal contains non-ASCII character }}
   CFSTR("\0"); // expected-warning {{ CFString literal contains NUL character }}
   CFSTR(242); // expected-error {{ CFString literal is not a string constant }} expected-warning {{incompatible integer to pointer conversion}}
-  CFSTR("foo", "bar"); // expected-error {{ error: too many arguments to function }}
+  CFSTR("foo", "bar"); // expected-error {{too many arguments to function call}}
 }
 
 
diff --git a/test/SemaObjC/message.m b/test/SemaObjC/message.m
index 69a6535..274885d 100644
--- a/test/SemaObjC/message.m
+++ b/test/SemaObjC/message.m
@@ -66,5 +66,5 @@
 @end
 
 int f0(I0 *ob) {
-  [ ob nonVararg: 0, 1, 2]; // expected-error {{too many arguments to function}}
+  [ ob nonVararg: 0, 1, 2]; // expected-error {{too many arguments to method call}}
 }