clang  13.0.0git
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
clang::driver::Driver Class Reference

Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like command line arguments. More...

#include "clang/Driver/Driver.h"

Collaboration diagram for clang::driver::Driver:
Collaboration graph
[legend]

Classes

struct  CompilationDiagnosticReport
 Contains the files in the compilation diagnostic report generated by generateCompilationDiagnostics. More...
 

Public Types

enum  OpenMPRuntimeKind { OMPRT_Unknown, OMPRT_OMP, OMPRT_GOMP, OMPRT_IOMP5 }
 
typedef SmallVector< std::string, 4 > prefix_list
 A prefix directory used to emulate a limited subset of GCC's '-Bprefix' functionality. More...
 
typedef SmallVector< std::pair< types::ID, const llvm::opt::Arg * >, 16 > InputList
 A list of inputs and their types for the given arguments. More...
 
typedef int(* CC1ToolFunc) (SmallVectorImpl< const char * > &ArgV)
 Pointer to the ExecuteCC1Tool function, if available. More...
 

Public Member Functions

DiagnosticBuilder Diag (unsigned DiagID) const
 
bool CCCIsCXX () const
 Whether the driver should follow g++ like behavior. More...
 
bool CCCIsCPP () const
 Whether the driver is just the preprocessor. More...
 
bool CCCIsCC () const
 Whether the driver should follow gcc like behavior. More...
 
bool IsCLMode () const
 Whether the driver should follow cl.exe like behavior. More...
 
bool IsFlangMode () const
 Whether the driver should invoke flang for fortran inputs. More...
 
 Driver (StringRef ClangExecutable, StringRef TargetTriple, DiagnosticsEngine &Diags, std::string Title="clang LLVM compiler", IntrusiveRefCntPtr< llvm::vfs::FileSystem > VFS=nullptr)
 
Accessors
const std::stringgetCCCGenericGCCName () const
 Name to use when invoking gcc/g++. More...
 
const std::stringgetConfigFile () const
 
const llvm::opt::OptTable & getOpts () const
 
DiagnosticsEnginegetDiags () const
 
llvm::vfs::FileSystem & getVFS () const
 
bool getCheckInputsExist () const
 
void setCheckInputsExist (bool Value)
 
void setTargetAndMode (const ParsedClangName &TM)
 
const std::stringgetTitle ()
 
void setTitle (std::string Value)
 
std::string getTargetTriple () const
 
const char * getClangProgramPath () const
 Get the path to the main clang executable. More...
 
const char * getInstalledDir () const
 Get the path to where the clang executable was installed. More...
 
void setInstalledDir (StringRef Value)
 
bool isSaveTempsEnabled () const
 
bool isSaveTempsObj () const
 
bool embedBitcodeEnabled () const
 
bool embedBitcodeInObject () const
 
bool embedBitcodeMarkerOnly () const
 
OpenMPRuntimeKind getOpenMPRuntime (const llvm::opt::ArgList &Args) const
 Compute the desired OpenMP runtime from the flags provided. More...
 
Primary Functionality
void CreateOffloadingDeviceToolChains (Compilation &C, InputList &Inputs)
 CreateOffloadingDeviceToolChains - create all the toolchains required to support offloading devices given the programming models specified in the current compilation. More...
 
CompilationBuildCompilation (ArrayRef< const char * > Args)
 BuildCompilation - Construct a compilation object for a command line argument vector. More...
 
Driver Steps
void ParseDriverMode (StringRef ProgramName, ArrayRef< const char * > Args)
 ParseDriverMode - Look for and handle the driver mode option in Args. More...
 
llvm::opt::InputArgList ParseArgStrings (ArrayRef< const char * > Args, bool IsClCompatMode, bool &ContainsError)
 ParseArgStrings - Parse the given list of strings into an ArgList. More...
 
void BuildInputs (const ToolChain &TC, llvm::opt::DerivedArgList &Args, InputList &Inputs) const
 BuildInputs - Construct the list of inputs and their types from the given arguments. More...
 
void BuildActions (Compilation &C, llvm::opt::DerivedArgList &Args, const InputList &Inputs, ActionList &Actions) const
 BuildActions - Construct the list of actions to perform for the given arguments, which are only done for a single architecture. More...
 
void BuildUniversalActions (Compilation &C, const ToolChain &TC, const InputList &BAInputs) const
 BuildUniversalActions - Construct the list of actions to perform for the given arguments, which may require a universal build. More...
 
bool DiagnoseInputExistence (const llvm::opt::DerivedArgList &Args, StringRef Value, types::ID Ty, bool TypoCorrect) const
 Check that the file referenced by Value exists. More...
 
void BuildJobs (Compilation &C) const
 BuildJobs - Bind actions to concrete tools and translate arguments to form the list of jobs to run. More...
 
int ExecuteCompilation (Compilation &C, SmallVectorImpl< std::pair< int, const Command * > > &FailingCommands)
 ExecuteCompilation - Execute the compilation according to the command line arguments and return an appropriate exit code. More...
 
void generateCompilationDiagnostics (Compilation &C, const Command &FailingCommand, StringRef AdditionalInformation="", CompilationDiagnosticReport *GeneratedReport=nullptr)
 generateCompilationDiagnostics - Generate diagnostics information including preprocessed source file(s). More...
 

Static Public Member Functions

static std::string GetResourcesPath (StringRef BinaryPath, StringRef CustomResourceDir="")
 Takes the path to a binary that's either in bin/ or lib/ and returns the path to clang's resource directory. More...
 
