summaryrefslogtreecommitdiffstats
path: root/lib/ARCMigrate
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2015-01-26 17:41:03 +0000
committerFariborz Jahanian <fjahanian@apple.com>2015-01-26 17:41:03 +0000
commit138133f406699ca702ceb68dcd227025faa81979 (patch)
tree9fef34d4ca1512f9956502e72bbafd99ac44eab1 /lib/ARCMigrate
parentd6bdd305019999412410a53164dc2d1ee0732f27 (diff)
Objective-C SDK modernizer to use NS_ENUM/NS_OPTIONS macros
with typed enums. rdar://19352510 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@227104 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ARCMigrate')
-rw-r--r--lib/ARCMigrate/ObjCMT.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp
index 59feea11e1..cd1a2caab4 100644
--- a/lib/ARCMigrate/ObjCMT.cpp
+++ b/lib/ARCMigrate/ObjCMT.cpp
@@ -788,7 +788,22 @@ static void rewriteToNSMacroDecl(ASTContext &Ctx,
ClassString += TypedefDcl->getIdentifier()->getName();
ClassString += ')';
- SourceRange R(EnumDcl->getLocStart(), EnumDcl->getLocStart());
+ SourceLocation EndLoc;
+ if (EnumDcl->getIntegerTypeSourceInfo()) {
+ TypeSourceInfo *TSourceInfo = EnumDcl->getIntegerTypeSourceInfo();
+ TypeLoc TLoc = TSourceInfo->getTypeLoc();
+ EndLoc = TLoc.getLocEnd();
+ const char *lbrace = Ctx.getSourceManager().getCharacterData(EndLoc);
+ unsigned count = 0;
+ if (lbrace)
+ while (lbrace[count] != '{')
+ ++count;
+ if (count > 0)
+ EndLoc = EndLoc.getLocWithOffset(count-1);
+ }
+ else
+ EndLoc = EnumDcl->getLocStart();
+ SourceRange R(EnumDcl->getLocStart(), EndLoc);
commit.replace(R, ClassString);
// This is to remove spaces between '}' and typedef name.
SourceLocation StartTypedefLoc = EnumDcl->getLocEnd();
@@ -910,7 +925,7 @@ bool ObjCMigrateASTConsumer::migrateNSEnumDecl(ASTContext &Ctx,
const EnumDecl *EnumDcl,
const TypedefDecl *TypedefDcl) {
if (!EnumDcl->isCompleteDefinition() || EnumDcl->getIdentifier() ||
- EnumDcl->isDeprecated() || EnumDcl->getIntegerTypeSourceInfo())
+ EnumDcl->isDeprecated())
return false;
if (!TypedefDcl) {
if (NSIntegerTypedefed) {