[cfe-commits] r159766 - /cfe/trunk/docs/ReleaseNotes.html

Jordan Rose jordan_rose at apple.com
Thu Jul 5 11:48:30 PDT 2012


Author: jrose
Date: Thu Jul  5 13:48:30 2012
New Revision: 159766

URL: http://llvm.org/viewvc/llvm-project?rev=159766&view=rev
Log:
Release notes for r158230 "Disallow using ObjC literals in direct comparisons"

This may turn out to be a controversial change, due to string literals being
uniqued at link time, but Apple's docs only say "The compiler makes such
object constants unique on a per-module basis..."[1] without actually saying
what a "module" is. (It's not a clang module.) Furthermore, this uniqueness
guarantee often can't be guaranteed once the string has been passed through
framework code.

If this does turn out very controversial, we could downgrade this to a
DefaultError warning for strings, and leave it as a true Error for other
kinds of literals.

(<rdar://problem/11300873>)

[1]: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Strings/Articles/CreatingStrings.html

Modified:
    cfe/trunk/docs/ReleaseNotes.html

Modified: cfe/trunk/docs/ReleaseNotes.html
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.html?rev=159766&r1=159765&r2=159766&view=diff
==============================================================================
--- cfe/trunk/docs/ReleaseNotes.html (original)
+++ cfe/trunk/docs/ReleaseNotes.html Thu Jul  5 13:48:30 2012
@@ -218,7 +218,21 @@
 <h3 id="objcchanges">Objective-C Language Changes in Clang</h3>
 <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
 
-<p>...</p>
+<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>
 
 <!-- = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = -->
 <h3 id="apichanges">Internal API Changes</h3>





More information about the cfe-commits mailing list