10 #ifndef LLVM_CLANG_DRIVER_DRIVER_H 11 #define LLVM_CLANG_DRIVER_DRIVER_H 20 #include "llvm/ADT/StringMap.h" 21 #include "llvm/ADT/StringRef.h" 22 #include "llvm/Option/ArgList.h" 23 #include "llvm/Support/StringSaver.h" 60 std::unique_ptr<llvm::opt::OptTable> Opts;
79 enum BitcodeEmbedMode {
111 return Diags.
Report(DiagID);
180 bool CCCIsCC()
const {
return Mode == GCCMode; }
206 std::string DefaultTargetTriple;
209 std::string CCCGenericGCCName;
212 std::string ConfigFile;
215 llvm::BumpPtrAllocator Alloc;
218 llvm::StringSaver Saver;
221 std::unique_ptr<llvm::opt::InputArgList> CfgOptions;
224 std::unique_ptr<llvm::opt::InputArgList> CLOptions;
228 unsigned CheckInputsExist : 1;
241 unsigned SuppressMissingInputWarning : 1;
243 std::list<std::string> TempFiles;
244 std::list<std::string> ResultFiles;
251 mutable llvm::StringMap<std::unique_ptr<ToolChain>> ToolChains;
256 llvm::opt::DerivedArgList *
257 TranslateInputArgs(
const llvm::opt::InputArgList &Args)
const;
261 phases::ID getFinalPhase(
const llvm::opt::DerivedArgList &DAL,
262 llvm::opt::Arg **FinalPhaseArg =
nullptr)
const;
267 void generatePrefixedToolNames(StringRef
Tool,
const ToolChain &TC,
281 bool getCrashDiagnosticFile(StringRef ReproCrashFilename,
285 Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple,
297 const llvm::opt::OptTable &
getOpts()
const {
return *Opts; }
309 const std::string &
getTitle() {
return DriverTitle; }
314 return ClangExecutable.c_str();
319 if (!InstalledDir.empty())
320 return InstalledDir.c_str();
324 InstalledDir =
Value;
364 bool &ContainsError);
373 void BuildInputs(
const ToolChain &TC, llvm::opt::DerivedArgList &Args,
382 void BuildActions(
Compilation &C, llvm::opt::DerivedArgList &Args,
411 void generateCompilationDiagnostics(
Compilation &C,
412 const Command &FailingCommand);
424 void PrintHelp(
bool ShowHidden)
const;
427 void PrintVersion(
const Compilation &C, raw_ostream &OS)
const;
435 std::string GetFilePath(StringRef Name,
const ToolChain &TC)
const;
443 std::string GetProgramPath(StringRef Name,
const ToolChain &TC)
const;
447 void handleAutocompletions(StringRef PassedFlags)
const;
467 StringRef BoundArch,
bool AtTopLevel,
bool MultipleArchs,
468 const char *LinkingOutput,
469 std::map<std::pair<const Action *, std::string>,
InputInfo>
474 const char *getDefaultImageName()
const;
489 const char *BaseInput, StringRef BoundArch,
490 bool AtTopLevel,
bool MultipleArchs,
491 StringRef NormalizedTriple)
const;
497 std::string GetTemporaryPath(StringRef Prefix, StringRef Suffix)
const;
500 std::string GetClPchPath(
Compilation &C, StringRef BaseName)
const;
504 bool ShouldUseClangCompiler(
const JobAction &JA)
const;
517 bool loadConfigFile();
523 bool readConfigFile(StringRef FileName);
527 void setDriverModeFromOption(StringRef Opt);
531 void setLTOMode(
const llvm::opt::ArgList &Args);
537 const ToolChain &getToolChain(
const llvm::opt::ArgList &Args,
538 const llvm::Triple &Target)
const;
544 std::pair<unsigned, unsigned> getIncludeExcludeOptionFlagMasks()
const;
551 bool AtTopLevel,
bool MultipleArchs,
const char *LinkingOutput,
552 std::map<std::pair<const Action *, std::string>,
InputInfo>
564 static bool GetReleaseVersion(StringRef Str,
unsigned &Major,
unsigned &Minor,
565 unsigned &Micro,
bool &HadExtra);
573 static bool GetReleaseVersion(StringRef Str,
ID
ID - Ordered values for successive stages in the compilation process which interact with user options...
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
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.
bool isUsingLTO() const
Returns true if we are performing any kind of LTO.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
std::string DyldPrefix
Dynamic loader prefix, if present.
bool embedBitcodeEnabled() const
LTOKind getLTOMode() const
Get the specific kind of LTO being performed.
DiagnosticBuilder Diag(unsigned DiagID) const
The virtual file system interface.
bool embedBitcodeMarkerOnly() const
unsigned CCLogDiagnostics
Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics to CCLogDiagnosticsFilename...
const std::string & getTitle()
std::string Dir
The path the driver executable was in, as invoked from the command line.
Action - Represent an abstract compilation step to perform.
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 isOptimizationLevelFast(const llvm::opt::ArgList &Args)
void setTargetAndMode(const ParsedClangName &TM)
Defines the Diagnostic-related interfaces.
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
An unknown OpenMP runtime.
const char * CCPrintOptionsFilename
The file to log CC_PRINT_OPTIONS output to, if enabled.
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.
unsigned GenReproducer
Force clang to emit reproducer for driver invocation.
const DiagnosticsEngine & getDiags() const
bool isSaveTempsObj() const
const std::string & getConfigFile() const
bool IsCLMode() const
Whether the driver should follow cl.exe like behavior.
unsigned CCPrintOptions
Set CC_PRINT_OPTIONS mode, which is like -v but logs the commands to CCPrintOptionsFilename or to std...
void setCheckInputsExist(bool Value)
bool embedBitcodeInObject() const
Command - An executable path/name and argument vector to execute.
vfs::FileSystem & getVFS() const
std::string InstalledDir
The path to the installed clang directory, if any.
bool CCCIsCXX() const
Whether the driver should follow g++ like behavior.
bool isSaveTempsEnabled() const
std::string UserConfigDir
User directory for config files.
void setTitle(std::string Value)
Helper structure used to pass information extracted from clang executable name such as i686-linux-and...
void EmbedBitcode(llvm::Module *M, const CodeGenOptions &CGOpts, llvm::MemoryBufferRef Buf)
Dataflow Directional Tag Classes.
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.
const std::string & getCCCGenericGCCName() const
Name to use when invoking gcc/g++.
std::string SysRoot
sysroot, if present
std::string Name
The name the driver was invoked as.
ParsedClangName ClangNameParts
Target and driver mode components extracted from clang executable name.
bool getCheckInputsExist() const
const char * getInstalledDir() const
Get the path to where the clang executable was installed.
std::string ClangExecutable
The original path to the clang executable.
Compilation - A set of tasks to perform for a single driver invocation.
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.
LTOKind
Describes the kind of LTO mode selected via -f(no-)?lto(=.*)? options.
const llvm::opt::OptTable & getOpts() const
const char * getClangProgramPath() const
Get the path to the main clang executable.
std::string DriverTitle
Driver title to use with help.
bool CCCIsCPP() const
Whether the driver is just the preprocessor.
void setInstalledDir(StringRef Value)
bool CCCIsCC() const
Whether the driver should follow gcc like behavior.
unsigned CCGenDiagnostics
Whether the driver is generating diagnostics for debugging purposes.
std::string SystemConfigDir
System directory for config files.
std::string ResourceDir
The path to the compiler resource directory.