]> granicus.if.org Git - clang/commitdiff
ObjectiveC migrator. In infering NS_ENUM/NS_OPTIONS
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 17 Oct 2013 22:23:32 +0000 (22:23 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 17 Oct 2013 22:23:32 +0000 (22:23 +0000)
macros, prefer the typedef immediately following the
enum declaration to the one preceeding it.
// rdar://15200915

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

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

index deb391f967f4a32d7e2dbf2a5043fe98c97ca479..8356fb65921376c271de66b394a7c44f8ef458bc 100644 (file)
@@ -745,6 +745,7 @@ bool ObjCMigrateASTConsumer::migrateNSEnumDecl(ASTContext &Ctx,
         edit::Commit commit(*Editor);
         rewriteToNSMacroDecl(EnumDcl, TypedefDcl, *NSAPIObj, commit, !NSOptions);
         Editor->commit(commit);
+        return true;
       }
     }
     return false;
@@ -1530,6 +1531,15 @@ void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) {
           DeclContext::decl_iterator N = D;
           if (++N != DEnd)
             if (const EnumDecl *ED = dyn_cast<EnumDecl>(*N)) {
+              if (++N != DEnd) {
+                if (const TypedefDecl *TD1 = dyn_cast<TypedefDecl>(*N)) {
+                  if (migrateNSEnumDecl(Ctx, ED, TD1)) {
+                    ++D; ++D;
+                    CacheObjCNSIntegerTypedefed(TD);
+                    continue;
+                  }
+                }
+              }
               if (migrateNSEnumDecl(Ctx, ED, TD)) {
                 ++D;
                 continue;
index a2f0707ed79a1b40ab82eac1ecd5679545f40e1d..1bf55d8ed46b658aae22efd4c125731ebe6ac4d1 100644 (file)
@@ -217,10 +217,10 @@ enum {
 typedef NSInteger NSModalResponse NS_AVAILABLE_MAC(10.9);
 
 // rdar://15201056
-typedef NSUInteger FarAwayNSUInteger;
+typedef NSUInteger FarFarAwayOptions;
 
 // rdar://15200915
-typedef NSUInteger NSWorkspaceLaunchOptions;
+typedef NSUInteger FarAwayOptions;
 enum {
      NSWorkspaceLaunchAndPrint =                 0x00000002,
      NSWorkspaceLaunchWithErrorPresentation    = 0x00000040,
@@ -234,20 +234,21 @@ enum {
      NSWorkspaceLaunchAndHide                  = 0x00100000,
      NSWorkspaceLaunchAndHideOthers            = 0x00200000,
      NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync | 
-NSWorkspaceLaunchAllowingClassicStartup
+     NSWorkspaceLaunchAllowingClassicStartup
 };
+typedef NSUInteger NSWorkspaceLaunchOptions;
 
-typedef NSUInteger NSWorkspaceIconCreationOptions;
 enum {
     NSExcludeQuickDrawElementsIconCreationOption    = 1 << 1,
     NSExclude10_4ElementsIconCreationOption         = 1 << 2
 };
+typedef NSUInteger NSExcludeOptions;
 
-typedef NSUInteger NSWorkspaceCreationOptions;
 enum {
     NSExcludeQuickDrawElementsCreationOption    = 1 << 1,
     NSExclude10_4ElementsCreationOption         = 1 << 2
 };
+typedef NSUInteger NSExcludeCreationOption;
 
 enum {
   FarAway1    = 1 << 1,
@@ -258,17 +259,38 @@ enum {
     NSExcludeQuickDrawElementsIconOption    = 1 << 1,
     NSExclude10_4ElementsIconOption         = 1 << 2
 };
-typedef NSUInteger NSWorkspaceIconOptions;
-
-typedef NSInteger NSCollectionViewDropOperation;
+typedef NSUInteger NSExcludeIconOptions;
 
 @interface INTF {
-  NSCollectionViewDropOperation I1;
-  NSCollectionViewDropOperation I2;
+  NSExcludeIconOptions I1;
+  NSExcludeIconOptions I2;
 }
 @end
 
 enum {
-  NotFarAway1    = 1 << 1,
-  NotFarAway2    = 1 << 2
+  FarFarAway1    = 1 << 1,
+  FarFarAway2    = 1 << 2
+};
+
+// rdar://15200915
+typedef NS_OPTIONS(NSUInteger, NSWindowOcclusionState) {
+    NSWindowOcclusionStateVisible = 1UL << 1,
+};
+
+typedef NSUInteger NSWindowNumberListOptions;
+
+enum {
+    NSDirectSelection = 0,
+    NSSelectingNext,
+    NSSelectingPrevious
+};
+typedef NSUInteger NSSelectionDirection;
+
+// standard window buttons
+enum {
+    NSWindowCloseButton,
+    NSWindowMiniaturizeButton,
+    NSWindowZoomButton,
+    NSWindowToolbarButton,
+    NSWindowDocumentIconButton
 };
index 445b367a3f3d2fe0466fa57f69807935a578e956..0b640ac35676dac82e73e236066a27b92563026a 100644 (file)
@@ -207,12 +207,13 @@ typedef NS_ENUM(NSInteger, NSModalResponse) {
 } NS_ENUM_AVAILABLE_MAC(10.9);
 
 // rdar://15201056
-typedef NS_OPTIONS(NSUInteger, FarAwayNSUInteger) {
+typedef NSUInteger FarFarAwayOptions;
+
+// rdar://15200915
+typedef NS_OPTIONS(NSUInteger, FarAwayOptions) {
   FarAway1    = 1 << 1,
   FarAway2    = 1 << 2
 };
-
-// rdar://15200915
 typedef NS_OPTIONS(NSUInteger, NSWorkspaceLaunchOptions) {
      NSWorkspaceLaunchAndPrint =                 0x00000002,
      NSWorkspaceLaunchWithErrorPresentation    = 0x00000040,
@@ -226,33 +227,53 @@ typedef NS_OPTIONS(NSUInteger, NSWorkspaceLaunchOptions) {
      NSWorkspaceLaunchAndHide                  = 0x00100000,
      NSWorkspaceLaunchAndHideOthers            = 0x00200000,
      NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync | 
-NSWorkspaceLaunchAllowingClassicStartup
+     NSWorkspaceLaunchAllowingClassicStartup
 };
 
-typedef NS_OPTIONS(NSUInteger, NSWorkspaceIconCreationOptions) {
+typedef NS_OPTIONS(NSUInteger, NSExcludeOptions) {
     NSExcludeQuickDrawElementsIconCreationOption    = 1 << 1,
     NSExclude10_4ElementsIconCreationOption         = 1 << 2
 };
 
-typedef NS_OPTIONS(NSUInteger, NSWorkspaceCreationOptions) {
+typedef NS_OPTIONS(NSUInteger, NSExcludeCreationOption) {
     NSExcludeQuickDrawElementsCreationOption    = 1 << 1,
     NSExclude10_4ElementsCreationOption         = 1 << 2
 };
 
 
-typedef NS_OPTIONS(NSUInteger, NSWorkspaceIconOptions) {
+typedef NS_OPTIONS(NSUInteger, NSExcludeIconOptions) {
     NSExcludeQuickDrawElementsIconOption    = 1 << 1,
     NSExclude10_4ElementsIconOption         = 1 << 2
 };
 
-typedef NS_OPTIONS(NSUInteger, NSCollectionViewDropOperation) {
-  NotFarAway1    = 1 << 1,
-  NotFarAway2    = 1 << 2
-};
-
 @interface INTF {
-  NSCollectionViewDropOperation I1;
-  NSCollectionViewDropOperation I2;
+  NSExcludeIconOptions I1;
+  NSExcludeIconOptions I2;
 }
 @end
 
+enum {
+  FarFarAway1    = 1 << 1,
+  FarFarAway2    = 1 << 2
+};
+
+// rdar://15200915
+typedef NS_OPTIONS(NSUInteger, NSWindowOcclusionState) {
+    NSWindowOcclusionStateVisible = 1UL << 1,
+};
+
+typedef NS_ENUM(NSUInteger, NSWindowNumberListOptions) {
+    NSWindowCloseButton,
+    NSWindowMiniaturizeButton,
+    NSWindowZoomButton,
+    NSWindowToolbarButton,
+    NSWindowDocumentIconButton
+};
+
+typedef NS_ENUM(NSUInteger, NSSelectionDirection) {
+    NSDirectSelection = 0,
+    NSSelectingNext,
+    NSSelectingPrevious
+};
+
+// standard window buttons