17 #include "clang/Config/config.h" 28 #include "llvm/Option/OptTable.h" 29 #include "llvm/Option/Option.h" 30 #include "llvm/Support/BuryPointer.h" 31 #include "llvm/Support/DynamicLibrary.h" 32 #include "llvm/Support/ErrorHandling.h" 33 using namespace clang;
38 static std::unique_ptr<FrontendAction>
41 StringRef Action(
"unknown");
45 case ASTDeclList:
return llvm::make_unique<ASTDeclListAction>();
46 case ASTDump:
return llvm::make_unique<ASTDumpAction>();
47 case ASTPrint:
return llvm::make_unique<ASTPrintAction>();
48 case ASTView:
return llvm::make_unique<ASTViewAction>();
50 return llvm::make_unique<DumpCompilerOptionsAction>();
51 case DumpRawTokens:
return llvm::make_unique<DumpRawTokensAction>();
52 case DumpTokens:
return llvm::make_unique<DumpTokensAction>();
53 case EmitAssembly:
return llvm::make_unique<EmitAssemblyAction>();
54 case EmitBC:
return llvm::make_unique<EmitBCAction>();
55 case EmitHTML:
return llvm::make_unique<HTMLPrintAction>();
56 case EmitLLVM:
return llvm::make_unique<EmitLLVMAction>();
57 case EmitLLVMOnly:
return llvm::make_unique<EmitLLVMOnlyAction>();
58 case EmitCodeGenOnly:
return llvm::make_unique<EmitCodeGenOnlyAction>();
59 case EmitObj:
return llvm::make_unique<EmitObjAction>();
60 case FixIt:
return llvm::make_unique<FixItAction>();
62 return llvm::make_unique<GenerateModuleFromModuleMapAction>();
64 return llvm::make_unique<GenerateModuleInterfaceAction>();
66 return llvm::make_unique<GenerateHeaderModuleAction>();
67 case GeneratePCH:
return llvm::make_unique<GeneratePCHAction>();
68 case InitOnly:
return llvm::make_unique<InitOnlyAction>();
70 case ModuleFileInfo:
return llvm::make_unique<DumpModuleInfoAction>();
71 case VerifyPCH:
return llvm::make_unique<VerifyPCHAction>();
72 case TemplightDump:
return llvm::make_unique<TemplightDumpAction>();
75 for (FrontendPluginRegistry::iterator it =
76 FrontendPluginRegistry::begin(), ie = FrontendPluginRegistry::end();
79 std::unique_ptr<PluginASTAction>
P(it->instantiate());
93 case PrintPreamble:
return llvm::make_unique<PrintPreambleAction>();
97 return llvm::make_unique<RewriteIncludesAction>();
98 return llvm::make_unique<PrintPreprocessedAction>();
101 case RewriteMacros:
return llvm::make_unique<RewriteMacrosAction>();
102 case RewriteTest:
return llvm::make_unique<RewriteTestAction>();
103 #if CLANG_ENABLE_OBJC_REWRITER 104 case RewriteObjC:
return llvm::make_unique<RewriteObjCAction>();
108 #if CLANG_ENABLE_ARCMT 110 return llvm::make_unique<arcmt::MigrateSourceAction>();
114 #if CLANG_ENABLE_STATIC_ANALYZER 115 case RunAnalysis:
return llvm::make_unique<ento::AnalysisAction>();
122 #if !CLANG_ENABLE_ARCMT || !CLANG_ENABLE_STATIC_ANALYZER \ 123 || !CLANG_ENABLE_OBJC_REWRITER 127 llvm_unreachable(
"Invalid program action!");
131 std::unique_ptr<FrontendAction>
141 Act = llvm::make_unique<FixItRecompile>(std::move(Act));
144 #if CLANG_ENABLE_ARCMT 152 Act = llvm::make_unique<arcmt::CheckAction>(std::move(Act));
155 Act = llvm::make_unique<arcmt::ModifyAction>(std::move(Act));
158 Act = llvm::make_unique<arcmt::MigrateAction>(std::move(Act),
166 Act = llvm::make_unique<arcmt::ObjCMigrateAction>(std::move(Act),
176 Act = llvm::make_unique<ASTMergeAction>(std::move(Act),
186 Opts->PrintHelp(llvm::outs(),
"clang -cc1 [options] file...",
187 "LLVM 'Clang' Compiler: http://clang.llvm.org",
197 llvm::cl::PrintVersionMessage();
206 if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &
Error))
212 for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
213 ie = FrontendPluginRegistry::end();
215 std::unique_ptr<PluginASTAction>
P(it->instantiate());
229 auto Args = llvm::make_unique<const char*[]>(NumArgs + 2);
230 Args[0] =
"clang (LLVM option parsing)";
231 for (
unsigned i = 0; i != NumArgs; ++i)
233 Args[NumArgs + 1] =
nullptr;
234 llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get());
237 #if CLANG_ENABLE_STATIC_ANALYZER 270 llvm::BuryPointer(std::move(Act));
Expand macros but not #includes.
bool hasErrorOccurred() const
Generate pre-compiled module from a module map.
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.
void printCheckerHelp(raw_ostream &OS, ArrayRef< std::string > plugins, DiagnosticsEngine &diags)
Action is determined by the cc1 command-line.
Generate LLVM IR, but do not emit anything.
FrontendOptions & getFrontendOpts()
PreprocessorOutputOptions & getPreprocessorOutputOpts()
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.
enum clang::FrontendOptions::@191 ARCMTAction
unsigned ARCMTMigrateEmitARCErrors
Emit ARC errors even if the migrator can fix them.
void printEnabledCheckerList(raw_ostream &OS, ArrayRef< std::string > plugins, const AnalyzerOptions &opts, DiagnosticsEngine &diags)
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 ...
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.
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.