r192506 - ObjectiveC migrator. also support migration to
Fariborz Jahanian
fjahanian at apple.com
Fri Oct 11 14:34:57 PDT 2013
Author: fjahanian
Date: Fri Oct 11 16:34:56 2013
New Revision: 192506
URL: http://llvm.org/viewvc/llvm-project?rev=192506&view=rev
Log:
ObjectiveC migrator. also support migration to
NS_ENUM/NS_OPTIONS macros when typedef declaration
precedes enum declaration. // 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=192506&r1=192505&r2=192506&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Fri Oct 11 16:34:56 2013
@@ -46,7 +46,7 @@ class ObjCMigrateASTConsumer : public AS
void migrateObjCInterfaceDecl(ASTContext &Ctx, ObjCContainerDecl *D);
void migrateProtocolConformance(ASTContext &Ctx,
const ObjCImplementationDecl *ImpDecl);
- void migrateNSEnumDecl(ASTContext &Ctx, const EnumDecl *EnumDcl,
+ bool migrateNSEnumDecl(ASTContext &Ctx, const EnumDecl *EnumDcl,
const TypedefDecl *TypedefDcl);
void migrateAllMethodInstaceType(ASTContext &Ctx, ObjCContainerDecl *CDecl);
void migrateMethodInstanceType(ASTContext &Ctx, ObjCContainerDecl *CDecl,
@@ -638,13 +638,13 @@ void ObjCMigrateASTConsumer::migrateProt
Editor->commit(commit);
}
-void ObjCMigrateASTConsumer::migrateNSEnumDecl(ASTContext &Ctx,
+bool ObjCMigrateASTConsumer::migrateNSEnumDecl(ASTContext &Ctx,
const EnumDecl *EnumDcl,
const TypedefDecl *TypedefDcl) {
if (!EnumDcl->isCompleteDefinition() || EnumDcl->getIdentifier() ||
!TypedefDcl->getIdentifier() ||
EnumDcl->isDeprecated() || TypedefDcl->isDeprecated())
- return;
+ return false;
QualType qt = TypedefDcl->getTypeSourceInfo()->getType();
bool IsNSIntegerType = NSAPIObj->isObjCNSIntegerType(qt);
@@ -657,29 +657,30 @@ void ObjCMigrateASTConsumer::migrateNSEn
bool NSOptions = UseNSOptionsMacro(PP, Ctx, EnumDcl);
if (NSOptions) {
if (!Ctx.Idents.get("NS_OPTIONS").hasMacroDefinition())
- return;
+ return false;
}
else if (!Ctx.Idents.get("NS_ENUM").hasMacroDefinition())
- return;
+ return false;
edit::Commit commit(*Editor);
rewriteToNSMacroDecl(EnumDcl, TypedefDcl, *NSAPIObj, commit, !NSOptions);
Editor->commit(commit);
}
}
- return;
+ return false;
}
// We may still use NS_OPTIONS based on what we find in the enumertor list.
bool NSOptions = UseNSOptionsMacro(PP, Ctx, EnumDcl);
// NS_ENUM must be available.
if (IsNSIntegerType && !Ctx.Idents.get("NS_ENUM").hasMacroDefinition())
- return;
+ return false;
// NS_OPTIONS must be available.
if (IsNSUIntegerType && !Ctx.Idents.get("NS_OPTIONS").hasMacroDefinition())
- return;
+ return false;
edit::Commit commit(*Editor);
rewriteToNSEnumDecl(EnumDcl, TypedefDcl, *NSAPIObj, commit, IsNSIntegerType, NSOptions);
Editor->commit(commit);
+ return true;
}
static void ReplaceWithInstancetype(const ObjCMigrateASTConsumer &ASTC,
@@ -1435,8 +1436,21 @@ void ObjCMigrateASTConsumer::HandleTrans
++N;
if (N != DEnd)
if (const TypedefDecl *TD = dyn_cast<TypedefDecl>(*N)) {
- if (ASTMigrateActions & FrontendOptions::ObjCMT_NsMacros)
- migrateNSEnumDecl(Ctx, ED, TD);
+ if (ASTMigrateActions & FrontendOptions::ObjCMT_NsMacros) {
+ if (migrateNSEnumDecl(Ctx, ED, TD))
+ D++;
+ }
+ }
+ }
+ else if (const TypedefDecl *TD = dyn_cast<TypedefDecl>(*D)) {
+ DeclContext::decl_iterator N = D;
+ ++N;
+ if (N != DEnd)
+ if (const EnumDecl *ED = dyn_cast<EnumDecl>(*N)) {
+ if (ASTMigrateActions & FrontendOptions::ObjCMT_NsMacros) {
+ if (migrateNSEnumDecl(Ctx, ED, TD))
+ ++D;
+ }
}
}
else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*D)) {
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=192506&r1=192505&r2=192506&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-ns-macros.m (original)
+++ cfe/trunk/test/ARCMT/objcmt-ns-macros.m Fri Oct 11 16:34:56 2013
@@ -215,3 +215,39 @@ enum {
NSModalResponseContinue = (-1002),
} NS_ENUM_AVAILABLE_MAC(10.9);
typedef NSInteger NSModalResponse NS_AVAILABLE_MAC(10.9);
+
+// rdar://15200915
+typedef NSUInteger NSWorkspaceLaunchOptions;
+enum {
+ NSWorkspaceLaunchAndPrint = 0x00000002,
+ NSWorkspaceLaunchWithErrorPresentation = 0x00000040,
+ NSWorkspaceLaunchInhibitingBackgroundOnly = 0x00000080,
+ NSWorkspaceLaunchWithoutAddingToRecents = 0x00000100,
+ NSWorkspaceLaunchWithoutActivation = 0x00000200,
+ NSWorkspaceLaunchAsync = 0x00010000,
+ NSWorkspaceLaunchAllowingClassicStartup = 0x00020000,
+ NSWorkspaceLaunchPreferringClassic = 0x00040000,
+ NSWorkspaceLaunchNewInstance = 0x00080000,
+ NSWorkspaceLaunchAndHide = 0x00100000,
+ NSWorkspaceLaunchAndHideOthers = 0x00200000,
+ NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync |
+NSWorkspaceLaunchAllowingClassicStartup
+};
+
+typedef NSUInteger NSWorkspaceIconCreationOptions;
+enum {
+ NSExcludeQuickDrawElementsIconCreationOption = 1 << 1,
+ NSExclude10_4ElementsIconCreationOption = 1 << 2
+};
+
+typedef NSUInteger NSWorkspaceCreationOptions;
+enum {
+ NSExcludeQuickDrawElementsCreationOption = 1 << 1,
+ NSExclude10_4ElementsCreationOption = 1 << 2
+};
+
+enum {
+ NSExcludeQuickDrawElementsIconOption = 1 << 1,
+ NSExclude10_4ElementsIconOption = 1 << 2
+};
+typedef NSUInteger NSWorkspaceIconOptions;
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=192506&r1=192505&r2=192506&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result (original)
+++ cfe/trunk/test/ARCMT/objcmt-ns-macros.m.result Fri Oct 11 16:34:56 2013
@@ -205,3 +205,35 @@ typedef NS_ENUM(NSInteger, NSModalRespon
NSModalResponseAbort = (-1001),
NSModalResponseContinue = (-1002),
} NS_ENUM_AVAILABLE_MAC(10.9);
+
+// rdar://15200915
+typedef NS_OPTIONS(NSUInteger, NSWorkspaceLaunchOptions) {
+ NSWorkspaceLaunchAndPrint = 0x00000002,
+ NSWorkspaceLaunchWithErrorPresentation = 0x00000040,
+ NSWorkspaceLaunchInhibitingBackgroundOnly = 0x00000080,
+ NSWorkspaceLaunchWithoutAddingToRecents = 0x00000100,
+ NSWorkspaceLaunchWithoutActivation = 0x00000200,
+ NSWorkspaceLaunchAsync = 0x00010000,
+ NSWorkspaceLaunchAllowingClassicStartup = 0x00020000,
+ NSWorkspaceLaunchPreferringClassic = 0x00040000,
+ NSWorkspaceLaunchNewInstance = 0x00080000,
+ NSWorkspaceLaunchAndHide = 0x00100000,
+ NSWorkspaceLaunchAndHideOthers = 0x00200000,
+ NSWorkspaceLaunchDefault = NSWorkspaceLaunchAsync |
+NSWorkspaceLaunchAllowingClassicStartup
+};
+
+typedef NS_OPTIONS(NSUInteger, NSWorkspaceIconCreationOptions) {
+ NSExcludeQuickDrawElementsIconCreationOption = 1 << 1,
+ NSExclude10_4ElementsIconCreationOption = 1 << 2
+};
+
+typedef NS_OPTIONS(NSUInteger, NSWorkspaceCreationOptions) {
+ NSExcludeQuickDrawElementsCreationOption = 1 << 1,
+ NSExclude10_4ElementsCreationOption = 1 << 2
+};
+
+typedef NS_OPTIONS(NSUInteger, NSWorkspaceIconOptions) {
+ NSExcludeQuickDrawElementsIconOption = 1 << 1,
+ NSExclude10_4ElementsIconOption = 1 << 2
+};
More information about the cfe-commits
mailing list