[cfe-commits] r72393 - /cfe/trunk/lib/Sema/SemaChecking.cpp

Chris Lattner sabre at nondot.org
Mon May 25 11:23:36 PDT 2009


Author: lattner
Date: Mon May 25 13:23:36 2009
New Revision: 72393

URL: http://llvm.org/viewvc/llvm-project?rev=72393&view=rev
Log:
tweak non-null check to put the caret on the function, but underline the
argument.  This avoids the argument from being silenced when the argument is
the NULL macro, which is defined in a system header.  This also makes the output
a bit nicer, e.g.:

t.c:8:3: warning: null passed to a callee which requires a non-null argument
  func1(NULL, cp2, i1);
  ^     ~~~~

vs something like:

t.c:8:10: warning: argument is null where non-null is required
  func1(NULL, cp2, i1);
        ^


Modified:
    cfe/trunk/lib/Sema/SemaChecking.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon May 25 13:23:36 2009
@@ -793,9 +793,10 @@
 {
   for (NonNullAttr::iterator i = NonNull->begin(), e = NonNull->end();
        i != e; ++i) {
-    const Expr *ArgExpr = TheCall->getArg(*i)->IgnoreParenCasts();
+    const Expr *ArgExpr = TheCall->getArg(*i);
     if (ArgExpr->isNullPointerConstant(Context))
-      Diag(ArgExpr->getLocStart(), diag::warn_null_arg);
+      Diag(TheCall->getCallee()->getLocStart(), diag::warn_null_arg)
+        << ArgExpr->getSourceRange();
   }
 }
 





More information about the cfe-commits mailing list