static bool GetReleaseVersion (StringRef Str, unsigned &Major, unsigned &Minor, unsigned &Micro, bool &HadExtra)
 GetReleaseVersion - Parse (([0-9]+)(. More...
 
static bool GetReleaseVersion (StringRef Str, MutableArrayRef< unsigned > Digits)
 Parse digits from a string Str and fulfill Digits with the parsed numbers. More...
 
static bool getDefaultModuleCachePath (SmallVectorImpl< char > &Result)
 Compute the default -fmodule-cache-path. More...
 

Public Attributes

std::string Name
 The name the driver was invoked as. More...
 
std::string Dir
 The path the driver executable was in, as invoked from the command line. More...
 
std::string ClangExecutable
 The original path to the clang executable. More...
 
ParsedClangName ClangNameParts
 Target and driver mode components extracted from clang executable name. More...
 
std::string InstalledDir
 The path to the installed clang directory, if any. More...
 
std::string ResourceDir
 The path to the compiler resource directory. More...
 
std::string SystemConfigDir
 System directory for config files. More...
 
std::string UserConfigDir
 User directory for config files. More...
 
prefix_list PrefixDirs
 
std::string SysRoot
 sysroot, if present More...
 
std::string DyldPrefix
 Dynamic loader prefix, if present. More...
 
std::string DriverTitle
 Driver title to use with help. More...
 
std::string HostBits
 Information about the host which can be overridden by the user. More...
 
std::string HostMachine
 
std::string HostSystem
 
std::string HostRelease
 
std::string CCPrintStatReportFilename
 The file to log CC_PRINT_PROC_STAT_FILE output to, if enabled. More...
 
std::string CCPrintOptionsFilename
 The file to log CC_PRINT_OPTIONS output to, if enabled. More...
 
std::string CCPrintHeadersFilename
 The file to log CC_PRINT_HEADERS output to, if enabled. More...
 
std::string CCLogDiagnosticsFilename
 The file to log CC_LOG_DIAGNOSTICS output to, if enabled. More...
 
unsigned CCCPrintBindings: 1
 Only print tool bindings, don't build any jobs. More...
 
unsigned CCPrintOptions: 1
 Set CC_PRINT_OPTIONS mode, which is like -v but logs the commands to CCPrintOptionsFilename or to stderr. More...
 
unsigned CCPrintHeaders: 1
 Set CC_PRINT_HEADERS mode, which causes the frontend to log header include information to CCPrintHeadersFilename or to stderr. More...
 
unsigned CCLogDiagnostics: 1
 Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics to CCLogDiagnosticsFilename or to stderr, in a stable machine readable format. More...
 
unsigned CCGenDiagnostics: 1
 Whether the driver is generating diagnostics for debugging purposes. More...
 
unsigned CCPrintProcessStats: 1
 Set CC_PRINT_PROC_STAT mode, which causes the driver to dump performance report to CC_PRINT_PROC_STAT_FILE or to stdout. More...
 
CC1ToolFunc CC1Main = nullptr
 
unsigned GenReproducer: 1
 Force clang to emit reproducer for driver invocation. More...
 

Helper Methods

void PrintActions (const Compilation &C) const
 PrintActions - Print the list of actions. More...
 
void PrintHelp (bool ShowHidden) const
 PrintHelp - Print the help text. More...
 
void PrintVersion (const Compilation &C, raw_ostream &OS) const
 PrintVersion - Print the driver version. More...
 
std::string GetFilePath (StringRef Name, const ToolChain &TC) const
 GetFilePath - Lookup Name in the list of file search paths. More...
 
std::string GetProgramPath (StringRef Name, const ToolChain &TC) const
 GetProgramPath - Lookup Name in the list of program search paths. More...
 
void HandleAutocompletions (StringRef PassedFlags) const
 HandleAutocompletions - Handle –autocomplete by searching and printing possible flags, descriptions, and its arguments. More...
 
bool HandleImmediateArgs (const Compilation &C)
 HandleImmediateArgs - Handle any arguments which should be treated before building actions or binding tools. More...
 
ActionConstructPhaseAction (Compilation &C, const llvm::opt::ArgList &Args, phases::ID Phase, Action *Input, Action::OffloadKind TargetDeviceOffloadKind=Action::OFK_None) const
 ConstructAction - Construct the appropriate action to do for Phase on the Input, taking in to account arguments like -fsyntax-only or –analyze. More...
 
InputInfo BuildJobsForAction (Compilation &C, const Action *A, const ToolChain *TC, StringRef BoundArch, bool AtTopLevel, bool MultipleArchs, const char *LinkingOutput, std::map< std::pair< const Action *, std::string >, InputInfo > &CachedResults, Action::OffloadKind TargetDeviceOffloadKind) const
 BuildJobsForAction - Construct the jobs to perform for the action A and return an InputInfo for the result of running A. More...
 
const char * getDefaultImageName () const
 Returns the default name for linked images (e.g., "a.out"). More...
 
const char * GetNamedOutputPath (Compilation &C, const JobAction &JA, const char *BaseInput, StringRef BoundArch, bool AtTopLevel, bool MultipleArchs, StringRef NormalizedTriple) const
 GetNamedOutputPath - Return the name to use for the output of the action JA. More...
 
std::string GetTemporaryPath (StringRef Prefix, StringRef Suffix) const
 GetTemporaryPath - Return the pathname of a temporary file to use as part of compilation; the file will have the given prefix and suffix. More...
 
std::string GetTemporaryDirectory (StringRef Prefix) const
 GetTemporaryDirectory - Return the pathname of a temporary directory to use as part of compilation; the directory will have the given prefix. More...
 
std::string GetClPchPath (Compilation &C, StringRef BaseName) const
 Return the pathname of the pch file in clang-cl mode. More...
 
bool ShouldUseClangCompiler (const JobAction &JA) const
 ShouldUseClangCompiler - Should the clang compiler be used to handle this action. More...
 
bool ShouldUseFlangCompiler (const JobAction &JA) const
 ShouldUseFlangCompiler - Should the flang compiler be used to handle this action. More...
 
bool ShouldEmitStaticLibrary (const llvm::opt::ArgList &Args) const
 ShouldEmitStaticLibrary - Should the linker emit a static library. More...
 
bool isUsingLTO () const
 Returns true if we are performing any kind of LTO. More...
 
LTOKind getLTOMode () const
 Get the specific kind of LTO being performed. More...
 

Detailed Description

Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like command line arguments.

Definition at line 59 of file Driver.h.

Member Typedef Documentation

◆ CC1ToolFunc

typedef int(* clang::driver::Driver::CC1ToolFunc) (SmallVectorImpl< const char * > &ArgV)

Pointer to the ExecuteCC1Tool function, if available.

When the clangDriver lib is used through clang.exe, this provides a shortcut for executing the -cc1 command-line directly, in the same process.

Definition at line 218 of file Driver.h.

◆ InputList

typedef SmallVector<std::pair<types::ID, const llvm::opt::Arg *>, 16> clang::driver::Driver::InputList

A list of inputs and their types for the given arguments.

Definition at line 173 of file Driver.h.

◆ prefix_list

A prefix directory used to emulate a limited subset of GCC's '-Bprefix' functionality.

FIXME: This type of customization should be removed in favor of the universal driver when it is ready.

Definition at line 144 of file Driver.h.

Member Enumeration Documentation

◆ OpenMPRuntimeKind

Enumerator
OMPRT_Unknown 

An unknown OpenMP runtime.

We can't generate effective OpenMP code without knowing what runtime to target.

OMPRT_OMP 

The LLVM OpenMP runtime.

When completed and integrated, this will become the default for Clang.

OMPRT_GOMP 

The GNU OpenMP runtime.

Clang doesn't support generating OpenMP code for this runtime but can swallow the pragmas, and find and link against the runtime library itself.

OMPRT_IOMP5 

The legacy name for the LLVM OpenMP runtime from when it was the Intel OpenMP runtime.

We support this mode for users with existing dependencies on this runtime library name.

Definition at line 88 of file Driver.h.

Constructor & Destructor Documentation

◆ Driver()

Driver::Driver ( StringRef  ClangExecutable,
StringRef  TargetTriple,
DiagnosticsEngine Diags,
std::string  Title = "clang LLVM compiler",
IntrusiveRefCntPtr< llvm::vfs::FileSystem >  VFS = nullptr 
)

Member Function Documentation

◆ BuildActions()

void Driver::BuildActions ( Compilation C,
llvm::opt::DerivedArgList &  Args,
const InputList Inputs,
ActionList Actions 
) const

BuildActions - Construct the list of actions to perform for the given arguments, which are only done for a single architecture.

Parameters
C- The compilation that is being built.
Args- The input arguments.
Actions- The list to store the resulting actions onto.

Definition at line 3617 of file Driver.cpp.

References Diag(), clang::driver::types::getCompilationPhases(), and V.

Referenced by BuildUniversalActions(), and generateCompilationDiagnostics().

◆ BuildCompilation()

Compilation * Driver::BuildCompilation ( ArrayRef< const char * >  Args)

BuildCompilation - Construct a compilation object for a command line argument vector.

Returns
A compilation, or 0 if none was built for the given argument vector. A null return value does not necessarily indicate an error condition, the diagnostics should be queried to determine if an error occurred.

Definition at line 993 of file Driver.cpp.

References ClangExecutable, IsCLMode(), ParseArgStrings(), and ParseDriverMode().

Referenced by clang::createInvocationFromCommandLine().

◆ BuildInputs()

void Driver::BuildInputs ( const ToolChain TC,
llvm::opt::DerivedArgList &  Args,
InputList Inputs 
) const

BuildInputs - Construct the list of inputs and their types from the given arguments.

Parameters
TC- The default host tool chain.
Args- The input arguments.
Inputs- The list to store the resulting compilation inputs onto.

Definition at line 2164 of file Driver.cpp.

References CCCIsCPP(), CCCIsCXX(), Diag(), DiagnoseInputExistence(), clang::driver::Action::getKind(), getOpts(), clang::driver::types::getTypeName(), IsCLMode(), IsFlangMode(), clang::driver::options::LinkerInput, clang::driver::types::lookupCXXTypeForCType(), clang::driver::ToolChain::LookupTypeForExtension(), clang::driver::types::lookupTypeForTypeSpecifier(), MakeInputArg(), Previous, and clang::driver::types::TY_INVALID.

Referenced by generateCompilationDiagnostics().

◆ BuildJobs()

void Driver::BuildJobs ( Compilation C) const

◆ BuildJobsForAction()

InputInfo Driver::BuildJobsForAction ( Compilation C,
const Action A,
const ToolChain TC,
StringRef  BoundArch,
bool  AtTopLevel,
bool  MultipleArchs,
const char *  LinkingOutput,
std::map< std::pair< const Action *, std::string >, InputInfo > &  CachedResults,
Action::OffloadKind  TargetDeviceOffloadKind 
) const

BuildJobsForAction - Construct the jobs to perform for the action A and return an InputInfo for the result of running A.

Will only construct jobs for a given (Action, ToolChain, BoundArch, DeviceKind) tuple once.

Definition at line 4459 of file Driver.cpp.

References GetTriplePlusArchString().

Referenced by BuildJobs().

◆ BuildUniversalActions()

void Driver::BuildUniversalActions ( Compilation C,
const ToolChain TC,
const InputList BAInputs 
) const

BuildUniversalActions - Construct the list of actions to perform for the given arguments, which may require a universal build.

Parameters
C- The compilation that is being built.
TC- The default host tool chain.

Definition at line 2027 of file Driver.cpp.

References BuildActions(), clang::driver::types::canLipoType(), ContainsCompileOrAssembleAction(), Diag(), clang::driver::tools::darwin::getArchTypeForMachOArchName(), clang::driver::ToolChain::getDefaultUniversalArchName(), clang::driver::types::getTypeName(), and clang::driver::willEmitRemarks().

Referenced by generateCompilationDiagnostics().

◆ CCCIsCC()

bool clang::driver::Driver::CCCIsCC ( ) const
inline

Whether the driver should follow gcc like behavior.

Definition at line 182 of file Driver.h.

◆ CCCIsCPP()

bool clang::driver::Driver::CCCIsCPP ( ) const
inline

Whether the driver is just the preprocessor.

Definition at line 179 of file Driver.h.

Referenced by BuildInputs(), CheckPreprocessingOptions(), and clang::driver::types::getCompilationPhases().

◆ CCCIsCXX()

bool clang::driver::Driver::CCCIsCXX ( ) const
inline

◆ ConstructPhaseAction()

Action * Driver::ConstructPhaseAction ( Compilation C,
const llvm::opt::ArgList &  Args,
phases::ID  Phase,
Action Input,
Action::OffloadKind  TargetDeviceOffloadKind = Action::OFK_None 
) const

◆ CreateOffloadingDeviceToolChains()

void Driver::CreateOffloadingDeviceToolChains ( Compilation C,
InputList Inputs 
)

CreateOffloadingDeviceToolChains - create all the toolchains required to support offloading devices given the programming models specified in the current compilation.

Also, update the host tool chain kind accordingly.

Definition at line 648 of file Driver.cpp.

References Diag(), getHIPOffloadTargetTriple(), getOpenMPRuntime(), clang::driver::ToolChain::getTriple(), clang::driver::types::isCuda(), clang::driver::types::isHIP(), clang::driver::Action::OFK_Cuda, clang::driver::Action::OFK_HIP, clang::driver::Action::OFK_Host, clang::driver::Action::OFK_OpenMP, OMPRT_IOMP5, OMPRT_OMP, and string().

◆ Diag()

DiagnosticBuilder clang::driver::Driver::Diag ( unsigned  DiagID) const
inline

Definition at line 109 of file Driver.h.

References clang::DiagnosticsEngine::Report().

Referenced by clang::driver::SanitizerArgs::addArgs(), clang::driver::toolchains::DarwinClang::AddClangCXXStdlibIncludeArgs(), clang::driver::toolchains::ROCMToolChain::addClangTargetOptions(), clang::driver::toolchains::CudaToolChain::addClangTargetOptions(), addCoveragePrefixMapArg(), clang::driver::CudaInstallationDetector::AddCudaIncludeArgs(), addDebugPrefixMapArg(), addDefaultBlacklists(), clang::driver::RocmInstallationDetector::AddHIPIncludeArgs(), clang::driver::tools::addLinkerCompressDebugSectionsOption(), clang::driver::toolchains::DarwinClang::AddLinkRuntimeLibArgs(), clang::driver::tools::addMachineOutlinerArgs(), addMacroPrefixMapArg(), clang::driver::tools::addOpenMPDeviceRTL(), addPGOAndCoverageFlags(), addPgProfilingLinkArgs(), clang::driver::tools::ClangAs::AddX86TargetArgs(), clang::driver::toolchains::AVRToolChain::AVRToolChain(), BuildActions(), clang::driver::toolchains::MSVCToolChain::buildAssembler(), BuildInputs(), BuildJobs(), BuildUniversalActions(), checkARMArchName(), checkARMCPUName(), CheckCodeGenerationOptions(), clang::driver::CudaInstallationDetector::CheckCudaVersionSupportsArch(), checkDebugInfoOption(), clang::driver::toolchains::Darwin::CheckObjCARC(), CheckPreprocessingOptions(), checkRemarksOptions(), clang::driver::toolchains::AMDGPUToolChain::checkTargetID(), clang::driver::Compilation::CleanupFile(), CollectArgsForIntegratedAssembler(), clang::driver::ToolChain::computeMSVCVersion(), computeTargetTriple(), clang::driver::tools::wasm::Linker::ConstructJob(), clang::driver::tools::hexagon::Assembler::ConstructJob(), clang::driver::tools::nacltools::Linker::ConstructJob(), clang::driver::tools::PS4cpu::Link::ConstructJob(), clang::driver::tools::gnutools::Linker::ConstructJob(), clang::driver::tools::gnutools::StaticLibTool::ConstructJob(), clang::driver::tools::gcc::Common::ConstructJob(), clang::driver::tools::Clang::ConstructJob(), CreateOffloadingDeviceToolChains(), DecodeAArch64Features(), DiagnoseInputExistence(), clang::driver::Compilation::ExecuteCommand(), ExecuteCompilation(), generateCompilationDiagnostics(), getArchFeatures(), getARMFPUFeatures(), getARMHWDivFeatures(), clang::driver::toolchains::MipsLLVMToolChain::GetCXXStdlibType(), clang::driver::toolchains::NaClToolChain::GetCXXStdlibType(), clang::driver::toolchains::Fuchsia::GetCXXStdlibType(), clang::driver::toolchains::HexagonToolChain::GetCXXStdlibType(), clang::driver::ToolChain::GetCXXStdlibType(), getDebugFissionKind(), getExtensionFeatures(), getExtensionVersion(), clang::driver::toolchains::HIPToolChain::getHIPDeviceLibs(), clang::driver::tools::wasm::Linker::getLinkerPath(), clang::driver::ToolChain::GetLinkerPath(), GetNamedOutputPath(), getOpenMPRuntime(), clang::driver::tools::getOrCheckAMDGPUCodeObjectVersion(), getRISCFeaturesFromMcpu(), clang::driver::toolchains::Fuchsia::GetRuntimeLibType(), clang::driver::toolchains::DarwinClang::GetRuntimeLibType(), clang::driver::ToolChain::GetRuntimeLibType(), getStaticPIE(), clang::driver::tools::getStatsFileName(), GetTemporaryDirectory(), GetTemporaryPath(), clang::driver::ToolChain::GetUnwindLibType(), handleHVXTargetFeatures(), handleHVXWarnings(), clang::driver::toolchains::MyriadToolChain::MyriadToolChain(), ParseArgStrings(), parseArgValues(), parseClangCLEHFlags(), parseCoverageFeatures(), ParseMPreferVectorWidth(), ParseMRecip(), parseSpecialCaseListArg(), clang::driver::toolchains::PS4CPU::PS4CPU(), RenderARCMigrateToolOptions(), RenderDebugInfoCompressionArgs(), renderDebugOptions(), RenderDiagnosticsOptions(), renderDwarfFormat(), clang::driver::tools::gcc::Compiler::RenderExtraToolArgs(), RenderFloatingPointOptions(), RenderModulesOptions(), RenderObjCOptions(), RenderSSPOptions(), RenderTrivialAutoVarInitOptions(), clang::driver::RocmInstallationDetector::RocmInstallationDetector(), clang::driver::SanitizerArgs::SanitizerArgs(), SetRISCVSmallDataLimit(), clang::driver::toolchains::Darwin::TranslateArgs(), validateSpecialCaseListFormat(), and clang::driver::XRayArgs::XRayArgs().

◆ DiagnoseInputExistence()

bool Driver::DiagnoseInputExistence ( const llvm::opt::DerivedArgList &  Args,
StringRef  Value,
types::ID  Ty,
bool  TypoCorrect 
) const

Check that the file referenced by Value exists.

If it doesn't, issue a diagnostic and return false. If TypoCorrect is true and the file does not exist, see if it looks like a likely typo for a flag and if so print a "did you mean" blurb.

Definition at line 2115 of file Driver.cpp.

References Diag(), getCheckInputsExist(), getOpts(), getVFS(), IsCLMode(), and string().

Referenced by BuildInputs().

◆ embedBitcodeEnabled()

bool clang::driver::Driver::embedBitcodeEnabled ( ) const
inline

Definition at line 355 of file Driver.h.

◆ embedBitcodeInObject()

bool clang::driver::Driver::embedBitcodeInObject ( ) const
inline

Definition at line 356 of file Driver.h.

◆ embedBitcodeMarkerOnly()

bool clang::driver::Driver::embedBitcodeMarkerOnly ( ) const
inline

Definition at line 357 of file Driver.h.

◆ ExecuteCompilation()

int Driver::ExecuteCompilation ( Compilation C,
SmallVectorImpl< std::pair< int, const Command * > > &  FailingCommands 
)

ExecuteCompilation - Execute the compilation according to the command line arguments and return an appropriate exit code.

This routine handles additional processing that must be done in addition to just running the subprocesses, for example reporting errors, setting up response files, removing temporary files, etc.

Definition at line 1518 of file Driver.cpp.

References Diag(), clang::driver::Command::getCreator(), clang::driver::Tool::getShortName(), clang::driver::Command::getSource(), clang::DiagnosticsEngine::hasErrorOccurred(), clang::driver::Tool::hasGoodDiagnostics(), and isSaveTempsEnabled().

◆ generateCompilationDiagnostics()

void Driver::generateCompilationDiagnostics ( Compilation C,
const Command FailingCommand,
StringRef  AdditionalInformation = "",
CompilationDiagnosticReport GeneratedReport = nullptr 
)

◆ getCCCGenericGCCName()

const std::string& clang::driver::Driver::getCCCGenericGCCName ( ) const
inline

Name to use when invoking gcc/g++.

Definition at line 318 of file Driver.h.

Referenced by clang::driver::tools::gcc::Common::ConstructJob().

◆ getCheckInputsExist()

bool clang::driver::Driver::getCheckInputsExist ( ) const
inline

Definition at line 328 of file Driver.h.

Referenced by DiagnoseInputExistence().

◆ getClangProgramPath()

const char* clang::driver::Driver::getClangProgramPath ( ) const
inline

Get the path to the main clang executable.

Definition at line 340 of file Driver.h.

References ClangExecutable.

Referenced by clang::driver::tools::Clang::ConstructJob(), and clang::driver::tools::ClangAs::ConstructJob().

◆ GetClPchPath()

std::string Driver::GetClPchPath ( Compilation C,
StringRef  BaseName 
) const

Return the pathname of the pch file in clang-cl mode.

Definition at line 5147 of file Driver.cpp.

References string().

Referenced by GetNamedOutputPath().

◆ getConfigFile()

const std::string& clang::driver::Driver::getConfigFile ( ) const
inline

Definition at line 320 of file Driver.h.

◆ getDefaultImageName()

const char * Driver::getDefaultImageName ( ) const

Returns the default name for linked images (e.g., "a.out").

Definition at line 4754 of file Driver.cpp.

References normalize(), and clang::Target.

Referenced by BuildJobs(), and GetNamedOutputPath().

◆ getDefaultModuleCachePath()

bool Driver::getDefaultModuleCachePath ( SmallVectorImpl< char > &  Result)
static

Compute the default -fmodule-cache-path.

Returns
True if the system provides a default cache directory.

Definition at line 3362 of file Clang.cpp.

Referenced by RenderModulesOptions().

◆ getDiags()

DiagnosticsEngine& clang::driver::Driver::getDiags ( ) const
inline

◆ GetFilePath()

std::string Driver::GetFilePath ( StringRef  Name,
const ToolChain TC 
) const

GetFilePath - Lookup Name in the list of file search paths.

Parameters
TC- The tool chain for additional information on directories to search.

Definition at line 5023 of file Driver.cpp.

Referenced by HandleImmediateArgs().

◆ getInstalledDir()

const char* clang::driver::Driver::getInstalledDir ( ) const
inline

◆ getLTOMode()

LTOKind clang::driver::Driver::getLTOMode ( ) const
inline

◆ GetNamedOutputPath()

const char * Driver::GetNamedOutputPath ( Compilation C,
const JobAction JA,
const char *  BaseInput,
StringRef  BoundArch,
bool  AtTopLevel,
bool  MultipleArchs,
StringRef  NormalizedTriple 
) const

GetNamedOutputPath - Return the name to use for the output of the action JA.

The result is appended to the compilation's list of temporary or result files, as appropriate.

Parameters
C- The compilation.
JA- The action of interest.
BaseInput- The original input file that this action was triggered by.
BoundArch- The bound architecture.
AtTopLevel- Whether this is a "top-level" action.
MultipleArchs- Whether multiple -arch options were supplied.
NormalizedTriple- The normalized triple of the relevant target.

Definition at line 4803 of file Driver.cpp.

References clang::driver::types::appendSuffixForType(), CCGenDiagnostics, Diag(), End, GetClPchPath(), getDefaultImageName(), clang::driver::Action::getOffloadingDeviceKind(), GetTemporaryPath(), clang::driver::Action::getType(), clang::driver::types::getTypeTempSuffix(), getVFS(), HasPreprocessOutput(), IsCLMode(), isSaveTempsEnabled(), isSaveTempsObj(), MakeCLOutputFilename(), Name, clang::driver::Action::OFK_HIP, Split, and string().

◆ getOpenMPRuntime()

Driver::OpenMPRuntimeKind Driver::getOpenMPRuntime ( const llvm::opt::ArgList &  Args) const

Compute the desired OpenMP runtime from the flags provided.

Definition at line 623 of file Driver.cpp.

References Diag(), OMPRT_GOMP, OMPRT_IOMP5, OMPRT_OMP, and OMPRT_Unknown.

Referenced by clang::driver::tools::MinGW::Linker::ConstructJob(), clang::driver::tools::Clang::ConstructJob(), and CreateOffloadingDeviceToolChains().

◆ getOpts()

const llvm::opt::OptTable& clang::driver::Driver::getOpts ( ) const
inline

◆ GetProgramPath()

std::string Driver::GetProgramPath ( StringRef  Name,
const ToolChain TC 
) const

GetProgramPath - Lookup Name in the list of program search paths.

Parameters
TC- The provided tool chain for additional information on directories to search.

Definition at line 5083 of file Driver.cpp.

Referenced by HandleImmediateArgs().

◆ GetReleaseVersion() [1/2]

bool Driver::GetReleaseVersion ( StringRef  Str,
MutableArrayRef< unsigned Digits 
)
static

Parse digits from a string Str and fulfill Digits with the parsed numbers.

This method assumes that the max number of digits to look for is equal to Digits.size().

Returns
True if the entire string was parsed and there are no extra characters remaining at the end.

Definition at line 5427 of file Driver.cpp.

◆ GetReleaseVersion() [2/2]

bool Driver::GetReleaseVersion ( StringRef  Str,
unsigned Major,
unsigned Minor,
unsigned Micro,
bool HadExtra 
)
static

GetReleaseVersion - Parse (([0-9]+)(.

([0-9]+)(.([0-9]+)?))?)? and return the grouped values as integers. Numbers which are not provided are set to 0.

Returns
True if the entire string was parsed (9.2), or all groups were parsed (10.3.5extrastuff). HadExtra is true if all groups were parsed but extra characters remain at the end.

([0-9]+)(.([0-9]+)?))?)? and return the grouped values as integers. Numbers which are not provided are set to 0.

