[cfe-commits] r150260 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/SemaCXX/format-strings.cpp

David Blaikie dblaikie at gmail.com
Fri Feb 10 12:43:54 PST 2012


On Fri, Feb 10, 2012 at 11:52 AM, Ted Kremenek <kremenek at apple.com> wrote:
> On Feb 10, 2012, at 11:42 AM, David Blaikie <dblaikie at gmail.com> wrote:
>
> On Fri, Feb 10, 2012 at 11:13 AM, Ted Kremenek <kremenek at apple.com> wrote:
>
> Author: kremenek
> Date: Fri Feb 10 13:13:51 2012
> New Revision: 150260
>
> URL: http://llvm.org/viewvc/llvm-project?rev=150260&view=rev
> Log:
> Enhance checking for null format string literal to take into account __null.
>   Fixes <rdar://problem/8269537>.
>
> Modified:
>    cfe/trunk/lib/Sema/SemaChecking.cpp
>    cfe/trunk/test/SemaCXX/format-strings.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=150260&r1=150259&r2=150260&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Feb 10 13:13:51 2012
> @@ -1381,6 +1381,7 @@
>                                  inFunctionCall);
>   }
>
> +  case Stmt::GNUNullExprClass:
>   case Stmt::IntegerLiteralClass:
>
>
> could/should this be generalized over all null pointer literals?
>
>
> Absolutely.
>
>
> This, for example, still flags 'nullptr' and (to a more questionable
> extent) 'false' which is still technically a valid null pointer. If
> I'm reading/testing it correctly, that is.
>
>
> It's questionable whether we should be happy with any integer literal, but
> definitely we should not warn about any cases of null.

The trick is any integer literal that didn't fail to compile in this
context is a null pointer. Anyway, here's a patch that generalizes
nicely along with some extra test cases it implements.

- David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: null_formats.diff
Type: text/x-patch
Size: 2216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120210/84cf0bf8/attachment.bin>


More information about the cfe-commits mailing list