diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/contrib/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/contrib/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp index b95851e380d2..7476b1076d10 100644 --- a/contrib/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/contrib/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -15,6 +15,7 @@ #include "clang/CodeGen/CodeGenAction.h" #include "clang/Config/config.h" #include "clang/Driver/Options.h" +#include "clang/ExtractAPI/FrontendActions.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Frontend/CompilerInvocation.h" #include "clang/Frontend/FrontendActions.h" @@ -52,18 +53,24 @@ CreateFrontendBaseAction(CompilerInstance &CI) { case DumpTokens: return std::make_unique<DumpTokensAction>(); case EmitAssembly: return std::make_unique<EmitAssemblyAction>(); case EmitBC: return std::make_unique<EmitBCAction>(); + case EmitCIR: + llvm_unreachable("CIR suppport not built into clang"); case EmitHTML: return std::make_unique<HTMLPrintAction>(); case EmitLLVM: return std::make_unique<EmitLLVMAction>(); case EmitLLVMOnly: return std::make_unique<EmitLLVMOnlyAction>(); case EmitCodeGenOnly: return std::make_unique<EmitCodeGenOnlyAction>(); case EmitObj: return std::make_unique<EmitObjAction>(); + case ExtractAPI: + return std::make_unique<ExtractAPIAction>(); case FixIt: return std::make_unique<FixItAction>(); case GenerateModule: return std::make_unique<GenerateModuleFromModuleMapAction>(); case GenerateModuleInterface: return std::make_unique<GenerateModuleInterfaceAction>(); - case GenerateHeaderModule: - return std::make_unique<GenerateHeaderModuleAction>(); + case GenerateReducedModuleInterface: + return std::make_unique<GenerateReducedModuleInterfaceAction>(); + case GenerateHeaderUnit: + return std::make_unique<GenerateHeaderUnitAction>(); case GeneratePCH: return std::make_unique<GeneratePCHAction>(); case GenerateInterfaceStubs: return std::make_unique<GenerateInterfaceStubsAction>(); @@ -79,7 +86,7 @@ CreateFrontendBaseAction(CompilerInstance &CI) { if (Plugin.getName() == CI.getFrontendOpts().ActionName) { std::unique_ptr<PluginASTAction> P(Plugin.instantiate()); if ((P->getActionType() != PluginASTAction::ReplaceAction && - P->getActionType() != PluginASTAction::Cmdline) || + P->getActionType() != PluginASTAction::CmdlineAfterMainAction) || !P->ParseArgs( CI, CI.getFrontendOpts().PluginArgs[std::string(Plugin.getName())])) @@ -175,6 +182,18 @@ CreateFrontendAction(CompilerInstance &CI) { } #endif + // Wrap the base FE action in an extract api action to generate + // symbol graph as a biproduct of compilation (enabled with + // --emit-symbol-graph option) + if (FEOpts.EmitSymbolGraph) { + if (FEOpts.SymbolGraphOutputDir.empty()) { + CI.getDiagnostics().Report(diag::warn_missing_symbol_graph_dir); + CI.getFrontendOpts().SymbolGraphOutputDir = "."; + } + CI.getCodeGenOpts().ClearASTBeforeBackend = false; + Act = std::make_unique<WrappingExtractAPIAction>(std::move(Act)); + } + // If there are any AST files to merge, create a frontend action // adaptor to perform the merge. if (!FEOpts.ASTMergeFiles.empty()) @@ -190,8 +209,8 @@ bool ExecuteCompilerInvocation(CompilerInstance *Clang) { driver::getDriverOptTable().printHelp( llvm::outs(), "clang -cc1 [options] file...", "LLVM 'Clang' Compiler: http://clang.llvm.org", - /*Include=*/driver::options::CC1Option, - /*Exclude=*/0, /*ShowAllAliases=*/false); + /*ShowHidden=*/false, /*ShowAllAliases=*/false, + llvm::opt::Visibility(driver::options::CC1Option)); return true; } @@ -203,24 +222,7 @@ bool ExecuteCompilerInvocation(CompilerInstance *Clang) { return true; } - // Load any requested plugins. - for (const std::string &Path : Clang->getFrontendOpts().Plugins) { - std::string Error; - if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &Error)) - Clang->getDiagnostics().Report(diag::err_fe_unable_to_load_plugin) - << Path << Error; - } - - // Check if any of the loaded plugins replaces the main AST action - for (const FrontendPluginRegistry::entry &Plugin : - FrontendPluginRegistry::entries()) { - std::unique_ptr<PluginASTAction> P(Plugin.instantiate()); - if (P->getActionType() == PluginASTAction::ReplaceAction) { - Clang->getFrontendOpts().ProgramAction = clang::frontend::PluginAction; - Clang->getFrontendOpts().ActionName = Plugin.getName().str(); - break; - } - } + Clang->LoadRequestedPlugins(); // Honor -mllvm. // @@ -239,7 +241,7 @@ bool ExecuteCompilerInvocation(CompilerInstance *Clang) { #if CLANG_ENABLE_STATIC_ANALYZER // These should happen AFTER plugins have been loaded! - AnalyzerOptions &AnOpts = *Clang->getAnalyzerOpts(); + AnalyzerOptions &AnOpts = Clang->getAnalyzerOpts(); // Honor -analyzer-checker-help and -analyzer-checker-help-hidden. if (AnOpts.ShowCheckerHelp || AnOpts.ShowCheckerHelpAlpha || |