18 #include "clang/Config/config.h" 28 #include "llvm/Option/OptTable.h" 29 #include "llvm/Option/Option.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>();
64 case GeneratePCH:
return llvm::make_unique<GeneratePCHAction>();
65 case GeneratePTH:
return llvm::make_unique<GeneratePTHAction>();
66 case InitOnly:
return llvm::make_unique<InitOnlyAction>();
68 case ModuleFileInfo:
return llvm::make_unique<DumpModuleInfoAction>();
69 case VerifyPCH:
return llvm::make_unique<VerifyPCHAction>();
70 case TemplightDump:
return llvm::make_unique<TemplightDumpAction>();
73 for (FrontendPluginRegistry::iterator it =
74 FrontendPluginRegistry::begin(), ie = FrontendPluginRegistry::end();
77 std::unique_ptr<PluginASTAction>
P(it->instantiate());
92 case PrintPreamble:
return llvm::make_unique<PrintPreambleAction>();
96 return llvm::make_unique<RewriteIncludesAction>();
97 return llvm::make_unique<PrintPreprocessedAction>();
100 case RewriteMacros:
return llvm::make_unique<RewriteMacrosAction>();
101 case RewriteTest:
return llvm::make_unique<RewriteTestAction>();
102 #if CLANG_ENABLE_OBJC_REWRITER 103 case RewriteObjC:
return llvm::make_unique<RewriteObjCAction>();
107 #if CLANG_ENABLE_ARCMT 109 return llvm::make_unique<arcmt::MigrateSourceAction>();
113 #if CLANG_ENABLE_STATIC_ANALYZER 114 case RunAnalysis:
return llvm::make_unique<ento::AnalysisAction>();
121 #if !CLANG_ENABLE_ARCMT || !CLANG_ENABLE_STATIC_ANALYZER \ 122 || !CLANG_ENABLE_OBJC_REWRITER 126 llvm_unreachable(
"Invalid program action!");
130 std::unique_ptr<FrontendAction>
140 Act = llvm::make_unique<FixItRecompile>(std::move(Act));
143 #if CLANG_ENABLE_ARCMT 151 Act = llvm::make_unique<arcmt::CheckAction>(std::move(Act));
154 Act = llvm::make_unique<arcmt::ModifyAction>(std::move(Act));
157 Act = llvm::make_unique<arcmt::MigrateAction>(std::move(Act),
165 Act = llvm::make_unique<arcmt::ObjCMigrateAction>(std::move(Act),
175 Act = llvm::make_unique<ASTMergeAction>(std::move(Act),
185 Opts->PrintHelp(llvm::outs(),
"clang -cc1",
186 "LLVM 'Clang' Compiler: http://clang.llvm.org",
196 llvm::cl::PrintVersionMessage();
205 if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &
Error))
211 for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
212 ie = FrontendPluginRegistry::end();
214 std::unique_ptr<PluginASTAction>
P(it->instantiate());
228 auto Args = llvm::make_unique<const char*[]>(NumArgs + 2);
229 Args[0] =
"clang (LLVM option parsing)";
230 for (
unsigned i = 0; i != NumArgs; ++i)
232 Args[NumArgs + 1] =
nullptr;
233 llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get());
236 #if CLANG_ENABLE_STATIC_ANALYZER 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 printEnabledCheckerList(raw_ostream &OS, ArrayRef< std::string > plugins, const AnalyzerOptions &opts)
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.
Print DeclContext and their Decls.
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.
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.
void printCheckerHelp(raw_ostream &OS, ArrayRef< std::string > plugins)
Dataflow Directional Tag Classes.
frontend::ActionKind ProgramAction
The frontend action to perform.
std::string ARCMTMigrateReportOut
FrontendOptions - Options for controlling the behavior of the frontend.
void BuryPointer(const void *Ptr)
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.
enum clang::FrontendOptions::@169 ARCMTAction
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.
Generate pre-tokenized header.