[cfe-commits] r170920 - /cfe/trunk/lib/Sema/SemaChecking.cpp

Ted Kremenek kremenek at apple.com
Fri Dec 21 11:45:33 PST 2012


Author: kremenek
Date: Fri Dec 21 13:45:33 2012
New Revision: 170920

URL: http://llvm.org/viewvc/llvm-project?rev=170920&view=rev
Log:
Use descriptive enum instead of raw integers for checkUnsafeAssignLiteral().

Modified:
    cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=170920&r1=170919&r2=170920&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Fri Dec 21 13:45:33 2012
@@ -5753,26 +5753,28 @@
   // immediately zapped in a weak reference.  Note that we explicitly
   // allow ObjCStringLiterals, since those are designed to never really die.
   RHS = RHS->IgnoreParenImpCasts();
-  unsigned kind = 4;
+  // This enum needs to match with the 'select' in warn_arc_literal_assign.
+  enum Kind { Dictionary = 0, Array, Block, BoxedE, None };
+  unsigned kind = None;
   switch (RHS->getStmtClass()) {
     default:
       break;
     case Stmt::ObjCDictionaryLiteralClass:
-      kind = 0;
+      kind = Dictionary;
       break;
     case Stmt::ObjCArrayLiteralClass:
-      kind = 1;
+      kind = Array;
       break;
     case Stmt::BlockExprClass:
-      kind = 2;
+      kind = Block;
       break;
     case Stmt::ObjCBoxedExprClass:
-      kind = 3;
+      kind = BoxedE;
       break;
   }
-  if (kind < 4) {
+  if (kind != None) {
     S.Diag(Loc, diag::warn_arc_literal_assign)
-    << kind
+    << (unsigned) kind
     << (isProperty ? 0 : 1)
     << RHS->getSourceRange();
     return true;





More information about the cfe-commits mailing list