Returns
True if the entire string was parsed (9.2), or all groups were parsed (10.3.5extrastuff).

Definition at line 5389 of file Driver.cpp.

Referenced by clang::driver::tools::darwin::Linker::ConstructJob(), and getSystemOrSDKMacOSVersion().

◆ GetResourcesPath()

std::string Driver::GetResourcesPath ( StringRef  BinaryPath,
StringRef  CustomResourceDir = "" 
)
static

Takes the path to a binary that's either in bin/ or lib/ and returns the path to clang's resource directory.

Definition at line 106 of file Driver.cpp.

References P, and string().

Referenced by Driver().

◆ getTargetTriple()

std::string clang::driver::Driver::getTargetTriple ( ) const
inline

◆ GetTemporaryDirectory()

std::string Driver::GetTemporaryDirectory ( StringRef  Prefix) const

GetTemporaryDirectory - Return the pathname of a temporary directory to use as part of compilation; the directory will have the given prefix.

Definition at line 5136 of file Driver.cpp.

References Diag(), and string().

◆ GetTemporaryPath()

std::string Driver::GetTemporaryPath ( StringRef  Prefix,
StringRef  Suffix 
) const

GetTemporaryPath - Return the pathname of a temporary file to use as part of compilation; the file will have the given prefix and suffix.

