summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/ARCMigrate/ObjCMT.cpp22
-rw-r--r--clang/test/ARCMT/objcmt-ns-macros.m18
-rw-r--r--clang/test/ARCMT/objcmt-ns-macros.m.result20
3 files changed, 50 insertions, 10 deletions
diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp
index 0aca657ffdb..f5754f87cd2 100644
--- a/clang/lib/ARCMigrate/ObjCMT.cpp
+++ b/clang/lib/ARCMigrate/ObjCMT.cpp
@@ -497,9 +497,16 @@ static bool rewriteToObjCInterfaceDecl(const ObjCInterfaceDecl *IDecl,
static bool rewriteToNSEnumDecl(const EnumDecl *EnumDcl,
const TypedefDecl *TypedefDcl,
const NSAPI &NS, edit::Commit &commit,
- bool IsNSIntegerType) {
- std::string ClassString =
- IsNSIntegerType ? "typedef NS_ENUM(NSInteger, " : "typedef NS_OPTIONS(NSUInteger, ";
+ bool IsNSIntegerType,
+ bool NSOptions) {
+ std::string ClassString;
+ if (NSOptions)
+ ClassString = "typedef NS_OPTIONS(NSUInteger, ";
+ else
+ ClassString =
+ IsNSIntegerType ? "typedef NS_ENUM(NSInteger, "
+ : "typedef NS_ENUM(NSUInteger, ";
+
ClassString += TypedefDcl->getIdentifier()->getName();
ClassString += ')';
SourceRange R(EnumDcl->getLocStart(), EnumDcl->getLocStart());
@@ -653,12 +660,9 @@ void ObjCMigrateASTConsumer::migrateNSEnumDecl(ASTContext &Ctx,
}
return;
}
- if (IsNSIntegerType && UseNSOptionsMacro(PP, Ctx, EnumDcl)) {
- // We may still use NS_OPTIONS based on what we find in the enumertor list.
- IsNSIntegerType = false;
- IsNSUIntegerType = true;
- }
+ // 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;
@@ -666,7 +670,7 @@ void ObjCMigrateASTConsumer::migrateNSEnumDecl(ASTContext &Ctx,
if (IsNSUIntegerType && !Ctx.Idents.get("NS_OPTIONS").hasMacroDefinition())
return;
edit::Commit commit(*Editor);
- rewriteToNSEnumDecl(EnumDcl, TypedefDcl, *NSAPIObj, commit, IsNSIntegerType);
+ rewriteToNSEnumDecl(EnumDcl, TypedefDcl, *NSAPIObj, commit, IsNSIntegerType, NSOptions);
Editor->commit(commit);
}
diff --git a/clang/test/ARCMT/objcmt-ns-macros.m b/clang/test/ARCMT/objcmt-ns-macros.m
index 1ee675cd746..ec6e3d44c73 100644
--- a/clang/test/ARCMT/objcmt-ns-macros.m
+++ b/clang/test/ARCMT/objcmt-ns-macros.m
@@ -92,3 +92,21 @@ enum {
UIView1 = 0XBADBEEF
};
typedef NSInteger UIStyle;
+
+enum {
+ NSTIFFFileType,
+ NSBMPFileType,
+ NSGIFFileType,
+ NSJPEGFileType,
+ NSPNGFileType,
+ NSJPEG2000FileType
+};
+typedef NSUInteger NSBitmapImageFileType;
+
+enum {
+ NSWarningAlertStyle = 0,
+ NSInformationalAlertStyle = 1,
+ NSCriticalAlertStyle = 2
+};
+typedef NSUInteger NSAlertStyle;
+
diff --git a/clang/test/ARCMT/objcmt-ns-macros.m.result b/clang/test/ARCMT/objcmt-ns-macros.m.result
index cd0fc8789da..80c84bdfbea 100644
--- a/clang/test/ARCMT/objcmt-ns-macros.m.result
+++ b/clang/test/ARCMT/objcmt-ns-macros.m.result
@@ -15,7 +15,7 @@ typedef NS_ENUM(NSInteger, wibble) {
};
-typedef NS_OPTIONS(NSUInteger, UITableViewCellStyle) {
+typedef NS_ENUM(NSUInteger, UITableViewCellStyle) {
UIViewAutoresizingNone = 0,
UIViewAutoresizingFlexibleLeftMargin,
UIViewAutoresizingFlexibleWidth,
@@ -92,3 +92,21 @@ typedef NS_OPTIONS(NSUInteger, UIStyle) {
UIView1 = 0XBADBEEF
};
+
+typedef NS_ENUM(NSUInteger, NSBitmapImageFileType) {
+ NSTIFFFileType,
+ NSBMPFileType,
+ NSGIFFileType,
+ NSJPEGFileType,
+ NSPNGFileType,
+ NSJPEG2000FileType
+};
+
+
+typedef NS_ENUM(NSUInteger, NSAlertStyle) {
+ NSWarningAlertStyle = 0,
+ NSInformationalAlertStyle = 1,
+ NSCriticalAlertStyle = 2
+};
+
+
OpenPOWER on IntegriCloud