#include "clang/Driver/ToolChain.h"
#include "ToolChains/Arch/AArch64.h"
#include "ToolChains/Arch/ARM.h"
#include "ToolChains/Arch/RISCV.h"
#include "ToolChains/Clang.h"
#include "ToolChains/CommonArgs.h"
#include "ToolChains/Flang.h"
#include "ToolChains/InterfaceStubs.h"
#include "clang/Basic/ObjCRuntime.h"
#include "clang/Basic/Sanitizers.h"
#include "clang/Config/config.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Job.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Driver/XRayArgs.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Option/OptTable.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/VersionTuple.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/TargetParser/AArch64TargetParser.h"
#include "llvm/TargetParser/RISCVISAInfo.h"
#include "llvm/TargetParser/TargetParser.h"
#include "llvm/TargetParser/Triple.h"
#include <cassert>
#include <cstddef>
#include <cstring>
#include <string>
usingnamespaceclang;
usingnamespacedriver;
usingnamespacetools;
usingnamespacellvm;
usingnamespacellvm::opt;
static llvm::opt::Arg *GetRTTIArgument(const ArgList &Args) { … }
static ToolChain::RTTIMode CalculateRTTIMode(const ArgList &Args,
const llvm::Triple &Triple,
const Arg *CachedRTTIArg) { … }
static ToolChain::ExceptionsMode CalculateExceptionsMode(const ArgList &Args) { … }
ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
const ArgList &Args)
: … { … }
llvm::Expected<std::unique_ptr<llvm::MemoryBuffer>>
ToolChain::executeToolChainProgram(StringRef Executable) const { … }
void ToolChain::setTripleEnvironment(llvm::Triple::EnvironmentType Env) { … }
ToolChain::~ToolChain() = default;
llvm::vfs::FileSystem &ToolChain::getVFS() const { … }
bool ToolChain::useIntegratedAs() const { … }
bool ToolChain::useIntegratedBackend() const { … }
bool ToolChain::useRelaxRelocations() const { … }
bool ToolChain::defaultToIEEELongDouble() const { … }
static void getAArch64MultilibFlags(const Driver &D,
const llvm::Triple &Triple,
const llvm::opt::ArgList &Args,
Multilib::flags_list &Result) { … }
static void getARMMultilibFlags(const Driver &D,
const llvm::Triple &Triple,
const llvm::opt::ArgList &Args,
Multilib::flags_list &Result) { … }
static void getRISCVMultilibFlags(const Driver &D, const llvm::Triple &Triple,
const llvm::opt::ArgList &Args,
Multilib::flags_list &Result) { … }
Multilib::flags_list
ToolChain::getMultilibFlags(const llvm::opt::ArgList &Args) const { … }
SanitizerArgs
ToolChain::getSanitizerArgs(const llvm::opt::ArgList &JobArgs) const { … }
const XRayArgs& ToolChain::getXRayArgs() const { … }
namespace {
struct DriverSuffix { … };
}
static const DriverSuffix *FindDriverSuffix(StringRef ProgName, size_t &Pos) { … }
static std::string normalizeProgramName(llvm::StringRef Argv0) { … }
static const DriverSuffix *parseDriverSuffix(StringRef ProgName, size_t &Pos) { … }
ParsedClangName
ToolChain::getTargetAndModeFromProgramName(StringRef PN) { … }
StringRef ToolChain::getDefaultUniversalArchName() const { … }
std::string ToolChain::getInputFilename(const InputInfo &Input) const { … }
ToolChain::UnwindTableLevel
ToolChain::getDefaultUnwindTableLevel(const ArgList &Args) const { … }
Tool *ToolChain::getClang() const { … }
Tool *ToolChain::getFlang() const { … }
Tool *ToolChain::buildAssembler() const { … }
Tool *ToolChain::buildLinker() const { … }
Tool *ToolChain::buildStaticLibTool() const { … }
Tool *ToolChain::getAssemble() const { … }
Tool *ToolChain::getClangAs() const { … }
Tool *ToolChain::getLink() const { … }
Tool *ToolChain::getStaticLibTool() const { … }
Tool *ToolChain::getIfsMerge() const { … }
Tool *ToolChain::getOffloadBundler() const { … }
Tool *ToolChain::getOffloadPackager() const { … }
Tool *ToolChain::getLinkerWrapper() const { … }
Tool *ToolChain::getTool(Action::ActionClass AC) const { … }
static StringRef getArchNameForCompilerRTLib(const ToolChain &TC,
const ArgList &Args) { … }
StringRef ToolChain::getOSLibName() const { … }
std::string ToolChain::getCompilerRTPath() const { … }
std::string ToolChain::getCompilerRTBasename(const ArgList &Args,
StringRef Component,
FileType Type) const { … }
std::string ToolChain::buildCompilerRTBasename(const llvm::opt::ArgList &Args,
StringRef Component,
FileType Type,
bool AddArch) const { … }
std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
FileType Type) const { … }
const char *ToolChain::getCompilerRTArgString(const llvm::opt::ArgList &Args,
StringRef Component,
FileType Type) const { … }
std::optional<std::string>
ToolChain::getFallbackAndroidTargetPath(StringRef BaseDir) const { … }
std::optional<std::string>
ToolChain::getTargetSubDirPath(StringRef BaseDir) const { … }
std::optional<std::string> ToolChain::getRuntimePath() const { … }
std::optional<std::string> ToolChain::getStdlibPath() const { … }
std::optional<std::string> ToolChain::getStdlibIncludePath() const { … }
ToolChain::path_list ToolChain::getArchSpecificLibPaths() const { … }
bool ToolChain::needsProfileRT(const ArgList &Args) { … }
bool ToolChain::needsGCovInstrumentation(const llvm::opt::ArgList &Args) { … }
Tool *ToolChain::SelectTool(const JobAction &JA) const { … }
std::string ToolChain::GetFilePath(const char *Name) const { … }
std::string ToolChain::GetProgramPath(const char *Name) const { … }
std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD) const { … }
std::string ToolChain::GetStaticLibToolPath() const { … }
types::ID ToolChain::LookupTypeForExtension(StringRef Ext) const { … }
bool ToolChain::HasNativeLLVMSupport() const { … }
bool ToolChain::isCrossCompiling() const { … }
ObjCRuntime ToolChain::getDefaultObjCRuntime(bool isNonFragile) const { … }
llvm::ExceptionHandling
ToolChain::GetExceptionModel(const llvm::opt::ArgList &Args) const { … }
bool ToolChain::isThreadModelSupported(const StringRef Model) const { … }
std::string ToolChain::ComputeLLVMTriple(const ArgList &Args,
types::ID InputType) const { … }
std::string ToolChain::ComputeEffectiveClangTriple(const ArgList &Args,
types::ID InputType) const { … }
std::string ToolChain::computeSysRoot() const { … }
void ToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const { … }
void ToolChain::addClangTargetOptions(
const ArgList &DriverArgs, ArgStringList &CC1Args,
Action::OffloadKind DeviceOffloadKind) const { … }
void ToolChain::addClangCC1ASTargetOptions(const ArgList &Args,
ArgStringList &CC1ASArgs) const { … }
void ToolChain::addClangWarningOptions(ArgStringList &CC1Args) const { … }
void ToolChain::addProfileRTLibs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const { … }
ToolChain::RuntimeLibType ToolChain::GetRuntimeLibType(
const ArgList &Args) const { … }
ToolChain::UnwindLibType ToolChain::GetUnwindLibType(
const ArgList &Args) const { … }
ToolChain::CXXStdlibType ToolChain::GetCXXStdlibType(const ArgList &Args) const{ … }
void ToolChain::addSystemInclude(const ArgList &DriverArgs,
ArgStringList &CC1Args,
const Twine &Path) { … }
void ToolChain::addExternCSystemInclude(const ArgList &DriverArgs,
ArgStringList &CC1Args,
const Twine &Path) { … }
void ToolChain::addExternCSystemIncludeIfExists(const ArgList &DriverArgs,
ArgStringList &CC1Args,
const Twine &Path) { … }
void ToolChain::addSystemIncludes(const ArgList &DriverArgs,
ArgStringList &CC1Args,
ArrayRef<StringRef> Paths) { … }
std::string ToolChain::concat(StringRef Path, const Twine &A,
const Twine &B, const Twine &C,
const Twine &D) { … }
std::string ToolChain::detectLibcxxVersion(StringRef IncludePath) const { … }
void ToolChain::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const { … }
void ToolChain::AddClangCXXStdlibIsystemArgs(
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const { … }
bool ToolChain::ShouldLinkCXXStdlib(const llvm::opt::ArgList &Args) const { … }
void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void ToolChain::AddFilePathLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void ToolChain::AddCCKextLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
bool ToolChain::isFastMathRuntimeAvailable(const ArgList &Args,
std::string &Path) const { … }
bool ToolChain::addFastMathRuntimeIfAvailable(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
Expected<SmallVector<std::string>>
ToolChain::getSystemGPUArchs(const llvm::opt::ArgList &Args) const { … }
SanitizerMask ToolChain::getSupportedSanitizers() const { … }
void ToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const { … }
void ToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const { … }
llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12>
ToolChain::getDeviceLibs(const ArgList &DriverArgs) const { … }
void ToolChain::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const { … }
static VersionTuple separateMSVCFullVersion(unsigned Version) { … }
VersionTuple
ToolChain::computeMSVCVersion(const Driver *D,
const llvm::opt::ArgList &Args) const { … }
llvm::opt::DerivedArgList *ToolChain::TranslateOpenMPTargetArgs(
const llvm::opt::DerivedArgList &Args, bool SameTripleAsHost,
SmallVectorImpl<llvm::opt::Arg *> &AllocatedArgs) const { … }
void ToolChain::TranslateXarchArgs(
const llvm::opt::DerivedArgList &Args, llvm::opt::Arg *&A,
llvm::opt::DerivedArgList *DAL,
SmallVectorImpl<llvm::opt::Arg *> *AllocatedArgs) const { … }
llvm::opt::DerivedArgList *ToolChain::TranslateXarchArgs(
const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
Action::OffloadKind OFK,
SmallVectorImpl<llvm::opt::Arg *> *AllocatedArgs) const { … }