diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ARCMigrate/ARCMTActions.cpp | 58 | ||||
-rw-r--r-- | lib/ARCMigrate/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lib/Frontend/CMakeLists.txt | 1 | ||||
-rw-r--r-- | lib/Frontend/CompilerInstance.cpp | 29 | ||||
-rw-r--r-- | lib/Frontend/FrontendAction.cpp | 38 | ||||
-rw-r--r-- | lib/FrontendTool/CMakeLists.txt | 3 | ||||
-rw-r--r-- | lib/FrontendTool/ExecuteCompilerInvocation.cpp | 16 |
7 files changed, 115 insertions, 31 deletions
diff --git a/lib/ARCMigrate/ARCMTActions.cpp b/lib/ARCMigrate/ARCMTActions.cpp new file mode 100644 index 0000000000..a30c2783e3 --- /dev/null +++ b/lib/ARCMigrate/ARCMTActions.cpp @@ -0,0 +1,58 @@ +//===--- ARCMTActions.cpp - ARC Migrate Tool Frontend Actions ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "clang/ARCMigrate/ARCMTActions.h" +#include "clang/ARCMigrate/ARCMT.h" +#include "clang/Frontend/CompilerInstance.h" + +using namespace clang; +using namespace arcmt; + +void CheckAction::ExecuteAction() { + CompilerInstance &CI = getCompilerInstance(); + if (arcmt::checkForManualIssues(CI.getInvocation(), getCurrentFile(), + getCurrentFileKind(), + CI.getDiagnostics().getClient())) + return; + + // We only want to see warnings reported from arcmt::checkForManualIssues. + CI.getDiagnostics().setIgnoreAllWarnings(true); + WrapperFrontendAction::ExecuteAction(); +} + +CheckAction::CheckAction(FrontendAction *WrappedAction) + : WrapperFrontendAction(WrappedAction) {} + +void TransformationAction::ExecuteAction() { + CompilerInstance &CI = getCompilerInstance(); + if (arcmt::applyTransformations(CI.getInvocation(), getCurrentFile(), + getCurrentFileKind(), + CI.getDiagnostics().getClient())) + return; + + WrapperFrontendAction::ExecuteAction(); +} + +TransformationAction::TransformationAction(FrontendAction *WrappedAction) + : WrapperFrontendAction(WrappedAction) {} + +void InMemoryTransformationAction::ExecuteAction() { + CompilerInstance &CI = getCompilerInstance(); + if (arcmt::applyTransformationsInMemory(CI.getInvocation(), getCurrentFile(), + getCurrentFileKind(), + CI.getDiagnostics().getClient())) + return; + + WrapperFrontendAction::ExecuteAction(); +} + +InMemoryTransformationAction::InMemoryTransformationAction( + FrontendAction *WrappedAction) + : WrapperFrontendAction(WrappedAction) {} + diff --git a/lib/ARCMigrate/CMakeLists.txt b/lib/ARCMigrate/CMakeLists.txt index 3645a22356..0049d2ff37 100644 --- a/lib/ARCMigrate/CMakeLists.txt +++ b/lib/ARCMigrate/CMakeLists.txt @@ -2,6 +2,7 @@ set(LLVM_USED_LIBS clangBasic clangAST clangParse clangFrontend clangRewrite) add_clang_library(clangARCMigrate ARCMT.cpp + ARCMTActions.cpp FileRemapper.cpp TransformActions.cpp Transforms.cpp diff --git a/lib/Frontend/CMakeLists.txt b/lib/Frontend/CMakeLists.txt index 5565b7b4a8..7dcbebff39 100644 --- a/lib/Frontend/CMakeLists.txt +++ b/lib/Frontend/CMakeLists.txt @@ -1,5 +1,4 @@ set( LLVM_USED_LIBS - clangARCMigrate clangAST clangBasic clangDriver diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index b05c24a985..38fcfe3c47 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -26,7 +26,6 @@ #include "clang/Frontend/TextDiagnosticPrinter.h" #include "clang/Frontend/VerifyDiagnosticsClient.h" #include "clang/Frontend/Utils.h" -#include "clang/ARCMigrate/ARCMT.h" #include "clang/Serialization/ASTReader.h" #include "clang/Sema/CodeCompleteConsumer.h" #include "llvm/Support/FileSystem.h" @@ -597,34 +596,6 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) { if (hasSourceManager()) getSourceManager().clearIDTables(); - switch (getFrontendOpts().ARCMTAction) { - default: - break; - - case FrontendOptions::ARCMT_Check: - if (arcmt::checkForManualIssues(getInvocation(), InFile, - getFrontendOpts().Inputs[i].first, - getDiagnostics().getClient())) - continue; - // We only want to see warnings reported from arcmt::checkForManualIssues. - getDiagnostics().setIgnoreAllWarnings(true); - break; - - case FrontendOptions::ARCMT_Modify: - if (arcmt::applyTransformations(getInvocation(), InFile, - getFrontendOpts().Inputs[i].first, - getDiagnostics().getClient())) - continue; - break; - - case FrontendOptions::ARCMT_ModifyInMemory: - if (arcmt::applyTransformationsInMemory(getInvocation(), InFile, - getFrontendOpts().Inputs[i].first, - getDiagnostics().getClient())) - continue; - break; - } - if (Act.BeginSourceFile(*this, InFile, getFrontendOpts().Inputs[i].first)) { Act.Execute(); Act.EndSourceFile(); diff --git a/lib/Frontend/FrontendAction.cpp b/lib/Frontend/FrontendAction.cpp index 42da44c2c7..0024818ad8 100644 --- a/lib/Frontend/FrontendAction.cpp +++ b/lib/Frontend/FrontendAction.cpp @@ -381,3 +381,41 @@ PreprocessorFrontendAction::CreateASTConsumer(CompilerInstance &CI, llvm::StringRef InFile) { llvm_unreachable("Invalid CreateASTConsumer on preprocessor action!"); } + +ASTConsumer *WrapperFrontendAction::CreateASTConsumer(CompilerInstance &CI, + llvm::StringRef InFile) { + return WrappedAction->CreateASTConsumer(CI, InFile); +} +bool WrapperFrontendAction::BeginSourceFileAction(CompilerInstance &CI, + llvm::StringRef Filename) { + return WrappedAction->BeginSourceFileAction(CI, Filename); +} +void WrapperFrontendAction::ExecuteAction() { + WrappedAction->ExecuteAction(); +} +void WrapperFrontendAction::EndSourceFileAction() { + WrappedAction->EndSourceFileAction(); +} + +bool WrapperFrontendAction::usesPreprocessorOnly() const { + return WrappedAction->usesPreprocessorOnly(); +} +bool WrapperFrontendAction::usesCompleteTranslationUnit() { + return WrappedAction->usesCompleteTranslationUnit(); +} +bool WrapperFrontendAction::hasPCHSupport() const { + return WrappedAction->hasPCHSupport(); +} +bool WrapperFrontendAction::hasASTFileSupport() const { + return WrappedAction->hasASTFileSupport(); +} +bool WrapperFrontendAction::hasIRSupport() const { + return WrappedAction->hasIRSupport(); +} +bool WrapperFrontendAction::hasCodeCompletionSupport() const { + return WrappedAction->hasCodeCompletionSupport(); +} + +WrapperFrontendAction::WrapperFrontendAction(FrontendAction *WrappedAction) + : WrappedAction(WrappedAction) {} + diff --git a/lib/FrontendTool/CMakeLists.txt b/lib/FrontendTool/CMakeLists.txt index 720ce2adf1..b8e4329c07 100644 --- a/lib/FrontendTool/CMakeLists.txt +++ b/lib/FrontendTool/CMakeLists.txt @@ -1,5 +1,6 @@ set(LLVM_USED_LIBS clangDriver clangFrontend clangRewrite clangCodeGen - clangStaticAnalyzerFrontend clangStaticAnalyzerCheckers clangStaticAnalyzerCore) + clangStaticAnalyzerFrontend clangStaticAnalyzerCheckers clangStaticAnalyzerCore + clangARCMigrate) add_clang_library(clangFrontendTool ExecuteCompilerInvocation.cpp diff --git a/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/lib/FrontendTool/ExecuteCompilerInvocation.cpp index 664b53351d..7ad263e14b 100644 --- a/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -14,6 +14,7 @@ #include "clang/FrontendTool/Utils.h" #include "clang/StaticAnalyzer/Frontend/FrontendActions.h" +#include "clang/ARCMigrate/ARCMTActions.h" #include "clang/CodeGen/CodeGenAction.h" #include "clang/Driver/CC1Options.h" #include "clang/Driver/OptTable.h" @@ -89,6 +90,21 @@ static FrontendAction *CreateFrontendAction(CompilerInstance &CI) { if (!Act) return 0; + // Potentially wrap the base FE action in an ARC Migrate Tool action. + switch (CI.getFrontendOpts().ARCMTAction) { + case FrontendOptions::ARCMT_None: + break; + case FrontendOptions::ARCMT_Check: + Act = new arcmt::CheckAction(Act); + break; + case FrontendOptions::ARCMT_Modify: + Act = new arcmt::TransformationAction(Act); + break; + case FrontendOptions::ARCMT_ModifyInMemory: + Act = new arcmt::InMemoryTransformationAction(Act); + break; + } + // If there are any AST files to merge, create a frontend action // adaptor to perform the merge. if (!CI.getFrontendOpts().ASTMergeFiles.empty()) |