[cfe-commits] r59831 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Sema/SemaChecking.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaExprObjC.cpp test/Sema/builtins.c test/SemaObjC/message.m

Chris Lattner sabre at nondot.org
Fri Nov 21 10:44:42 PST 2008


Author: lattner
Date: Fri Nov 21 12:44:24 2008
New Revision: 59831

URL: http://llvm.org/viewvc/llvm-project?rev=59831&view=rev
Log:
merge some simple call diagnostics.

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/lib/Sema/SemaExprObjC.cpp
    cfe/trunk/test/Sema/builtins.c
    cfe/trunk/test/SemaObjC/message.m

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=59831&r1=59830&r2=59831&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Fri Nov 21 12:44:24 2008
@@ -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,

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=59831&r1=59830&r2=59831&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Nov 21 12:44:24 2008
@@ -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.

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=59831&r1=59830&r2=59831&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Nov 21 12:44:24 2008
@@ -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.

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=59831&r1=59830&r2=59831&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Fri Nov 21 12:44:24 2008
@@ -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());
     }

Modified: cfe/trunk/test/Sema/builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtins.c?rev=59831&r1=59830&r2=59831&view=diff

==============================================================================
--- cfe/trunk/test/Sema/builtins.c (original)
+++ cfe/trunk/test/Sema/builtins.c Fri Nov 21 12:44:24 2008
@@ -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}}
 }
 
 

Modified: cfe/trunk/test/SemaObjC/message.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/message.m?rev=59831&r1=59830&r2=59831&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjC/message.m (original)
+++ cfe/trunk/test/SemaObjC/message.m Fri Nov 21 12:44:24 2008
@@ -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}}
 }





More information about the cfe-commits mailing list