summaryrefslogtreecommitdiffstats
path: root/clang/lib/ARCMigrate/ObjCMT.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2013-08-30 17:46:01 +0000
committerFariborz Jahanian <fjahanian@apple.com>2013-08-30 17:46:01 +0000
commitff3476e4999948bd8f986c284d1eba6e2e118ba9 (patch)
treeafe8063aeae9ae0bf0818419835cc6f275da69ab /clang/lib/ARCMigrate/ObjCMT.cpp
parentf5b5f1f7f69e28cf9cda353d00ffa651eb10d891 (diff)
downloadbcm5719-llvm-ff3476e4999948bd8f986c284d1eba6e2e118ba9.tar.gz
bcm5719-llvm-ff3476e4999948bd8f986c284d1eba6e2e118ba9.zip
ObjectiveC migrator: infer NS_ENUM even when user
specified NSUInteger as the followup typedef. With this change, NS_OPTIONS is only inferred based on looking up how enumerators are speficied (if they her hexadecimal, power of 2, or have bitwise constant expressions). llvm-svn: 189682
Diffstat (limited to 'clang/lib/ARCMigrate/ObjCMT.cpp')
-rw-r--r--clang/lib/ARCMigrate/ObjCMT.cpp22
1 files changed, 13 insertions, 9 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);
}
OpenPOWER on IntegriCloud