From 23464b8f14d4a84fa419423362de2e95e49460b9 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 25 May 2009 18:23:36 +0000 Subject: [PATCH] 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); ^ llvm-svn: 72393 --- clang/lib/Sema/SemaChecking.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index 5a6babb3216c..c4183a0e61b1 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -793,9 +793,10 @@ Sema::CheckNonNullArguments(const NonNullAttr *NonNull, const CallExpr *TheCall) { 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(); } }