10 #ifndef LLVM_CLANG_DRIVER_DRIVER_H
11 #define LLVM_CLANG_DRIVER_DRIVER_H
18 #include "llvm/ADT/StringMap.h"
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/ADT/Triple.h"
21 #include "llvm/Support/Path.h"
67 llvm::opt::OptTable *Opts;
86 enum BitcodeEmbedMode {
98 return Diags.
Report(DiagID);
187 std::string CCCGenericGCCName;
191 unsigned CheckInputsExist : 1;
199 unsigned SuppressMissingInputWarning : 1;
201 std::list<std::string> TempFiles;
202 std::list<std::string> ResultFiles;
209 mutable llvm::StringMap<ToolChain *> ToolChains;
214 llvm::opt::DerivedArgList *
215 TranslateInputArgs(
const llvm::opt::InputArgList &Args)
const;
219 phases::ID getFinalPhase(
const llvm::opt::DerivedArgList &DAL,
220 llvm::opt::Arg **FinalPhaseArg =
nullptr)
const;
225 void generatePrefixedToolNames(
const char *
Tool,
const ToolChain &TC,
240 const llvm::opt::OptTable &
getOpts()
const {
return *Opts; }
348 const Command &FailingCommand);
399 const char *BoundArch,
bool AtTopLevel,
bool MultipleArchs,
400 const char *LinkingOutput,
401 std::map<std::pair<const Action *, std::string>,
InputInfo>
403 bool BuildForOffloadDevice)
const;
421 const char *BaseInput,
const char *BoundArch,
422 bool AtTopLevel,
bool MultipleArchs,
423 StringRef NormalizedTriple)
const;
447 void setLTOMode(
const llvm::opt::ArgList &Args);
453 const ToolChain &getToolChain(
const llvm::opt::ArgList &Args,
454 const llvm::Triple &Target)
const;
460 std::pair<unsigned, unsigned> getIncludeExcludeOptionFlagMasks()
const;
467 const char *BoundArch,
bool AtTopLevel,
bool MultipleArchs,
468 const char *LinkingOutput,
469 std::map<std::pair<const Action *, std::string>,
InputInfo>
471 bool BuildForOffloadDevice)
const;
482 unsigned &Minor,
unsigned &Micro,
ID
ID - Ordered values for successive stages in the compilation process which interact with user options...
Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple, DiagnosticsEngine &Diags, IntrusiveRefCntPtr< vfs::FileSystem > VFS=nullptr)
void ParseDriverMode(ArrayRef< const char * > Args)
ParseDriverMode - Look for and handle the driver mode option in Args.
unsigned CCPrintHeaders
Set CC_PRINT_HEADERS mode, which causes the frontend to log header include information to CCPrintHead...
unsigned CCCUsePCH
Use lazy precompiled headers for PCH support.
const char * GetNamedOutputPath(Compilation &C, const JobAction &JA, const char *BaseInput, const char *BoundArch, bool AtTopLevel, bool MultipleArchs, StringRef NormalizedTriple) const
GetNamedOutputPath - Return the name to use for the output of the action JA.
std::string GetTemporaryPath(StringRef Prefix, const char *Suffix) const
GetTemporaryPath - Return the pathname of a temporary file to use as part of compilation; the file wi...
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
const llvm::opt::OptTable & getOpts() const
std::string DyldPrefix
Dynamic loader prefix, if present.
DiagnosticBuilder Diag(unsigned DiagID) const
static bool GetReleaseVersion(const char *Str, unsigned &Major, unsigned &Minor, unsigned &Micro, bool &HadExtra)
GetReleaseVersion - Parse (([0-9]+)(.
Compilation * BuildCompilation(ArrayRef< const char * > Args)
BuildCompilation - Construct a compilation object for a command line argument vector.
void BuildUniversalActions(Compilation &C, const ToolChain &TC, const InputList &BAInputs) const
BuildUniversalActions - Construct the list of actions to perform for the given arguments, which may require a universal build.
bool ShouldUseClangCompiler(const JobAction &JA) const
ShouldUseClangCompiler - Should the clang compiler be used to handle this action. ...
bool CCCIsCXX() const
Whether the driver should follow g++ like behavior.
The virtual file system interface.
void PrintHelp(bool ShowHidden) const
PrintHelp - Print the help text.
unsigned CCLogDiagnostics
Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics to CCLogDiagnosticsFilename...
const std::string & getTitle()
void PrintActions(const Compilation &C) const
PrintActions - Print the list of actions.
std::string Dir
The path the driver executable was in, as invoked from the command line.
Action - Represent an abstract compilation step to perform.
InputInfo BuildJobsForAction(Compilation &C, const Action *A, const ToolChain *TC, const char *BoundArch, bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput, std::map< std::pair< const Action *, std::string >, InputInfo > &CachedResults, bool BuildForOffloadDevice) const
BuildJobsForAction - Construct the jobs to perform for the action A and return an InputInfo for the r...
bool HandleImmediateArgs(const Compilation &C)
HandleImmediateArgs - Handle any arguments which should be treated before building actions or binding...
const char * getInstalledDir() const
Get the path to where the clang executable was installed.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
Concrete class used by the front-end to report problems and issues.
bool embedBitcodeEnabled() const
void BuildActions(Compilation &C, llvm::opt::DerivedArgList &Args, const InputList &Inputs, ActionList &Actions) const
BuildActions - Construct the list of actions to perform for the given arguments, which are only done ...
std::string GetFilePath(const char *Name, const ToolChain &TC) const
GetFilePath - Lookup Name in the list of file search paths.
llvm::opt::InputArgList ParseArgStrings(ArrayRef< const char * > Args)
ParseArgStrings - Parse the given list of strings into an ArgList.
bool isOptimizationLevelFast(const llvm::opt::ArgList &Args)
bool IsCLMode() const
Whether the driver should follow cl.exe like behavior.
void generateCompilationDiagnostics(Compilation &C, const Command &FailingCommand)
generateCompilationDiagnostics - Generate diagnostics information including preprocessed source file(...
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
const char * CCPrintOptionsFilename
The file to log CC_PRINT_OPTIONS output to, if enabled.
void PrintVersion(const Compilation &C, raw_ostream &OS) const
PrintVersion - Print the driver version.
bool isSaveTempsEnabled() const
SmallVector< std::pair< types::ID, const llvm::opt::Arg * >, 16 > InputList
A list of inputs and their types for the given arguments.
A little helper class used to produce diagnostics.
bool getCheckInputsExist() const
Action * ConstructPhaseAction(Compilation &C, const llvm::opt::ArgList &Args, phases::ID Phase, Action *Input) const
ConstructAction - Construct the appropriate action to do for Phase on the Input, taking in to account...
unsigned CCPrintOptions
Set CC_PRINT_OPTIONS mode, which is like -v but logs the commands to CCPrintOptionsFilename or to std...
vfs::FileSystem & getVFS() const
void setCheckInputsExist(bool Value)
int ExecuteCompilation(Compilation &C, SmallVectorImpl< std::pair< int, const Command * > > &FailingCommands)
ExecuteCompilation - Execute the compilation according to the command line arguments and return an ap...
std::string GetClPchPath(Compilation &C, StringRef BaseName) const
Return the pathname of the pch file in clang-cl mode.
bool embedBitcodeMarkerOnly() const
bool UseStdLib
If the standard library is used.
std::string GetProgramPath(const char *Name, const ToolChain &TC) const
GetProgramPath - Lookup Name in the list of program search paths.
void BuildJobs(Compilation &C) const
BuildJobs - Bind actions to concrete tools and translate arguments to form the list of jobs to run...
std::string HostBits
Information about the host which can be overridden by the user.
Command - An executable path/name and argument vector to execute.
std::string InstalledDir
The path to the installed clang directory, if any.
bool isSaveTempsObj() const
LTOKind getLTOMode() const
Get the specific kind of LTO being performed.
void setTitle(std::string Value)
const char * getDefaultImageName() const
Returns the default name for linked images (e.g., "a.out").
bool CCCIsCPP() const
Whether the driver is just the preprocessor.
const char * CCPrintHeadersFilename
The file to log CC_PRINT_HEADERS output to, if enabled.
unsigned CCCPrintBindings
Only print tool bindings, don't build any jobs.
std::string SysRoot
sysroot, if present
std::string Name
The name the driver was invoked as.
const char * getClangProgramPath() const
Get the path to the main clang executable.
Defines the Diagnostic-related interfaces.
std::string ClangExecutable
The original path to the clang executable.
void BuildInputs(const ToolChain &TC, llvm::opt::DerivedArgList &Args, InputList &Inputs) const
BuildInputs - Construct the list of inputs and their types from the given arguments.
Compilation - A set of tasks to perform for a single driver invocation.
const DiagnosticsEngine & getDiags() const
SmallVector< std::string, 4 > prefix_list
A prefix directory used to emulate a limited subset of GCC's '-Bprefix' functionality.
const char * CCLogDiagnosticsFilename
The file to log CC_LOG_DIAGNOSTICS output to, if enabled.
bool isUsingLTO() const
Returns true if we are performing any kind of LTO.
std::string DefaultTargetTriple
Default target triple.
LTOKind
Describes the kind of LTO mode selected via -f(no-)?lto(=.*)? options.
const std::string & getCCCGenericGCCName() const
Name to use when invoking gcc/g++.
std::string DriverTitle
Driver title to use with help.
void setInstalledDir(StringRef Value)
void CreateOffloadingDeviceToolChains(Compilation &C, InputList &Inputs)
CreateOffloadingDeviceToolChains - create all the toolchains required to support offloading devices g...
unsigned CCGenDiagnostics
Whether the driver is generating diagnostics for debugging purposes.
std::string ResourceDir
The path to the compiler resource directory.