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" 59 std::unique_ptr<llvm::opt::OptTable> Opts;
78 enum BitcodeEmbedMode {
110 return Diags.
Report(DiagID);
179 bool CCCIsCC()
const {
return Mode == GCCMode; }
205 std::string TargetTriple;
208 std::string CCCGenericGCCName;
211 std::string ConfigFile;
214 llvm::BumpPtrAllocator Alloc;
217 llvm::StringSaver Saver;
220 std::unique_ptr<llvm::opt::InputArgList> CfgOptions;
223 std::unique_ptr<llvm::opt::InputArgList> CLOptions;
227 unsigned CheckInputsExist : 1;
237 unsigned SuppressMissingInputWarning : 1;
239 std::list<std::string> TempFiles;
240 std::list<std::string> ResultFiles;
247 mutable llvm::StringMap<std::unique_ptr<ToolChain>> ToolChains;
252 llvm::opt::DerivedArgList *
253 TranslateInputArgs(
const llvm::opt::InputArgList &Args)
const;
257 phases::ID getFinalPhase(
const llvm::opt::DerivedArgList &DAL,
258 llvm::opt::Arg **FinalPhaseArg =
nullptr)
const;
263 void generatePrefixedToolNames(StringRef
Tool,
const ToolChain &TC,
277 bool getCrashDiagnosticFile(StringRef ReproCrashFilename,
281 Driver(StringRef ClangExecutable, StringRef TargetTriple,
293 const llvm::opt::OptTable &
getOpts()
const {
return *Opts; }
297 llvm::vfs::FileSystem &
getVFS()
const {
return *VFS; }
305 const std::string &
getTitle() {
return DriverTitle; }
312 return ClangExecutable.c_str();
317 if (!InstalledDir.empty())
318 return InstalledDir.c_str();
322 InstalledDir =
Value;
363 bool &ContainsError);
372 void BuildInputs(
const ToolChain &TC, llvm::opt::DerivedArgList &Args,
381 void BuildActions(
Compilation &C, llvm::opt::DerivedArgList &Args,
416 void generateCompilationDiagnostics(
418 StringRef AdditionalInformation =
"",
431 void PrintHelp(
bool ShowHidden)
const;
434 void PrintVersion(
const Compilation &C, raw_ostream &OS)
const;
442 std::string GetFilePath(StringRef Name,
const ToolChain &TC)
const;
450 std::string GetProgramPath(StringRef Name,
const ToolChain &TC)
const;
454 void HandleAutocompletions(StringRef PassedFlags)
const;
466 Action *ConstructPhaseAction(
476 StringRef BoundArch,
bool AtTopLevel,
bool MultipleArchs,
477 const char *LinkingOutput,
478 std::map<std::pair<const Action *, std::string>,
InputInfo>
483 const char *getDefaultImageName()
const;
498 const char *BaseInput, StringRef BoundArch,
499 bool AtTopLevel,
bool MultipleArchs,
500 StringRef NormalizedTriple)
const;
506 std::string GetTemporaryPath(StringRef Prefix, StringRef Suffix)
const;
510 std::string GetTemporaryDirectory(StringRef Prefix)
const;
513 std::string GetClPchPath(
Compilation &C, StringRef BaseName)
const;
517 bool ShouldUseClangCompiler(
const JobAction &JA)
const;
530 bool loadConfigFile();
536 bool readConfigFile(StringRef FileName);
540 void setDriverModeFromOption(StringRef Opt);
544 void setLTOMode(
const llvm::opt::ArgList &Args);
550 const ToolChain &getToolChain(
const llvm::opt::ArgList &Args,
551 const llvm::Triple &
Target)
const;
557 std::pair<unsigned, unsigned> getIncludeExcludeOptionFlagMasks(
bool IsClCompatMode)
const;
564 bool AtTopLevel,
bool MultipleArchs,
const char *LinkingOutput,
565 std::map<std::pair<const Action *, std::string>,
InputInfo>
577 static bool GetReleaseVersion(StringRef Str,
unsigned &Major,
unsigned &Minor,
578 unsigned &Micro,
bool &HadExtra);
586 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...
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
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.
llvm::vfs::FileSystem & getVFS() 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.
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.
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.