16#include "clang/Config/config.h"
29#include "llvm/Option/OptTable.h"
30#include "llvm/Option/Option.h"
31#include "llvm/Support/BuryPointer.h"
32#include "llvm/Support/DynamicLibrary.h"
33#include "llvm/Support/ErrorHandling.h"
39static std::unique_ptr<FrontendAction>
42 StringRef Action(
"unknown");
46 case ASTDeclList:
return std::make_unique<ASTDeclListAction>();
47 case ASTDump:
return std::make_unique<ASTDumpAction>();
48 case ASTPrint:
return std::make_unique<ASTPrintAction>();
49 case ASTView:
return std::make_unique<ASTViewAction>();
50 case DumpCompilerOptions:
51 return std::make_unique<DumpCompilerOptionsAction>();
52 case DumpRawTokens:
return std::make_unique<DumpRawTokensAction>();
53 case DumpTokens:
return std::make_unique<DumpTokensAction>();
54 case EmitAssembly:
return std::make_unique<EmitAssemblyAction>();
55 case EmitBC:
return std::make_unique<EmitBCAction>();
57 llvm_unreachable(
"CIR suppport not built into clang");
58 case EmitHTML:
return std::make_unique<HTMLPrintAction>();
59 case EmitLLVM:
return std::make_unique<EmitLLVMAction>();
60 case EmitLLVMOnly:
return std::make_unique<EmitLLVMOnlyAction>();
61 case EmitCodeGenOnly:
return std::make_unique<EmitCodeGenOnlyAction>();
62 case EmitObj:
return std::make_unique<EmitObjAction>();
64 return std::make_unique<ExtractAPIAction>();
65 case FixIt:
return std::make_unique<FixItAction>();
67 return std::make_unique<GenerateModuleFromModuleMapAction>();
68 case GenerateModuleInterface:
69 return std::make_unique<GenerateModuleInterfaceAction>();
70 case GenerateReducedModuleInterface:
71 return std::make_unique<GenerateReducedModuleInterfaceAction>();
72 case GenerateHeaderUnit:
73 return std::make_unique<GenerateHeaderUnitAction>();
74 case GeneratePCH:
return std::make_unique<GeneratePCHAction>();
75 case GenerateInterfaceStubs:
76 return std::make_unique<GenerateInterfaceStubsAction>();
77 case InitOnly:
return std::make_unique<InitOnlyAction>();
78 case ParseSyntaxOnly:
return std::make_unique<SyntaxOnlyAction>();
79 case ModuleFileInfo:
return std::make_unique<DumpModuleInfoAction>();
80 case VerifyPCH:
return std::make_unique<VerifyPCHAction>();
81 case TemplightDump:
return std::make_unique<TemplightDumpAction>();
84 for (
const FrontendPluginRegistry::entry &Plugin :
85 FrontendPluginRegistry::entries()) {
87 std::unique_ptr<PluginASTAction>
P(Plugin.instantiate());
103 case PrintPreamble:
return std::make_unique<PrintPreambleAction>();
104 case PrintPreprocessedInput: {
107 return std::make_unique<RewriteIncludesAction>();
108 return std::make_unique<PrintPreprocessedAction>();
111 case RewriteMacros:
return std::make_unique<RewriteMacrosAction>();
112 case RewriteTest:
return std::make_unique<RewriteTestAction>();
113#if CLANG_ENABLE_OBJC_REWRITER
114 case RewriteObjC:
return std::make_unique<RewriteObjCAction>();
116 case RewriteObjC: Action =
"RewriteObjC";
break;
118#if CLANG_ENABLE_ARCMT
120 return std::make_unique<arcmt::MigrateSourceAction>();
122 case MigrateSource: Action =
"MigrateSource";
break;
124#if CLANG_ENABLE_STATIC_ANALYZER
125 case RunAnalysis:
return std::make_unique<ento::AnalysisAction>();
127 case RunAnalysis: Action =
"RunAnalysis";
break;
129 case RunPreprocessorOnly:
return std::make_unique<PreprocessOnlyAction>();
130 case PrintDependencyDirectivesSourceMinimizerOutput:
131 return std::make_unique<PrintDependencyDirectivesSourceMinimizerAction>();
134#if !CLANG_ENABLE_ARCMT || !CLANG_ENABLE_STATIC_ANALYZER \
135 || !CLANG_ENABLE_OBJC_REWRITER
139 llvm_unreachable(
"Invalid program action!");
143std::unique_ptr<FrontendAction>
153 Act = std::make_unique<FixItRecompile>(std::move(Act));
156#if CLANG_ENABLE_ARCMT
164 Act = std::make_unique<arcmt::CheckAction>(std::move(Act));
167 Act = std::make_unique<arcmt::ModifyAction>(std::move(Act));
170 Act = std::make_unique<arcmt::MigrateAction>(std::move(Act),
178 Act = std::make_unique<arcmt::ObjCMigrateAction>(std::move(Act),
194 Act = std::make_unique<WrappingExtractAPIAction>(std::move(Act));
200 Act = std::make_unique<ASTMergeAction>(std::move(Act),
210 llvm::outs(),
"clang -cc1 [options] file...",
211 "LLVM 'Clang' Compiler: http://clang.llvm.org",
221 llvm::cl::PrintVersionMessage();
233 auto Args = std::make_unique<const char*[]>(NumArgs + 2);
234 Args[0] =
"clang (LLVM option parsing)";
235 for (
unsigned i = 0; i != NumArgs; ++i)
237 Args[NumArgs + 1] =
nullptr;
238 llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get());
241#if CLANG_ENABLE_STATIC_ANALYZER
282 llvm::BuryPointer(std::move(Act));
Stores options for the analyzer from the command line.
unsigned ShowCheckerOptionDeveloperList
unsigned ShowEnabledCheckerList
unsigned ShowCheckerHelpAlpha
unsigned ShowConfigOptionsList
unsigned ShowCheckerHelpDeveloper
unsigned ShowCheckerOptionList
unsigned ShowCheckerOptionAlphaList
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
AnalyzerOptions & getAnalyzerOpts()
DiagnosticsEngine & getDiagnostics() const
Get the current diagnostics engine.
PreprocessorOutputOptions & getPreprocessorOutputOpts()
void LoadRequestedPlugins()
Load the list of plugins requested in the FrontendOptions.
FrontendOptions & getFrontendOpts()
bool ExecuteAction(FrontendAction &Act)
ExecuteAction - Execute the provided action against the compiler's CompilerInvocation object.
CodeGenOptions & getCodeGenOpts()
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
bool hasErrorOccurred() const
FrontendOptions - Options for controlling the behavior of the frontend.
unsigned EmitSymbolGraph
Whether to emit symbol graph files as a side effect of compilation.
std::map< std::string, std::vector< std::string > > PluginArgs
Args to pass to the plugins.
std::vector< std::string > LLVMArgs
A list of arguments to forward to LLVM's option processing; this should only be used for debugging an...
unsigned ShowHelp
Show the -help text.
unsigned FixAndRecompile
Apply fixes and recompile.
std::string ActionName
The name of the action to run when using a plugin action.
std::string ARCMTMigrateReportOut
unsigned ShowVersion
Show the -version text.
unsigned ARCMTMigrateEmitARCErrors
Emit ARC errors even if the migrator can fix them.
std::string SymbolGraphOutputDir
std::vector< std::string > ASTMergeFiles
The list of AST files to merge.
unsigned DisableFree
Disable memory freeing on exit.
frontend::ActionKind ProgramAction
The frontend action to perform.
enum clang::FrontendOptions::@199 ARCMTAction
@ ReplaceAction
Replace the main action.
@ CmdlineAfterMainAction
Execute the action after the main action if on the command line.
unsigned RewriteIncludes
Preprocess include directives only.
unsigned RewriteImports
Include contents of transitively-imported modules.
const llvm::opt::OptTable & getDriverOptTable()
void printEnabledCheckerList(llvm::raw_ostream &OS, CompilerInstance &CI)
void printCheckerHelp(llvm::raw_ostream &OS, CompilerInstance &CI)
void printAnalyzerConfigList(llvm::raw_ostream &OS)
void printCheckerConfigList(llvm::raw_ostream &OS, CompilerInstance &CI)
@ MigrateSource
Run migrator.
@ GeneratePCH
Generate pre-compiled header.
The JSON file list parser is used to communicate input to InstallAPI.
static std::unique_ptr< FrontendAction > CreateFrontendBaseAction(CompilerInstance &CI)
bool ExecuteCompilerInvocation(CompilerInstance *Clang)
ExecuteCompilerInvocation - Execute the given actions described by the compiler invocation object in ...
std::unique_ptr< FrontendAction > CreateFrontendAction(CompilerInstance &CI)
Construct the FrontendAction of a compiler invocation based on the options specified for the compiler...
@ Success
Template argument deduction was successful.