9 #ifndef LLVM_CLANG_DRIVER_DRIVER_H 10 #define LLVM_CLANG_DRIVER_DRIVER_H 20 #include "llvm/ADT/StringMap.h" 21 #include "llvm/ADT/StringRef.h" 22 #include "llvm/Option/Arg.h" 23 #include "llvm/Option/ArgList.h" 24 #include "llvm/Support/StringSaver.h" 78 enum BitcodeEmbedMode {
110 return Diags.
Report(DiagID);
179 bool CCCIsCC()
const {
return Mode == GCCMode; }
212 CC1ToolFunc CC1Main =
nullptr;
216 std::string TargetTriple;
219 std::string CCCGenericGCCName;
222 std::string ConfigFile;
225 llvm::BumpPtrAllocator Alloc;
228 llvm::StringSaver Saver;
231 std::unique_ptr<llvm::opt::InputArgList> CfgOptions;
234 std::unique_ptr<llvm::opt::InputArgList> CLOptions;
238 unsigned CheckInputsExist : 1;
248 unsigned SuppressMissingInputWarning : 1;
255 mutable llvm::StringMap<std::unique_ptr<ToolChain>> ToolChains;
260 llvm::opt::DerivedArgList *
261 TranslateInputArgs(
const llvm::opt::InputArgList &Args)
const;
268 phases::ID getFinalPhase(
const llvm::opt::DerivedArgList &DAL,
269 llvm::opt::Arg **FinalPhaseArg =
nullptr)
const;
273 void handleArguments(
Compilation &C, llvm::opt::DerivedArgList &Args,
279 void generatePrefixedToolNames(StringRef
Tool,
const ToolChain &TC,
293 bool getCrashDiagnosticFile(StringRef ReproCrashFilename,
300 static std::string GetResourcesPath(StringRef BinaryPath,
301 StringRef CustomResourceDir =
"");
303 Driver(StringRef ClangExecutable, StringRef TargetTriple,
319 llvm::vfs::FileSystem &
getVFS()
const {
return *VFS; }
327 const std::string &
getTitle() {
return DriverTitle; }
334 return ClangExecutable.c_str();
339 if (!InstalledDir.empty())
340 return InstalledDir.c_str();
344 InstalledDir =
Value;
385 bool &ContainsError);
394 void BuildInputs(
const ToolChain &TC, llvm::opt::DerivedArgList &Args,
403 void BuildActions(
Compilation &C, llvm::opt::DerivedArgList &Args,
418 bool DiagnoseInputExistence(
const llvm::opt::DerivedArgList &Args,
420 bool TypoCorrect)
const;
446 void generateCompilationDiagnostics(
448 StringRef AdditionalInformation =
"",
461 void PrintHelp(
bool ShowHidden)
const;
464 void PrintVersion(
const Compilation &C, raw_ostream &OS)
const;
472 std::string GetFilePath(StringRef Name,
const ToolChain &TC)
const;
480 std::string GetProgramPath(StringRef Name,
const ToolChain &TC)
const;
484 void HandleAutocompletions(StringRef PassedFlags)
const;
496 Action *ConstructPhaseAction(
506 StringRef BoundArch,
bool AtTopLevel,
bool MultipleArchs,
507 const char *LinkingOutput,
508 std::map<std::pair<const Action *, std::string>,
InputInfo>
513 const char *getDefaultImageName()
const;
528 const char *BaseInput, StringRef BoundArch,
529 bool AtTopLevel,
bool MultipleArchs,
530 StringRef NormalizedTriple)
const;
536 std::string GetTemporaryPath(StringRef Prefix, StringRef Suffix)
const;
540 std::string GetTemporaryDirectory(StringRef Prefix)
const;
543 std::string GetClPchPath(
Compilation &C, StringRef BaseName)
const;
547 bool ShouldUseClangCompiler(
const JobAction &JA)
const;
551 bool ShouldUseFlangCompiler(
const JobAction &JA)
const;
564 bool loadConfigFile();
570 bool readConfigFile(StringRef FileName);
574 void setDriverModeFromOption(StringRef Opt);
578 void setLTOMode(
const llvm::opt::ArgList &Args);
584 const ToolChain &getToolChain(
const llvm::opt::ArgList &Args,
585 const llvm::Triple &
Target)
const;
591 std::pair<unsigned, unsigned> getIncludeExcludeOptionFlagMasks(
bool IsClCompatMode)
const;
598 bool AtTopLevel,
bool MultipleArchs,
const char *LinkingOutput,
599 std::map<std::pair<const Action *, std::string>,
InputInfo>
611 static bool GetReleaseVersion(StringRef Str,
unsigned &Major,
unsigned &Minor,
612 unsigned &Micro,
bool &HadExtra);
620 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.
const llvm::opt::OptTable & getDriverOptTable()
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.
bool IsFlangMode() const
Whether the driver should invoke flang for fortran inputs.
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.
bool willEmitRemarks(const llvm::opt::ArgList &Args)
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.