Fixes an ObjC migrator crash when last decl
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 19 Jul 2013 17:44:32 +0000 (17:44 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 19 Jul 2013 17:44:32 +0000 (17:44 +0000)
in file is an enum.

llvm-svn: 186700

clang/lib/ARCMigrate/ObjCMT.cpp
clang/test/ARCMT/objcmt-ns-macros.m
clang/test/ARCMT/objcmt-ns-macros.m.result

index 2f4a3e7..282006b 100644 (file)
@@ -399,7 +399,7 @@ static bool rewriteToNSEnumDecl(const EnumDecl *EnumDcl,
   return false;
 }
 
-void ObjCMigrateASTConsumer::migrateProtocolConformance(ASTContext &Ctx,
+void ObjCMigrateASTConsumer::migrateProtocolConformance(ASTContext &Ctx,   
                                             const ObjCImplementationDecl *ImpDecl) {
   const ObjCInterfaceDecl *IDecl = ImpDecl->getClassInterface();
   if (!IDecl || ObjCProtocolDecls.empty())
@@ -514,8 +514,9 @@ void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) {
       else if (const EnumDecl *ED = dyn_cast<EnumDecl>(*D)) {
         DeclContext::decl_iterator N = D;
         ++N;
-        if (const TypedefDecl *TD = dyn_cast<TypedefDecl>(*N))
-          migrateNSEnumDecl(Ctx, ED, TD);
+        if (N != DEnd)
+          if (const TypedefDecl *TD = dyn_cast<TypedefDecl>(*N))
+            migrateNSEnumDecl(Ctx, ED, TD);
       }
     }
   
index e56c4cf..b9069f5 100644 (file)
@@ -27,3 +27,8 @@ enum {
 
 typedef NSUInteger UITableViewCellStyle;
 
+enum {
+  UNOne,
+  UNTwo
+};
+
index 8a09bff..fcfe077 100644 (file)
@@ -27,3 +27,8 @@ typedef NS_OPTIONS(NSUInteger, UITableViewCellStyle) {
 
 
 
+enum {
+  UNOne,
+  UNTwo
+};
+