r192927 - ObjectiveC migrator. In infering NS_ENUM/NS_OPTIONS
Fariborz Jahanian
fjahanian at apple.com
Thu Oct 17 15:23:32 PDT 2013
Author: fjahanian
Date: Thu Oct 17 17:23:32 2013
New Revision: 192927
URL: http://llvm.org/viewvc/llvm-project?rev=192927&view=rev
Log:
ObjectiveC migrator. In infering NS_ENUM/NS_OPTIONS
macros, prefer the typedef immediately following the
enum declaration to the one preceeding it.
// rdar://15200915
Modified:
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
cfe/trunk/test/ARCMT/objcmt-ns-macros.m
cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result
Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=192927&r1=192926&r2=192927&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Thu Oct 17 17:23:32 2013
@@ -745,6 +745,7 @@ bool ObjCMigrateASTConsumer::migrateNSEn
edit::Commit commit(*Editor);
rewriteToNSMacroDecl(EnumDcl, TypedefDcl, *NSAPIObj, commit, !NSOptions);
Editor->commit(commit);
+ return true;
}
}
return false;
@@ -1530,6 +1531,15 @@ void ObjCMigrateASTConsumer::HandleTrans
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;
Modified: cfe/trunk/test/ARCMT/objcmt-ns-macros.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-ns-macros.m?rev=192927&r1=192926&r2=192927&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-ns-macros.m (original)
+++ cfe/trunk/test/ARCMT/objcmt-ns-macros.m Thu Oct 17 17:23:32 2013
@@ -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
};
Modified: cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result?rev=192927&r1=192926&r2=192927&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result Thu Oct 17 17:23:32 2013
@@ -207,12 +207,13 @@ typedef NS_ENUM(NSInteger, NSModalRespon
} 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, NSWorkspa
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
More information about the cfe-commits
mailing list