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;
35 static std::unique_ptr<FrontendAction>
38 StringRef Action(
"unknown");
42 case ASTDeclList:
return llvm::make_unique<ASTDeclListAction>();
43 case ASTDump:
return llvm::make_unique<ASTDumpAction>();
44 case ASTPrint:
return llvm::make_unique<ASTPrintAction>();
45 case ASTView:
return llvm::make_unique<ASTViewAction>();
46 case DumpRawTokens:
return llvm::make_unique<DumpRawTokensAction>();
47 case DumpTokens:
return llvm::make_unique<DumpTokensAction>();
48 case EmitAssembly:
return llvm::make_unique<EmitAssemblyAction>();
49 case EmitBC:
return llvm::make_unique<EmitBCAction>();
50 case EmitHTML:
return llvm::make_unique<HTMLPrintAction>();
51 case EmitLLVM:
return llvm::make_unique<EmitLLVMAction>();
52 case EmitLLVMOnly:
return llvm::make_unique<EmitLLVMOnlyAction>();
53 case EmitCodeGenOnly:
return llvm::make_unique<EmitCodeGenOnlyAction>();
54 case EmitObj:
return llvm::make_unique<EmitObjAction>();
55 case FixIt:
return llvm::make_unique<FixItAction>();
57 return llvm::make_unique<GenerateModuleFromModuleMapAction>();
59 return llvm::make_unique<GenerateModuleInterfaceAction>();
60 case GeneratePCH:
return llvm::make_unique<GeneratePCHAction>();
61 case GeneratePTH:
return llvm::make_unique<GeneratePTHAction>();
62 case InitOnly:
return llvm::make_unique<InitOnlyAction>();
64 case ModuleFileInfo:
return llvm::make_unique<DumpModuleInfoAction>();
65 case VerifyPCH:
return llvm::make_unique<VerifyPCHAction>();
68 for (FrontendPluginRegistry::iterator it =
69 FrontendPluginRegistry::begin(), ie = FrontendPluginRegistry::end();
72 std::unique_ptr<PluginASTAction>
P(it->instantiate());
87 case PrintPreamble:
return llvm::make_unique<PrintPreambleAction>();
91 return llvm::make_unique<RewriteIncludesAction>();
92 return llvm::make_unique<PrintPreprocessedAction>();
95 case RewriteMacros:
return llvm::make_unique<RewriteMacrosAction>();
96 case RewriteTest:
return llvm::make_unique<RewriteTestAction>();
97 #if CLANG_ENABLE_OBJC_REWRITER 98 case RewriteObjC:
return llvm::make_unique<RewriteObjCAction>();
102 #if CLANG_ENABLE_ARCMT 104 return llvm::make_unique<arcmt::MigrateSourceAction>();
108 #if CLANG_ENABLE_STATIC_ANALYZER 109 case RunAnalysis:
return llvm::make_unique<ento::AnalysisAction>();
116 #if !CLANG_ENABLE_ARCMT || !CLANG_ENABLE_STATIC_ANALYZER \ 117 || !CLANG_ENABLE_OBJC_REWRITER 121 llvm_unreachable(
"Invalid program action!");
125 static std::unique_ptr<FrontendAction>
135 Act = llvm::make_unique<FixItRecompile>(std::move(Act));
138 #if CLANG_ENABLE_ARCMT 146 Act = llvm::make_unique<arcmt::CheckAction>(std::move(Act));
149 Act = llvm::make_unique<arcmt::ModifyAction>(std::move(Act));
152 Act = llvm::make_unique<arcmt::MigrateAction>(std::move(Act),
160 Act = llvm::make_unique<arcmt::ObjCMigrateAction>(std::move(Act),
170 Act = llvm::make_unique<ASTMergeAction>(std::move(Act),
180 Opts->PrintHelp(llvm::outs(),
"clang -cc1",
181 "LLVM 'Clang' Compiler: http://clang.llvm.org",
191 llvm::cl::PrintVersionMessage();
200 if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &
Error))
206 for (FrontendPluginRegistry::iterator it = FrontendPluginRegistry::begin(),
207 ie = FrontendPluginRegistry::end();
209 std::unique_ptr<PluginASTAction>
P(it->instantiate());
223 auto Args = llvm::make_unique<const char*[]>(NumArgs + 2);
224 Args[0] =
"clang (LLVM option parsing)";
225 for (
unsigned i = 0; i != NumArgs; ++i)
227 Args[NumArgs + 1] =
nullptr;
228 llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get());
231 #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.
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)
enum clang::FrontendOptions::@168 ARCMTAction
Parse and apply any fixits to the source.
static std::unique_ptr< FrontendAction > CreateFrontendAction(CompilerInstance &CI)
Translate input source into HTML.
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 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
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 ...
static std::unique_ptr< FrontendAction > CreateFrontendBaseAction(CompilerInstance &CI)
unsigned DisableFree
Disable memory freeing on exit.
Generate pre-compiled header.
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.