GCC goes to extra lengths here to be a bit more robust.

Definition at line 5125 of file Driver.cpp.

References Diag(), and string().

Referenced by GetNamedOutputPath().

◆ getTitle()

const std::string& clang::driver::Driver::getTitle ( )
inline

Definition at line 334 of file Driver.h.

References DriverTitle.

◆ getVFS()

llvm::vfs::FileSystem& clang::driver::Driver::getVFS ( ) const
inline

◆ HandleAutocompletions()

void Driver::HandleAutocompletions ( StringRef  PassedFlags) const

HandleAutocompletions - Handle –autocomplete by searching and printing possible flags, descriptions, and its arguments.

Definition at line 1647 of file Driver.cpp.

References clang::driver::options::FlangOnlyOption, getOpts(), clang::driver::options::Ignored, IsFlangMode(), clang::driver::options::NoDriverOption, string(), and clang::driver::options::Unsupported.

Referenced by HandleImmediateArgs().

◆ HandleImmediateArgs()

bool Driver::HandleImmediateArgs ( const Compilation C)

◆ IsCLMode()

bool clang::driver::Driver::IsCLMode ( ) const
inline

◆ IsFlangMode()

bool clang::driver::Driver::IsFlangMode ( ) const
inline

Whether the driver should invoke flang for fortran inputs.

