<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Dec 21, 2012, at 2:10 PM, Jordan Rose <<a href="mailto:jordan_rose@apple.com">jordan_rose@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; ">On Dec 21, 2012, at 13:59 , Ted Kremenek <</span><a href="mailto:kremenek@apple.com" style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">kremenek@apple.com</a><span style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; ">> wrote:</span><br style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><br style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><blockquote type="cite" style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">Author: kremenek<br>Date: Fri Dec 21 15:59:39 2012<br>New Revision: 170931<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=170931&view=rev">http://llvm.org/viewvc/llvm-project?rev=170931&view=rev</a><br>Log:<br>Change checkUnsafeAssignLiteral() to use the new Sema::CheckLiteralKind().<br><br>Along the way, fix a bug in CheckLiteralKind(), previously in diagnoseObjCLiteralComparison, where we didn't ignore parentheses<br>in boxed expressions for purpose of classification.<br><br>In other words, both @42 and @(42) should be classified as numeric<br>literals.<br></blockquote><br style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; ">That was sort of deliberate the first time around, but okay. I guess to the ObjC programmer they're the same thing.</span><br style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "></blockquote><div><br></div><div>Yes, my thoughts exactly.</div><br><blockquote type="cite"><br style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><br style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><br style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><blockquote type="cite" style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">Modified:<br>  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>  cfe/trunk/lib/Sema/SemaChecking.cpp<br>  cfe/trunk/lib/Sema/SemaExpr.cpp<br>  cfe/trunk/test/SemaObjC/arc.m<br><br>Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=170931&r1=170930&r2=170931&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=170931&r1=170930&r2=170931&view=diff</a><br>==============================================================================<br>--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)<br>+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Dec 21 15:59:39 2012<br>@@ -3690,7 +3690,7 @@<br> "; object will be released after assignment">,<br> InGroup<ARCUnsafeRetainedAssign>;<br>def warn_arc_literal_assign : Warning<<br>-  "assigning %select{dictionary literal|array literal|block literal|boxed expression}0"<br>+  "assigning %select{block literal|array literal|dictionary literal|numeric literal|boxed expression}0"<br> " to a weak %select{property|variable}1"<br> "; object will be released after assignment">,<br> InGroup<ARCUnsafeRetainedAssign>;<br><br>Modified: cfe/trunk/lib/Sema/SemaChecking.cpp<br>URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=170931&r1=170930&r2=170931&view=diff">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=170931&r1=170930&r2=170931&view=diff</a><br>==============================================================================<br>--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)<br>+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Dec 21 15:59:39 2012<br>@@ -5753,33 +5753,24 @@<br> // immediately zapped in a weak reference.  Note that we explicitly<br> // allow ObjCStringLiterals, since those are designed to never really die.<br> RHS = RHS->IgnoreParenImpCasts();<br>-  // This enum needs to match with the 'select' in warn_arc_literal_assign.<br>-  enum Kind { Dictionary = 0, Array, Block, BoxedE, None };<br>-  unsigned kind = None;<br>-  switch (RHS->getStmtClass()) {<br>-    default:<br>-      break;<br>-    case Stmt::ObjCDictionaryLiteralClass:<br>-      kind = Dictionary;<br>-      break;<br>-    case Stmt::ObjCArrayLiteralClass:<br>-      kind = Array;<br>-      break;<br>-    case Stmt::BlockExprClass:<br>-      kind = Block;<br>-      break;<br>-    case Stmt::ObjCBoxedExprClass:<br>-      kind = BoxedE;<br>-      break;<br>-  }<br>-  if (kind != None) {<br>-    S.Diag(Loc, diag::warn_arc_literal_assign)<br>-    << (unsigned) kind<br>+<br>+  // Classification for diagnostic.<br>+  unsigned SelectVal = /* block literal */ 0;<br>+  if (!isa<BlockExpr>(RHS)) {<br>+    // This enum needs to match with the 'select' in<br>+    // warn_objc_arc_literal_assign (off-by-1).<br>+    Sema::ObjCLiteralKind Kind = S.CheckLiteralKind(RHS);<br>+    if (Kind == Sema::LK_String || Kind == Sema::LK_None)<br>+      return false;<br>+    SelectVal = (unsigned) Kind + 1;<br>+  }<br></blockquote><br style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; ">This seems awkward again. Can we just add "Block" to the enum, even though it's not strictly an Objective-C thing? If we want to be pedantic we could call it something like "DynamicLiteralKind" (but, strings) or "OwnershipLiteralKind" (i.e. literals that produce objects managed by ARC).</span></blockquote></div><br><div>It's going to be awkward in some way.  The two diagnostics that use this classification care about different things, are a feeding the enum value to the %select{…} in the diagnostic.  In one case we care about the block literal, and in the other case we don't, etc.</div><div><br></div></body></html>