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 TargetTriple;
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 TargetTriple,
297 const llvm::opt::OptTable &
getOpts()
const {
return *Opts; }
309 const std::string &
getTitle() {
return DriverTitle; }
316 return ClangExecutable.c_str();
321 if (!InstalledDir.empty())
322 return InstalledDir.c_str();
326 InstalledDir =
Value;
366 bool &ContainsError);
375 void BuildInputs(
const ToolChain &TC, llvm::opt::DerivedArgList &Args,
384 void BuildActions(
Compilation &C, llvm::opt::DerivedArgList &Args,
419 void generateCompilationDiagnostics(
421 StringRef AdditionalInformation =
"",
434 void PrintHelp(
bool ShowHidden)
const;
437 void PrintVersion(
const Compilation &C, raw_ostream &OS)
const;
445 std::string GetFilePath(StringRef Name,
const ToolChain &TC)
const;
453 std::string GetProgramPath(StringRef Name,
const ToolChain &TC)
const;
457 void HandleAutocompletions(StringRef PassedFlags)
const;
469 Action *ConstructPhaseAction(
479 StringRef BoundArch,
bool AtTopLevel,
bool MultipleArchs,
480 const char *LinkingOutput,
481 std::map<std::pair<const Action *, std::string>,
InputInfo>
486 const char *getDefaultImageName()
const;
501 const char *BaseInput, StringRef BoundArch,
502 bool AtTopLevel,
bool MultipleArchs,
503 StringRef NormalizedTriple)
const;
509 std::string GetTemporaryPath(StringRef Prefix, StringRef Suffix)
const;
512 std::string GetClPchPath(
Compilation &C, StringRef BaseName)
const;
516 bool ShouldUseClangCompiler(
const JobAction &JA)
const;
529 bool loadConfigFile();
535 bool readConfigFile(StringRef FileName);
539 void setDriverModeFromOption(StringRef Opt);
543 void setLTOMode(
const llvm::opt::ArgList &Args);
549 const ToolChain &getToolChain(
const llvm::opt::ArgList &Args,
550 const llvm::Triple &
Target)
const;
556 std::pair<unsigned, unsigned> getIncludeExcludeOptionFlagMasks()
const;
563 bool AtTopLevel,
bool MultipleArchs,
const char *LinkingOutput,
564 std::map<std::pair<const Action *, std::string>,
InputInfo>
576 static bool GetReleaseVersion(StringRef Str,
unsigned &Major,
unsigned &Minor,
577 unsigned &Micro,
bool &HadExtra);
585 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
std::string getTargetTriple() const
LTOKind getLTOMode() const
Get the specific kind of LTO being performed.
DiagnosticBuilder Diag(unsigned DiagID) const
The virtual file system interface.
Contains the files in the compilation diagnostic report generated by generateCompilationDiagnostics.
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.
llvm::SmallVector< std::string, 4 > TemporaryFiles
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.