Other modes fall back to calling gcc which in turn calls gfortran.

Definition at line 189 of file Driver.h.

Referenced by BuildInputs(), HandleAutocompletions(), clang::driver::ToolChain::LookupTypeForExtension(), ParseArgStrings(), PrintHelp(), PrintVersion(), and clang::driver::ToolChain::SelectTool().

◆ isSaveTempsEnabled()

bool clang::driver::Driver::isSaveTempsEnabled ( ) const
inline

◆ isSaveTempsObj()

bool clang::driver::Driver::isSaveTempsObj ( ) const
inline

Definition at line 353 of file Driver.h.

Referenced by GetNamedOutputPath().

◆ isUsingLTO()

bool clang::driver::Driver::isUsingLTO ( ) const
inline

◆ ParseArgStrings()

InputArgList Driver::ParseArgStrings ( ArrayRef< const char * >  Args,
bool  IsClCompatMode,
bool ContainsError 
)

◆ ParseDriverMode()

void Driver::ParseDriverMode ( StringRef  ProgramName,
ArrayRef< const char * >  Args 
)

ParseDriverMode - Look for and handle the driver mode option in Args.

Definition at line 171 of file Driver.cpp.

References ClangNameParts, clang::driver::ParsedClangName::DriverMode, clang::driver::ToolChain::getTargetAndModeFromProgramName(), and clang::driver::ParsedClangName::isEmpty().

