]> granicus.if.org Git - clang/commitdiff
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186700 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 2f4a3e7401cf0e76b50132b447bf08b7eea882e0..282006b57697dda1c4893d49c00506a8e082075d 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 e56c4cf2dd020c1bbcbeb2ff4e2f5b19bb7627a8..b9069f579232493939781973b8d575025eafba24 100644 (file)
@@ -27,3 +27,8 @@ enum {
 
 typedef NSUInteger UITableViewCellStyle;
 
+enum {
+  UNOne,
+  UNTwo
+};
+
index 8a09bff3b892e757b4ab41deef7d2f9cfe5c8efd..fcfe077039c8bb7532b4b7f09b1d0d0807114fca 100644 (file)
@@ -27,3 +27,8 @@ typedef NS_OPTIONS(NSUInteger, UITableViewCellStyle) {
 
 
 
+enum {
+  UNOne,
+  UNTwo
+};
+