16 #include "clang/Config/config.h" 27 #include "llvm/Option/OptTable.h" 28 #include "llvm/Option/Option.h" 29 #include "llvm/Support/BuryPointer.h" 30 #include "llvm/Support/DynamicLibrary.h" 31 #include "llvm/Support/ErrorHandling.h" 32 using namespace clang;
37 static std::unique_ptr<FrontendAction>
40 StringRef Action(
"unknown");
44 case ASTDeclList:
return llvm::make_unique<ASTDeclListAction>();
45 case ASTDump:
return llvm::make_unique<ASTDumpAction>();
46 case ASTPrint:
return llvm::make_unique<ASTPrintAction>();
47 case ASTView:
return llvm::make_unique<ASTViewAction>();
49 return llvm::make_unique<DumpCompilerOptionsAction>();
50 case DumpRawTokens:
return llvm::make_unique<DumpRawTokensAction>();
51 case DumpTokens:
return llvm::make_unique<DumpTokensAction>();
52 case EmitAssembly:
return llvm::make_unique<EmitAssemblyAction>();
53 case EmitBC:
return llvm::make_unique<EmitBCAction>();
54 case EmitHTML:
return llvm::make_unique<HTMLPrintAction>();
55 case EmitLLVM:
return llvm::make_unique<EmitLLVMAction>();
56 case EmitLLVMOnly:
return llvm::make_unique<EmitLLVMOnlyAction>();
57 case EmitCodeGenOnly:
return llvm::make_unique<EmitCodeGenOnlyAction>();
58 case EmitObj:
return llvm::make_unique<EmitObjAction>();
59 case FixIt:
return llvm::make_unique<FixItAction>();
61 return llvm::make_unique<GenerateModuleFromModuleMapAction>();
63 return llvm::make_unique<GenerateModuleInterfaceAction>();
65 return llvm::make_unique<GenerateHeaderModuleAction>();
66 case GeneratePCH:
return llvm::make_unique<GeneratePCHAction>();
68 return llvm::make_unique<GenerateInterfaceYAMLExpV1Action>();
70 return llvm::make_unique<GenerateInterfaceTBEExpV1Action>();
71 case InitOnly:
return llvm::make_unique<InitOnlyAction>();
73 case ModuleFileInfo:
return llvm::make_unique<DumpModuleInfoAction>();
74 case VerifyPCH:
return llvm::make_unique<VerifyPCHAction>();
75 case TemplightDump:
return llvm::make_unique<TemplightDumpAction>();
78 for (FrontendPluginRegistry::iterator it =
79 FrontendPluginRegistry::begin(), ie = FrontendPluginRegistry::end();
82 std::unique_ptr<PluginASTAction>
P(it->instantiate());
96 case PrintPreamble:
return llvm::make_unique<PrintPreambleAction>();
100 return llvm::make_unique<RewriteIncludesAction>();
101 return llvm::make_unique<PrintPreprocessedAction>();
104 case RewriteMacros:
return llvm::make_unique<RewriteMacrosAction>();
105 case RewriteTest:
return llvm::make_unique<RewriteTestAction>();
106 #if CLANG_ENABLE_OBJC_REWRITER 107 case RewriteObjC:
return llvm::make_unique<RewriteObjCAction>();
111 #if CLANG_ENABLE_ARCMT 113 return llvm::make_unique<arcmt::MigrateSourceAction>();
117 #if CLANG_ENABLE_STATIC_ANALYZER 118 case RunAnalysis:
return llvm::make_unique<ento::AnalysisAction>();
124 return llvm::make_unique<PrintDependencyDirectivesSourceMinimizerAction>();
127 #if !CLANG_ENABLE_ARCMT || !CLANG_ENABLE_STATIC_ANALYZER \ 128 || !CLANG_ENABLE_OBJC_REWRITER 132 llvm_unreachable(
"Invalid program action!");
136 std::unique_ptr<FrontendAction>
146 Act = llvm::make_unique<FixItRecompile>(std::move(Act));
149 #if CLANG_ENABLE_ARCMT 157 Act = llvm::make_unique<arcmt::CheckAction>(std::move(Act));
160 Act = llvm::make_unique<arcmt::ModifyAction>(std::move(Act));
163 Act = llvm::make_unique<arcmt::MigrateAction>(std::move(Act),
171 Act = llvm::make_unique<arcmt::ObjCMigrateAction>(std::move(Act),
181 Act = llvm::make_unique<ASTMergeAction>(std::move(Act),
191 Opts->PrintHelp(llvm::outs(),
"clang -cc1 [options] file...",
192 "LLVM 'Clang' Compiler: http://clang.llvm.org",
202 llvm::cl::PrintVersionMessage();
211 if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &
Error))
217 for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
218 ie = FrontendPluginRegistry::end();
220 std::unique_ptr<PluginASTAction>
P(it->instantiate());
234 auto Args = llvm::make_unique<const char*[]>(NumArgs + 2);
235 Args[0] =
"clang (LLVM option parsing)";
236 for (
unsigned i = 0;
i != NumArgs; ++
i)
238 Args[NumArgs + 1] =
nullptr;
239 llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get());
242 #if CLANG_ENABLE_STATIC_ANALYZER 247 if (AnOpts.ShowCheckerHelp || AnOpts.ShowCheckerHelpAlpha ||
248 AnOpts.ShowCheckerHelpDeveloper) {
258 if (AnOpts.ShowCheckerOptionList || AnOpts.ShowCheckerOptionAlphaList ||
259 AnOpts.ShowCheckerOptionDeveloperList) {
269 if (AnOpts.ShowEnabledCheckerList) {
278 if (AnOpts.ShowConfigOptionsList) {
293 llvm::BuryPointer(std::move(Act));
Expand macros but not #includes.
LangOptions & getLangOpts()
bool hasErrorOccurred() const
void printEnabledCheckerList(raw_ostream &OS, ArrayRef< std::string > plugins, AnalyzerOptions &opts, DiagnosticsEngine &diags, const LangOptions &LangOpts)
Generate pre-compiled module from a module map.
Print the output of the dependency directives source minimizer.
Parse and perform semantic analysis.
std::unique_ptr< FrontendAction > CreateFrontendAction(CompilerInstance &CI)
Construct the FrontendAction of a compiler invocation based on the options specified for the compiler...
Parse ASTs and print them.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
void printAnalyzerConfigList(raw_ostream &OS)
Parse and apply any fixits to the source.
Translate input source into HTML.
static std::unique_ptr< FrontendAction > CreateFrontendBaseAction(CompilerInstance &CI)
std::vector< std::string > ASTMergeFiles
The list of AST files to merge.
Action is determined by the cc1 command-line.
Generate LLVM IR, but do not emit anything.
FrontendOptions & getFrontendOpts()
PreprocessorOutputOptions & getPreprocessorOutputOpts()
void printCheckerHelp(raw_ostream &OS, ArrayRef< std::string > plugins, AnalyzerOptions &opts, DiagnosticsEngine &diags, const LangOptions &LangOpts)
std::unique_ptr< llvm::opt::OptTable > createDriverOptTable()
AnalyzerOptionsRef getAnalyzerOpts()
unsigned FixAndRecompile
Apply fixes and recompile.
Dump the compiler configuration.
Dump template instantiations.
Dump out preprocessed tokens.
Generate pre-compiled module from a C++ module interface file.
std::vector< std::string > Plugins
The list of plugins to load.
unsigned RewriteIncludes
Preprocess include directives only.
Only execute frontend initialization.
Print the "preamble" of the input file.
void printCheckerConfigList(raw_ostream &OS, ArrayRef< std::string > plugins, AnalyzerOptions &opts, DiagnosticsEngine &diags, const LangOptions &LangOpts)
unsigned ARCMTMigrateEmitARCErrors
Emit ARC errors even if the migrator can fix them.
bool ExecuteAction(FrontendAction &Act)
ExecuteAction - Execute the provided action against the compiler's CompilerInvocation object...
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Generate machine code, but don't emit anything.
Parse ASTs and view them in Graphviz.
Parse ASTs and list Decl nodes.
std::unordered_map< std::string, std::vector< std::string > > PluginArgs
Args to pass to the plugins.
Load and verify that a PCH file is usable.
unsigned ShowVersion
Show the -version text.
unsigned RewriteImports
Include contents of transitively-imported modules.
unsigned ShowHelp
Show the -help text.
Dataflow Directional Tag Classes.
frontend::ActionKind ProgramAction
The frontend action to perform.
std::string ARCMTMigrateReportOut
FrontendOptions - Options for controlling the behavior of the frontend.
Parse ASTs and dump them.
bool ExecuteCompilerInvocation(CompilerInstance *Clang)
ExecuteCompilerInvocation - Execute the given actions described by the compiler invocation object in ...
enum clang::FrontendOptions::@193 ARCMTAction
Stores options for the analyzer from the command line.
unsigned DisableFree
Disable memory freeing on exit.
Generate pre-compiled header.
Generate pre-compiled module from a set of header files.
std::string ActionName
The name of the action to run when using a plugin action.
Run one or more source code analyses.
Generate Interface Stub Files.
DiagnosticsEngine & getDiagnostics() const
Get the current diagnostics engine.
std::vector< std::string > LLVMArgs
A list of arguments to forward to LLVM's option processing; this should only be used for debugging an...
Dump information about a module file.