Referenced by BuildCompilation().

◆ PrintActions()

void Driver::PrintActions ( const Compilation C) const

PrintActions - Print the list of actions.

Definition at line 2007 of file Driver.cpp.

References PrintActions1().

◆ PrintHelp()

void Driver::PrintHelp ( bool  ShowHidden) const

PrintHelp - Print the help text.

Parameters
ShowHidden- Show hidden options.

Definition at line 1589 of file Driver.cpp.

References DriverTitle, clang::driver::options::FlangOnlyOption, clang::driver::options::FlangOption, getOpts(), IsCLMode(), IsFlangMode(), Name, clang::driver::options::NoDriverOption, and string().

Referenced by HandleImmediateArgs().

◆ PrintVersion()

void Driver::PrintVersion ( const Compilation C,
raw_ostream &  OS 
) const

◆ setCheckInputsExist()

void clang::driver::Driver::setCheckInputsExist ( bool  Value)
inline

Definition at line 330 of file Driver.h.

Referenced by clang::createInvocationFromCommandLine().

◆ setInstalledDir()

void clang::driver::Driver::setInstalledDir ( StringRef  Value)
inline

Definition at line 350 of file Driver.h.

References InstalledDir, and string().

◆ setTargetAndMode()

void clang::driver::Driver::setTargetAndMode ( const ParsedClangName TM)
inline

