Or maybe as a side note somewhere in the Obj-C literals doc at http://clang.llvm.org/docs/ObjectiveCLiterals.html
This document is supposed to "describes how the features are implemented in clang, and how to use them in your own programs." so it is probably a good place to discuss such implementation detail. Le 9 juil. 2012 à 19:09, Jordan Rose a écrit : > 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 <[email protected]> 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> > -- Jean-Daniel _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
