[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:49:42 PST 2012


On Fri, Feb 10, 2012 at 12:43 PM, David Blaikie <dblaikie at gmail.com> wrote:
> 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

[oops, missed a warning suppression/validation for 'false' as a null
pointer literal - I used an expected-warning, but I'm actually
undecided about whether we should do that in general (ad expected
warnings for warnings we aren't trying to test) rather than just
disable that warning in this test case (or, indeed, disable all
warnings except the ones we plan to test in a given test case - though
that might lose us a lot of fairly useful (if scattershot) accidental
coverage)]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: null_formats.diff
Type: text/x-patch
Size: 2215 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120210/4559ba0b/attachment.bin>


More information about the cfe-commits mailing list