Definition at line 332 of file Driver.h.

References ClangNameParts.

◆ setTitle()

void clang::driver::Driver::setTitle ( std::string  Value)
inline

Definition at line 335 of file Driver.h.

References DriverTitle.

Referenced by newDriver().

◆ ShouldEmitStaticLibrary()

bool Driver::ShouldEmitStaticLibrary ( const llvm::opt::ArgList &  Args) const

ShouldEmitStaticLibrary - Should the linker emit a static library.

Definition at line 5377 of file Driver.cpp.

◆ ShouldUseClangCompiler()

bool Driver::ShouldUseClangCompiler ( const JobAction JA) const

ShouldUseClangCompiler - Should the clang compiler be used to handle this action.

Definition at line 5350 of file Driver.cpp.

References clang::driver::Action::input_begin(), clang::driver::types::isAcceptedByClang(), and clang::driver::Action::size().

◆ ShouldUseFlangCompiler()

bool Driver::ShouldUseFlangCompiler ( const JobAction JA) const

ShouldUseFlangCompiler - Should the flang compiler be used to handle this action.

Definition at line 5364 of file Driver.cpp.

References clang::driver::Action::input_begin(), clang::driver::types::isFortran(), and clang::driver::Action::size().

Member Data Documentation

◆ CC1Main

CC1ToolFunc clang::driver::Driver::CC1Main = nullptr

Definition at line 219 of file Driver.h.

Referenced by clang::driver::tools::ClangAs::ConstructJob().

◆ CCCPrintBindings

unsigned clang::driver::Driver::CCCPrintBindings

Only print tool bindings, don't build any jobs.

Definition at line 192 of file Driver.h.

◆ CCGenDiagnostics

unsigned clang::driver::Driver::CCGenDiagnostics

Whether the driver is generating diagnostics for debugging purposes.

Definition at line 208 of file Driver.h.

Referenced by clang::driver::tools::Clang::ConstructJob(), clang::driver::tools::ClangAs::ConstructJob(), ConstructPhaseAction(), generateCompilationDiagnostics(), and GetNamedOutputPath().

◆ CCLogDiagnostics

unsigned clang::driver::Driver::CCLogDiagnostics

Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics to CCLogDiagnosticsFilename or to stderr, in a stable machine readable format.

Definition at line 205 of file Driver.h.

Referenced by clang::driver::tools::Clang::ConstructJob().

◆ CCLogDiagnosticsFilename

std::string clang::driver::Driver::CCLogDiagnosticsFilename

The file to log CC_LOG_DIAGNOSTICS output to, if enabled.

Definition at line 169 of file Driver.h.

Referenced by clang::driver::tools::Clang::ConstructJob().

◆ CCPrintHeaders

unsigned clang::driver::Driver::CCPrintHeaders

Set CC_PRINT_HEADERS mode, which causes the frontend to log header include information to CCPrintHeadersFilename or to stderr.

Definition at line 200 of file Driver.h.

Referenced by clang::driver::tools::Clang::ConstructJob().

◆ CCPrintHeadersFilename

std::string clang::driver::Driver::CCPrintHeadersFilename

The file to log CC_PRINT_HEADERS output to, if enabled.

Definition at line 166 of file Driver.h.

Referenced by clang::driver::tools::Clang::ConstructJob().

◆ CCPrintOptions

unsigned clang::driver::Driver::CCPrintOptions

Set CC_PRINT_OPTIONS mode, which is like -v but logs the commands to CCPrintOptionsFilename or to stderr.

