r192933 - ObjectiveC migrator. Minor clean up of my last patch.
Fariborz Jahanian
fjahanian at apple.com
Thu Oct 17 16:13:13 PDT 2013
Author: fjahanian
Date: Thu Oct 17 18:13:13 2013
New Revision: 192933
URL: http://llvm.org/viewvc/llvm-project?rev=192933&view=rev
Log:
ObjectiveC migrator. Minor clean up of my last patch.
No functional change.
Modified:
cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=192933&r1=192932&r2=192933&view=diff
==============================================================================
--- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
+++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Thu Oct 17 18:13:13 2013
@@ -575,7 +575,7 @@ static bool rewriteToNSEnumDecl(const En
return false;
}
-static bool rewriteToNSMacroDecl(const EnumDecl *EnumDcl,
+static void rewriteToNSMacroDecl(const EnumDecl *EnumDcl,
const TypedefDecl *TypedefDcl,
const NSAPI &NS, edit::Commit &commit,
bool IsNSIntegerType) {
@@ -587,7 +587,6 @@ static bool rewriteToNSMacroDecl(const E
commit.replace(R, ClassString);
SourceLocation TypedefLoc = TypedefDcl->getLocEnd();
commit.remove(SourceRange(TypedefLoc, TypedefLoc));
- return true;
}
static bool UseNSOptionsMacro(Preprocessor &PP, ASTContext &Ctx,
@@ -1527,26 +1526,27 @@ void ObjCMigrateASTConsumer::HandleTrans
migrateNSEnumDecl(Ctx, ED, /*TypedefDecl */0);
}
else if (const TypedefDecl *TD = dyn_cast<TypedefDecl>(*D)) {
- if (ASTMigrateActions & FrontendOptions::ObjCMT_NsMacros) {
- DeclContext::decl_iterator N = D;
+ if (!(ASTMigrateActions & FrontendOptions::ObjCMT_NsMacros))
+ continue;
+ DeclContext::decl_iterator N = D;
+ if (++N == DEnd)
+ continue;
+ if (const EnumDecl *ED = dyn_cast<EnumDecl>(*N)) {
if (++N != DEnd)
- if (const EnumDecl *ED = dyn_cast<EnumDecl>(*N)) {
- if (++N != DEnd) {
- if (const TypedefDecl *TD1 = dyn_cast<TypedefDecl>(*N)) {
- if (migrateNSEnumDecl(Ctx, ED, TD1)) {
- ++D; ++D;
- CacheObjCNSIntegerTypedefed(TD);
- continue;
- }
- }
- }
- if (migrateNSEnumDecl(Ctx, ED, TD)) {
- ++D;
+ if (const TypedefDecl *TDF = dyn_cast<TypedefDecl>(*N)) {
+ // prefer typedef-follows-enum to enum-follows-typedef pattern.
+ if (migrateNSEnumDecl(Ctx, ED, TDF)) {
+ ++D; ++D;
+ CacheObjCNSIntegerTypedefed(TD);
continue;
}
}
- CacheObjCNSIntegerTypedefed(TD);
+ if (migrateNSEnumDecl(Ctx, ED, TD)) {
+ ++D;
+ continue;
+ }
}
+ CacheObjCNSIntegerTypedefed(TD);
}
else if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(*D)) {
if (ASTMigrateActions & FrontendOptions::ObjCMT_Annotation)
More information about the cfe-commits
mailing list