diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp index cd4b284e7dfb..7b8aebbac5d6 100644 --- a/clang/lib/ARCMigrate/ObjCMT.cpp +++ b/clang/lib/ARCMigrate/ObjCMT.cpp @@ -46,7 +46,7 @@ class ObjCMigrateASTConsumer : public ASTConsumer { 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::migrateProtocolConformance(ASTContext &Ctx, 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::migrateNSEnumDecl(ASTContext &Ctx, 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::HandleTranslationUnit(ASTContext &Ctx) { ++N; if (N != DEnd) if (const TypedefDecl *TD = dyn_cast(*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(*D)) { + DeclContext::decl_iterator N = D; + ++N; + if (N != DEnd) + if (const EnumDecl *ED = dyn_cast(*N)) { + if (ASTMigrateActions & FrontendOptions::ObjCMT_NsMacros) { + if (migrateNSEnumDecl(Ctx, ED, TD)) + ++D; + } } } else if (const FunctionDecl *FD = dyn_cast(*D)) { diff --git a/clang/test/ARCMT/objcmt-ns-macros.m b/clang/test/ARCMT/objcmt-ns-macros.m index b83857de7d79..b8715716d6e4 100644 --- a/clang/test/ARCMT/objcmt-ns-macros.m +++ b/clang/test/ARCMT/objcmt-ns-macros.m @@ -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; diff --git a/clang/test/ARCMT/objcmt-ns-macros.m.result b/clang/test/ARCMT/objcmt-ns-macros.m.result index f8bbbefe6694..62f1cd7342c8 100644 --- a/clang/test/ARCMT/objcmt-ns-macros.m.result +++ b/clang/test/ARCMT/objcmt-ns-macros.m.result @@ -205,3 +205,35 @@ typedef NS_ENUM(NSInteger, NSModalResponse) { 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 +};