Definition at line 196 of file Driver.h.

◆ CCPrintOptionsFilename

std::string clang::driver::Driver::CCPrintOptionsFilename

The file to log CC_PRINT_OPTIONS output to, if enabled.

Definition at line 163 of file Driver.h.

◆ CCPrintProcessStats

unsigned clang::driver::Driver::CCPrintProcessStats

Set CC_PRINT_PROC_STAT mode, which causes the driver to dump performance report to CC_PRINT_PROC_STAT_FILE or to stdout.

Definition at line 212 of file Driver.h.

Referenced by BuildJobs().

◆ CCPrintStatReportFilename

std::string clang::driver::Driver::CCPrintStatReportFilename

The file to log CC_PRINT_PROC_STAT_FILE output to, if enabled.

Definition at line 160 of file Driver.h.

Referenced by BuildJobs().

◆ ClangExecutable

std::string clang::driver::Driver::ClangExecutable

The original path to the clang executable.

Definition at line 123 of file Driver.h.

Referenced by BuildCompilation(), Driver(), and getClangProgramPath().

◆ ClangNameParts

ParsedClangName clang::driver::Driver::ClangNameParts

Target and driver mode components extracted from clang executable name.

Definition at line 126 of file Driver.h.

Referenced by ParseDriverMode(), and setTargetAndMode().

◆ Dir

std::string clang::driver::Driver::Dir

◆ DriverTitle

std::string clang::driver::Driver::DriverTitle

Driver title to use with help.

Definition at line 154 of file Driver.h.

Referenced by getTitle(), PrintHelp(), and setTitle().

◆ DyldPrefix

std::string clang::driver::Driver::DyldPrefix

Dynamic loader prefix, if present.

Definition at line 151 of file Driver.h.

Referenced by clang::driver::tools::fuchsia::Linker::ConstructJob(), and clang::driver::tools::gnutools::Linker::ConstructJob().

◆ GenReproducer

unsigned clang::driver::Driver::GenReproducer

Force clang to emit reproducer for driver invocation.

This is enabled indirectly by setting FORCE_CLANG_DIAGNOSTICS_CRASH environment variable or when using the -gen-reproducer driver flag.

Definition at line 251 of file Driver.h.

◆ HostBits

std::string clang::driver::Driver::HostBits

Information about the host which can be overridden by the user.

Definition at line 157 of file Driver.h.

◆ HostMachine

std::string clang::driver::Driver::HostMachine

Definition at line 157 of file Driver.h.

◆ HostRelease

std::string clang::driver::Driver::HostRelease

Definition at line 157 of file Driver.h.

◆ HostSystem

std::string clang::driver::Driver::HostSystem

Definition at line 157 of file Driver.h.

◆ InstalledDir

std::string clang::driver::Driver::InstalledDir

◆ Name

std::string clang::driver::Driver::Name

The name the driver was invoked as.

Definition at line 116 of file Driver.h.

Referenced by Driver(), generateCompilationDiagnostics(), GetNamedOutputPath(), and PrintHelp().

◆ PrefixDirs

prefix_list clang::driver::Driver::PrefixDirs

◆ ResourceDir

std::string clang::driver::Driver::ResourceDir

◆ SysRoot

std::string clang::driver::Driver::SysRoot

sysroot, if present

Definition at line 148 of file Driver.h.

Referenced by clang::driver::toolchains::CrossWindowsToolChain::AddClangCXXStdlibIncludeArgs(), clang::driver::toolchains::Solaris::AddClangSystemIncludeArgs(), clang::driver::toolchains::CrossWindowsToolChain::AddClangSystemIncludeArgs(), clang::driver::toolchains::OpenBSD::AddClangSystemIncludeArgs(), clang::driver::toolchains::HexagonToolChain::AddClangSystemIncludeArgs(), clang::driver::toolchains::Fuchsia::AddClangSystemIncludeArgs(), clang::driver::toolchains::NetBSD::addLibCxxIncludePaths(), clang::driver::toolchains::HexagonToolChain::addLibCxxIncludePaths(), clang::driver::toolchains::MipsLLVMToolChain::computeSysRoot(), clang::driver::toolchains::Linux::computeSysRoot(), clang::driver::toolchains::BareMetal::computeSysRoot(), clang::driver::ToolChain::computeSysRoot(), constructHexagonLinkArgs(), clang::driver::tools::fuchsia::Linker::ConstructJob(), clang::driver::tools::cloudabi::Linker::ConstructJob(), clang::driver::tools::nacltools::Linker::ConstructJob(), clang::driver::tools::ananas::Linker::ConstructJob(), clang::driver::tools::netbsd::Linker::ConstructJob(), clang::driver::tools::dragonfly::Linker::ConstructJob(), clang::driver::tools::CrossWindows::Linker::ConstructJob(), clang::driver::tools::freebsd::Linker::ConstructJob(), clang::driver::tools::MinGW::Linker::ConstructJob(), clang::driver::tools::PS4cpu::Link::ConstructJob(), clang::driver::tools::RISCV::Linker::ConstructJob(), clang::driver::tools::gnutools::Linker::ConstructJob(), clang::driver::tools::msp430::Linker::ConstructJob(), Driver(), clang::driver::toolchains::Fuchsia::Fuchsia(), clang::driver::Compilation::getSysRoot(), clang::driver::toolchains::Generic_GCC::GCCInstallationDetector::init(), and clang::driver::toolchains::MinGW::MinGW().

◆ SystemConfigDir

std::string clang::driver::Driver::SystemConfigDir

System directory for config files.

Definition at line 135 of file Driver.h.

Referenced by Driver(), and HandleImmediateArgs().

◆ UserConfigDir

std::string clang::driver::Driver::UserConfigDir

User directory for config files.

Definition at line 138 of file Driver.h.

Referenced by Driver(), and HandleImmediateArgs().


The documentation for this class was generated from the following files: