diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2013-10-02 17:08:12 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2013-10-02 17:08:12 +0000 |
commit | 74fd551c0ba344d62aedc8636ed81b45652f04d8 (patch) | |
tree | 36dea03ae47726922ce56ba156f5c33156d9313e /lib | |
parent | 9a3be4cfdf7858b2467f57448ab99f72a2926b35 (diff) | |
download | clang-74fd551c0ba344d62aedc8636ed81b45652f04d8.tar.gz |
Objective-C migrator. Simplify migrator option
processing in preparation for adding several more
options. // rdar://15003157
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191842 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ARCMigrate/ObjCMT.cpp | 44 | ||||
-rw-r--r-- | lib/FrontendTool/ExecuteCompilerInvocation.cpp | 5 |
2 files changed, 13 insertions, 36 deletions
diff --git a/lib/ARCMigrate/ObjCMT.cpp b/lib/ARCMigrate/ObjCMT.cpp index d84cbbcffc..54e5662fae 100644 --- a/lib/ARCMigrate/ObjCMT.cpp +++ b/lib/ARCMigrate/ObjCMT.cpp @@ -75,10 +75,7 @@ class ObjCMigrateASTConsumer : public ASTConsumer { const ObjCMethodDecl *MethodDecl); public: std::string MigrateDir; - bool MigrateLiterals; - bool MigrateSubscripting; - bool MigrateProperty; - bool MigrateReadonlyProperty; + unsigned ASTMigrateActions; unsigned FileId; OwningPtr<NSAPI> NSAPIObj; OwningPtr<edit::EditedSource> Editor; @@ -91,20 +88,14 @@ public: llvm::SmallVector<const Decl *, 8> CFFunctionIBCandidates; ObjCMigrateASTConsumer(StringRef migrateDir, - bool migrateLiterals, - bool migrateSubscripting, - bool migrateProperty, - bool migrateReadonlyProperty, + unsigned astMigrateActions, FileRemapper &remapper, FileManager &fileMgr, const PPConditionalDirectiveRecord *PPRec, Preprocessor &PP, bool isOutputFile = false) : MigrateDir(migrateDir), - MigrateLiterals(migrateLiterals), - MigrateSubscripting(migrateSubscripting), - MigrateProperty(migrateProperty), - MigrateReadonlyProperty(migrateReadonlyProperty), + ASTMigrateActions(astMigrateActions), FileId(0), Remapper(remapper), FileMgr(fileMgr), PPRec(PPRec), PP(PP), IsOutputFile(isOutputFile) { } @@ -134,15 +125,10 @@ protected: } ObjCMigrateAction::ObjCMigrateAction(FrontendAction *WrappedAction, - StringRef migrateDir, - bool migrateLiterals, - bool migrateSubscripting, - bool migrateProperty, - bool migrateReadonlyProperty) + StringRef migrateDir, + unsigned migrateAction) : WrapperFrontendAction(WrappedAction), MigrateDir(migrateDir), - MigrateLiterals(migrateLiterals), MigrateSubscripting(migrateSubscripting), - MigrateProperty(migrateProperty), - MigrateReadonlyProperty(migrateReadonlyProperty), + ObjCMigAction(migrateAction), CompInst(0) { if (MigrateDir.empty()) MigrateDir = "."; // user current directory if none is given. @@ -156,10 +142,7 @@ ASTConsumer *ObjCMigrateAction::CreateASTConsumer(CompilerInstance &CI, ASTConsumer * WrappedConsumer = WrapperFrontendAction::CreateASTConsumer(CI, InFile); ASTConsumer *MTConsumer = new ObjCMigrateASTConsumer(MigrateDir, - MigrateLiterals, - MigrateSubscripting, - MigrateProperty, - MigrateReadonlyProperty, + ObjCMigAction, Remapper, CompInst->getFileManager(), PPRec, @@ -189,13 +172,13 @@ public: bool shouldWalkTypesOfTypeLocs() const { return false; } bool VisitObjCMessageExpr(ObjCMessageExpr *E) { - if (Consumer.MigrateLiterals) { + if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_Literals) { edit::Commit commit(*Consumer.Editor); edit::rewriteToObjCLiteralSyntax(E, *Consumer.NSAPIObj, commit, &PMap); Consumer.Editor->commit(commit); } - if (Consumer.MigrateSubscripting) { + if (Consumer.ASTMigrateActions & FrontendOptions::ObjCMT_Subscripting) { edit::Commit commit(*Consumer.Editor); edit::rewriteToObjCSubscriptSyntax(E, *Consumer.NSAPIObj, commit); Consumer.Editor->commit(commit); @@ -841,7 +824,7 @@ bool ObjCMigrateASTConsumer::migrateProperty(ASTContext &Ctx, Editor->commit(commit); return true; } - else if (MigrateReadonlyProperty) { + else if (ASTMigrateActions & FrontendOptions::ObjCMT_ReadonlyProperty) { // Try a non-void method with no argument (and no setter or property of same name // as a 'readonly' property. edit::Commit commit(*Editor); @@ -1341,7 +1324,7 @@ IsReallyASystemHeader(ASTContext &Ctx, const FileEntry *file, FileID FID) { void ObjCMigrateASTConsumer::HandleTranslationUnit(ASTContext &Ctx) { TranslationUnitDecl *TU = Ctx.getTranslationUnitDecl(); - if (MigrateProperty) { + if (ASTMigrateActions & FrontendOptions::ObjCMT_Property) { for (DeclContext::decl_iterator D = TU->decls_begin(), DEnd = TU->decls_end(); D != DEnd; ++D) { if (unsigned FID = @@ -1419,10 +1402,7 @@ ASTConsumer *MigrateSourceAction::CreateASTConsumer(CompilerInstance &CI, PPRec = new PPConditionalDirectiveRecord(CI.getSourceManager()); CI.getPreprocessor().addPPCallbacks(PPRec); return new ObjCMigrateASTConsumer(CI.getFrontendOpts().OutputFile, - /*MigrateLiterals=*/true, - /*MigrateSubscripting=*/true, - /*MigrateProperty*/true, - /*MigrateReadonlyProperty*/true, + FrontendOptions::ObjCMT_All, Remapper, CI.getFileManager(), PPRec, diff --git a/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/lib/FrontendTool/ExecuteCompilerInvocation.cpp index 7ba7103c76..acda316932 100644 --- a/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -162,10 +162,7 @@ static FrontendAction *CreateFrontendAction(CompilerInstance &CI) { if (FEOpts.ObjCMTAction != FrontendOptions::ObjCMT_None) { Act = new arcmt::ObjCMigrateAction(Act, FEOpts.MTMigrateDir, - FEOpts.ObjCMTAction & FrontendOptions::ObjCMT_Literals, - FEOpts.ObjCMTAction & FrontendOptions::ObjCMT_Subscripting, - FEOpts.ObjCMTAction & FrontendOptions::ObjCMT_Property, - FEOpts.ObjCMTAction & FrontendOptions::ObjCMT_ReadonlyProperty); + FEOpts.ObjCMTAction); } #endif |