[cfe-commits] r159939 - in /cfe/trunk: docs/ReleaseNotes.html include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/FixIt/objc-literals.m test/SemaObjC/objc-literal-comparison.m

Jordan Rose jordan_rose at apple.com
Mon Jul 9 10:09:35 PDT 2012


Hm. It's a bit much to put in the actual warning text, though, and most people who use clang for Objective-C won't be looking at Clang release notes anyway. Maybe I can try to put it through in our internal documentation (what appears on developer.apple.com).

Jordan


On Jul 9, 2012, at 10:06 , Jean-Daniel Dupas <devlists at shadowlab.org> wrote:

> While this is just a warning now, I found the comment in the release note very helpful to understand why we should never do it.
> 
> Le 9 juil. 2012 à 18:54, Jordan Rose a écrit :
> 
>> Author: jrose
>> Date: Mon Jul  9 11:54:44 2012
>> New Revision: 159939
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=159939&view=rev
>> Log:
>> Downgrade the "direct comparison" error for ObjC literals to a warning.
>> 
>> Chris pointed out that while the comparison is certainly problematic
>> and does not have well-defined behavior, it isn't any worse than some
>> of the other abuses that we merely warn about and doesn't need to make
>> the compilation fail.
>> 
>> Revert the release notes change (r159766) now that this is just a new warning.
>> 
>> Modified:
>>   cfe/trunk/docs/ReleaseNotes.html
>>   cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>   cfe/trunk/lib/Sema/SemaExpr.cpp
>>   cfe/trunk/test/FixIt/objc-literals.m
>>   cfe/trunk/test/SemaObjC/objc-literal-comparison.m
>> 
>> Modified: cfe/trunk/docs/ReleaseNotes.html
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.html?rev=159939&r1=159938&r2=159939&view=diff
>> ==============================================================================
>> --- cfe/trunk/docs/ReleaseNotes.html (original)
>> +++ cfe/trunk/docs/ReleaseNotes.html Mon Jul  9 11:54:44 2012
>> @@ -218,21 +218,7 @@
>> <h3 id="objcchanges">Objective-C Language Changes in Clang</h3>
>> <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
>> 
>> -<ul>
>> -  <li>
>> -    <p>It is now an error to compare against the addresses of Objective-C
>> -       literals. This is usually a simple mistake (using <code>==</code> instead
>> -       of <code>-isEqual:</code>), and the result depends on the implementation
>> -       of the various literals, none of which are guaranteed to be uniqued or
>> -       always newly-allocated.</p>
>> -    <p>In the past, we allowed comparisons against literal strings
>> -       (<code>@"..."</code>), since they are currently uniqued across
>> -       translation units at link time. This is an implementation detail and
>> -       should not be relied upon. If you are using such code, please use global
>> -       string constants instead (<code>NSString * const MyConst = @"..."</code>)
>> -       or use <code>-isEqual:</code>.</p>
>> -  </li>
>> -</ul>
>> +<p>...</p>





More information about the cfe-commits mailing list