27 #include "llvm/Option/OptTable.h"
28 #include "llvm/Option/Option.h"
29 #include "llvm/Support/DynamicLibrary.h"
30 #include "llvm/Support/ErrorHandling.h"
31 using namespace clang;
32 using namespace llvm::opt;
34 static std::unique_ptr<FrontendAction>
36 using namespace clang::frontend;
37 StringRef
Action(
"unknown");
41 case ASTDeclList:
return llvm::make_unique<ASTDeclListAction>();
42 case ASTDump:
return llvm::make_unique<ASTDumpAction>();
43 case ASTPrint:
return llvm::make_unique<ASTPrintAction>();
44 case ASTView:
return llvm::make_unique<ASTViewAction>();
45 case DumpRawTokens:
return llvm::make_unique<DumpRawTokensAction>();
46 case DumpTokens:
return llvm::make_unique<DumpTokensAction>();
47 case EmitAssembly:
return llvm::make_unique<EmitAssemblyAction>();
48 case EmitBC:
return llvm::make_unique<EmitBCAction>();
49 case EmitHTML:
return llvm::make_unique<HTMLPrintAction>();
50 case EmitLLVM:
return llvm::make_unique<EmitLLVMAction>();
51 case EmitLLVMOnly:
return llvm::make_unique<EmitLLVMOnlyAction>();
52 case EmitCodeGenOnly:
return llvm::make_unique<EmitCodeGenOnlyAction>();
53 case EmitObj:
return llvm::make_unique<EmitObjAction>();
54 case FixIt:
return llvm::make_unique<FixItAction>();
55 case GenerateModule:
return llvm::make_unique<GenerateModuleAction>();
56 case GeneratePCH:
return llvm::make_unique<GeneratePCHAction>();
57 case GeneratePTH:
return llvm::make_unique<GeneratePTHAction>();
58 case InitOnly:
return llvm::make_unique<InitOnlyAction>();
60 case ModuleFileInfo:
return llvm::make_unique<DumpModuleInfoAction>();
61 case VerifyPCH:
return llvm::make_unique<VerifyPCHAction>();
68 std::unique_ptr<PluginASTAction>
P(it->instantiate());
83 case PrintPreamble:
return llvm::make_unique<PrintPreambleAction>();
86 return llvm::make_unique<RewriteIncludesAction>();
87 return llvm::make_unique<PrintPreprocessedAction>();
90 case RewriteMacros:
return llvm::make_unique<RewriteMacrosAction>();
91 case RewriteTest:
return llvm::make_unique<RewriteTestAction>();
92 #ifdef CLANG_ENABLE_OBJC_REWRITER
93 case RewriteObjC:
return llvm::make_unique<RewriteObjCAction>();
97 #ifdef CLANG_ENABLE_ARCMT
99 return llvm::make_unique<arcmt::MigrateSourceAction>();
103 #ifdef CLANG_ENABLE_STATIC_ANALYZER
104 case RunAnalysis:
return llvm::make_unique<ento::AnalysisAction>();
111 #if !defined(CLANG_ENABLE_ARCMT) || !defined(CLANG_ENABLE_STATIC_ANALYZER) \
112 || !defined(CLANG_ENABLE_OBJC_REWRITER)
116 llvm_unreachable(
"Invalid program action!");
120 static std::unique_ptr<FrontendAction>
130 Act = llvm::make_unique<FixItRecompile>(std::move(Act));
133 #ifdef CLANG_ENABLE_ARCMT
141 Act = llvm::make_unique<arcmt::CheckAction>(std::move(Act));
144 Act = llvm::make_unique<arcmt::ModifyAction>(std::move(Act));
147 Act = llvm::make_unique<arcmt::MigrateAction>(std::move(Act),
155 Act = llvm::make_unique<arcmt::ObjCMigrateAction>(std::move(Act),
165 Act = llvm::make_unique<ASTMergeAction>(std::move(Act),
175 Opts->PrintHelp(llvm::outs(),
"clang -cc1",
176 "LLVM 'Clang' Compiler: http://clang.llvm.org",
185 llvm::cl::PrintVersionMessage();
194 if (llvm::sys::DynamicLibrary::LoadLibraryPermanently(Path.c_str(), &
Error))
203 std::unique_ptr<PluginASTAction>
P(it->instantiate());
217 auto Args = llvm::make_unique<const char*[]>(NumArgs + 2);
218 Args[0] =
"clang (LLVM option parsing)";
219 for (
unsigned i = 0; i !=
NumArgs; ++i)
221 Args[NumArgs + 1] =
nullptr;
222 llvm::cl::ParseCommandLineOptions(NumArgs + 1, Args.get());
225 #ifdef CLANG_ENABLE_STATIC_ANALYZER
Expand macros but not #includes.
Generate pre-compiled module.
Parse and perform semantic analysis.
Parse ASTs and print them.
bool hasErrorOccurred() const
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
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()
AnalyzerOptionsRef getAnalyzerOpts()
unsigned FixAndRecompile
Apply fixes and recompile.
Dump out preprocessed tokens.
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.
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
DiagnosticsEngine & getDiagnostics() const
Get the current diagnostics engine.
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.
const TemplateArgument * iterator
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 ShowHelp
Show the -help text.
void printCheckerHelp(raw_ostream &OS, ArrayRef< std::string > plugins)
frontend::ActionKind ProgramAction
The frontend action to perform.
std::string ARCMTMigrateReportOut
enum clang::FrontendOptions::@156 ARCMTAction
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 ...
llvm::opt::OptTable * createDriverOptTable()
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.
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.