9 #ifndef LLVM_CLANG_DRIVER_DRIVER_H 10 #define LLVM_CLANG_DRIVER_DRIVER_H 19 #include "llvm/ADT/StringMap.h" 20 #include "llvm/ADT/StringRef.h" 21 #include "llvm/Option/ArgList.h" 22 #include "llvm/Support/StringSaver.h" 58 std::unique_ptr<llvm::opt::OptTable> Opts;
77 enum BitcodeEmbedMode {
109 return Diags.
Report(DiagID);
178 bool CCCIsCC()
const {
return Mode == GCCMode; }
204 std::string TargetTriple;
207 std::string CCCGenericGCCName;
210 std::string ConfigFile;
213 llvm::BumpPtrAllocator Alloc;
216 llvm::StringSaver Saver;
219 std::unique_ptr<llvm::opt::InputArgList> CfgOptions;
222 std::unique_ptr<llvm::opt::InputArgList> CLOptions;
226 unsigned CheckInputsExist : 1;
236 unsigned SuppressMissingInputWarning : 1;
243 mutable llvm::StringMap<std::unique_ptr<ToolChain>> ToolChains;
248 llvm::opt::DerivedArgList *
249 TranslateInputArgs(
const llvm::opt::InputArgList &Args)
const;
253 phases::ID getFinalPhase(
const llvm::opt::DerivedArgList &DAL,
254 llvm::opt::Arg **FinalPhaseArg =
nullptr)
const;
259 void generatePrefixedToolNames(StringRef
Tool,
const ToolChain &TC,
273 bool getCrashDiagnosticFile(StringRef ReproCrashFilename,
280 static std::string GetResourcesPath(StringRef BinaryPath,
281 StringRef CustomResourceDir =
"");
283 Driver(StringRef ClangExecutable, StringRef TargetTriple,
295 const llvm::opt::OptTable &
getOpts()
const {
return *Opts; }
299 llvm::vfs::FileSystem &
getVFS()
const {
return *VFS; }
307 const std::string &
getTitle() {
return DriverTitle; }
314 return ClangExecutable.c_str();
319 if (!InstalledDir.empty())
320 return InstalledDir.c_str();
324 InstalledDir =
Value;
365 bool &ContainsError);
374 void BuildInputs(
const ToolChain &TC, llvm::opt::DerivedArgList &Args,
383 void BuildActions(
Compilation &C, llvm::opt::DerivedArgList &Args,
398 bool DiagnoseInputExistence(
const llvm::opt::DerivedArgList &Args,
400 bool TypoCorrect)
const;
426 void generateCompilationDiagnostics(
428 StringRef AdditionalInformation =
"",
441 void PrintHelp(
bool ShowHidden)
const;
444 void PrintVersion(
const Compilation &C, raw_ostream &OS)
const;
452 std::string GetFilePath(StringRef Name,
const ToolChain &TC)
const;
460 std::string GetProgramPath(StringRef Name,
const ToolChain &TC)
const;
464 void HandleAutocompletions(StringRef PassedFlags)
const;
476 Action *ConstructPhaseAction(
486 StringRef BoundArch,
bool AtTopLevel,
bool MultipleArchs,
487 const char *LinkingOutput,
488 std::map<std::pair<const Action *, std::string>,
InputInfo>
493 const char *getDefaultImageName()
const;
508 const char *BaseInput, StringRef BoundArch,
509 bool AtTopLevel,
bool MultipleArchs,
510 StringRef NormalizedTriple)
const;
516 std::string GetTemporaryPath(StringRef Prefix, StringRef Suffix)
const;
520 std::string GetTemporaryDirectory(StringRef Prefix)
const;
523 std::string GetClPchPath(
Compilation &C, StringRef BaseName)
const;
527 bool ShouldUseClangCompiler(
const JobAction &JA)
const;
540 bool loadConfigFile();
546 bool readConfigFile(StringRef FileName);
550 void setDriverModeFromOption(StringRef Opt);
554 void setLTOMode(
const llvm::opt::ArgList &Args);
560 const ToolChain &getToolChain(
const llvm::opt::ArgList &Args,
561 const llvm::Triple &
Target)
const;
567 std::pair<unsigned, unsigned> getIncludeExcludeOptionFlagMasks(
bool IsClCompatMode)
const;
574 bool AtTopLevel,
bool MultipleArchs,
const char *LinkingOutput,
575 std::map<std::pair<const Action *, std::string>,
InputInfo>
587 static bool GetReleaseVersion(StringRef Str,
unsigned &Major,
unsigned &Minor,
588 unsigned &Micro,
bool &HadExtra);
596 static bool GetReleaseVersion(StringRef Str,
ID
ID - Ordered values for successive stages in the compilation process which interact with user options...
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
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.