#include "clang/Driver/Driver.h"
#include "ToolChains/AIX.h"
#include "ToolChains/AMDGPU.h"
#include "ToolChains/AMDGPUOpenMP.h"
#include "ToolChains/AVR.h"
#include "ToolChains/Arch/RISCV.h"
#include "ToolChains/BareMetal.h"
#include "ToolChains/CSKYToolChain.h"
#include "ToolChains/Clang.h"
#include "ToolChains/CrossWindows.h"
#include "ToolChains/Cuda.h"
#include "ToolChains/Darwin.h"
#include "ToolChains/DragonFly.h"
#include "ToolChains/FreeBSD.h"
#include "ToolChains/Fuchsia.h"
#include "ToolChains/Gnu.h"
#include "ToolChains/HIPAMD.h"
#include "ToolChains/HIPSPV.h"
#include "ToolChains/HLSL.h"
#include "ToolChains/Haiku.h"
#include "ToolChains/Hexagon.h"
#include "ToolChains/Hurd.h"
#include "ToolChains/Lanai.h"
#include "ToolChains/Linux.h"
#include "ToolChains/MSP430.h"
#include "ToolChains/MSVC.h"
#include "ToolChains/MinGW.h"
#include "ToolChains/MipsLinux.h"
#include "ToolChains/NaCl.h"
#include "ToolChains/NetBSD.h"
#include "ToolChains/OHOS.h"
#include "ToolChains/OpenBSD.h"
#include "ToolChains/PPCFreeBSD.h"
#include "ToolChains/PPCLinux.h"
#include "ToolChains/PS4CPU.h"
#include "ToolChains/RISCVToolchain.h"
#include "ToolChains/SPIRV.h"
#include "ToolChains/Solaris.h"
#include "ToolChains/TCE.h"
#include "ToolChains/UEFI.h"
#include "ToolChains/VEToolchain.h"
#include "ToolChains/WebAssembly.h"
#include "ToolChains/XCore.h"
#include "ToolChains/ZOS.h"
#include "clang/Basic/DiagnosticDriver.h"
#include "clang/Basic/TargetID.h"
#include "clang/Basic/Version.h"
#include "clang/Config/config.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Job.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/Phases.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
#include "clang/Driver/Types.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Option/OptSpecifier.h"
#include "llvm/Option/OptTable.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ExitCodes.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/MD5.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/Regex.h"
#include "llvm/Support/StringSaver.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/RISCVISAInfo.h"
#include <cstdlib>
#include <map>
#include <memory>
#include <optional>
#include <set>
#include <utility>
#if LLVM_ON_UNIX
#include <unistd.h>
#endif
usingnamespaceclang::driver;
usingnamespaceclang;
usingnamespacellvm::opt;
static std::optional<llvm::Triple> getOffloadTargetTriple(const Driver &D,
const ArgList &Args) { … }
static std::optional<llvm::Triple>
getNVIDIAOffloadTargetTriple(const Driver &D, const ArgList &Args,
const llvm::Triple &HostTriple) { … }
static std::optional<llvm::Triple>
getHIPOffloadTargetTriple(const Driver &D, const ArgList &Args) { … }
std::string Driver::GetResourcesPath(StringRef BinaryPath) { … }
Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,
DiagnosticsEngine &Diags, std::string Title,
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS)
: … { … }
void Driver::setDriverMode(StringRef Value) { … }
InputArgList Driver::ParseArgStrings(ArrayRef<const char *> ArgStrings,
bool UseDriverMode, bool &ContainsError) { … }
phases::ID Driver::getFinalPhase(const DerivedArgList &DAL,
Arg **FinalPhaseArg) const { … }
static Arg *MakeInputArg(DerivedArgList &Args, const OptTable &Opts,
StringRef Value, bool Claim = true) { … }
DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const { … }
static llvm::Triple computeTargetTriple(const Driver &D,
StringRef TargetTriple,
const ArgList &Args,
StringRef DarwinArchName = "") { … }
static driver::LTOKind parseLTOMode(Driver &D, const llvm::opt::ArgList &Args,
OptSpecifier OptEq, OptSpecifier OptNeg) { … }
void Driver::setLTOMode(const llvm::opt::ArgList &Args) { … }
Driver::OpenMPRuntimeKind Driver::getOpenMPRuntime(const ArgList &Args) const { … }
void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
InputList &Inputs) { … }
static void appendOneArg(InputArgList &Args, const Arg *Opt,
const Arg *BaseArg) { … }
bool Driver::readConfigFile(StringRef FileName,
llvm::cl::ExpansionContext &ExpCtx) { … }
bool Driver::loadConfigFiles() { … }
bool Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) { … }
Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) { … }
static void printArgList(raw_ostream &OS, const llvm::opt::ArgList &Args) { … }
bool Driver::getCrashDiagnosticFile(StringRef ReproCrashFilename,
SmallString<128> &CrashDiagDir) { … }
static const char BugReporMsg[] = …;
void Driver::generateCompilationDiagnostics(
Compilation &C, const Command &FailingCommand,
StringRef AdditionalInformation, CompilationDiagnosticReport *Report) { … }
void Driver::setUpResponseFiles(Compilation &C, Command &Cmd) { … }
int Driver::ExecuteCompilation(
Compilation &C,
SmallVectorImpl<std::pair<int, const Command *>> &FailingCommands) { … }
void Driver::PrintHelp(bool ShowHidden) const { … }
void Driver::PrintVersion(const Compilation &C, raw_ostream &OS) const { … }
static void PrintDiagnosticCategories(raw_ostream &OS) { … }
void Driver::HandleAutocompletions(StringRef PassedFlags) const { … }
bool Driver::HandleImmediateArgs(Compilation &C) { … }
enum { … };
static unsigned PrintActions1(const Compilation &C, Action *A,
std::map<Action *, unsigned> &Ids,
Twine Indent = { … }
void Driver::PrintActions(const Compilation &C) const { … }
static bool ContainsCompileOrAssembleAction(const Action *A) { … }
void Driver::BuildUniversalActions(Compilation &C, const ToolChain &TC,
const InputList &BAInputs) const { … }
bool Driver::DiagnoseInputExistence(const DerivedArgList &Args, StringRef Value,
types::ID Ty, bool TypoCorrect) const { … }
static types::ID CXXHeaderUnitType(ModuleHeaderMode HM) { … }
void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
InputList &Inputs) const { … }
namespace {
class OffloadingActionBuilder final { … };
}
void Driver::handleArguments(Compilation &C, DerivedArgList &Args,
const InputList &Inputs,
ActionList &Actions) const { … }
void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
const InputList &Inputs, ActionList &Actions) const { … }
static StringRef getCanonicalArchString(Compilation &C,
const llvm::opt::DerivedArgList &Args,
StringRef ArchStr,
const llvm::Triple &Triple,
bool SuppressError = false) { … }
static std::optional<std::pair<llvm::StringRef, llvm::StringRef>>
getConflictOffloadArchCombination(const llvm::DenseSet<StringRef> &Archs,
llvm::Triple Triple) { … }
llvm::DenseSet<StringRef>
Driver::getOffloadArchs(Compilation &C, const llvm::opt::DerivedArgList &Args,
Action::OffloadKind Kind, const ToolChain *TC,
bool SuppressError) const { … }
Action *Driver::BuildOffloadingActions(Compilation &C,
llvm::opt::DerivedArgList &Args,
const InputTy &Input,
Action *HostAction) const { … }
Action *Driver::ConstructPhaseAction(
Compilation &C, const ArgList &Args, phases::ID Phase, Action *Input,
Action::OffloadKind TargetDeviceOffloadKind) const { … }
void Driver::BuildJobs(Compilation &C) const { … }
namespace {
class ToolSelector final { … };
}
static std::string GetTriplePlusArchString(const ToolChain *TC,
StringRef BoundArch,
Action::OffloadKind OffloadKind) { … }
InputInfoList 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>, InputInfoList>
&CachedResults,
Action::OffloadKind TargetDeviceOffloadKind) const { … }
static void handleTimeTrace(Compilation &C, const ArgList &Args,
const JobAction *JA, const char *BaseInput,
const InputInfo &Result) { … }
InputInfoList Driver::BuildJobsForActionNoCache(
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>, InputInfoList>
&CachedResults,
Action::OffloadKind TargetDeviceOffloadKind) const { … }
const char *Driver::getDefaultImageName() const { … }
static const char *MakeCLOutputFilename(const ArgList &Args, StringRef ArgValue,
StringRef BaseName,
types::ID FileType) { … }
static bool HasPreprocessOutput(const Action &JA) { … }
const char *Driver::CreateTempFile(Compilation &C, StringRef Prefix,
StringRef Suffix, bool MultipleArchs,
StringRef BoundArch,
bool NeedUniqueDirectory) const { … }
static const char *GetModuleOutputPath(Compilation &C, const JobAction &JA,
const char *BaseInput) { … }
const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
const char *BaseInput,
StringRef OrigBoundArch, bool AtTopLevel,
bool MultipleArchs,
StringRef OffloadingPrefix) const { … }
std::string Driver::GetFilePath(StringRef Name, const ToolChain &TC) const { … }
void Driver::generatePrefixedToolNames(
StringRef Tool, const ToolChain &TC,
SmallVectorImpl<std::string> &Names) const { … }
static bool ScanDirForExecutable(SmallString<128> &Dir, StringRef Name) { … }
std::string Driver::GetProgramPath(StringRef Name, const ToolChain &TC) const { … }
std::string Driver::GetStdModuleManifestPath(const Compilation &C,
const ToolChain &TC) const { … }
std::string Driver::GetTemporaryPath(StringRef Prefix, StringRef Suffix) const { … }
std::string Driver::GetTemporaryDirectory(StringRef Prefix) const { … }
std::string Driver::GetClPchPath(Compilation &C, StringRef BaseName) const { … }
const ToolChain &Driver::getToolChain(const ArgList &Args,
const llvm::Triple &Target) const { … }
const ToolChain &Driver::getOffloadingDeviceToolChain(
const ArgList &Args, const llvm::Triple &Target, const ToolChain &HostTC,
const Action::OffloadKind &TargetDeviceOffloadKind) const { … }
bool Driver::ShouldUseClangCompiler(const JobAction &JA) const { … }
bool Driver::ShouldUseFlangCompiler(const JobAction &JA) const { … }
bool Driver::ShouldEmitStaticLibrary(const ArgList &Args) const { … }
bool Driver::GetReleaseVersion(StringRef Str, unsigned &Major, unsigned &Minor,
unsigned &Micro, bool &HadExtra) { … }
bool Driver::GetReleaseVersion(StringRef Str,
MutableArrayRef<unsigned> Digits) { … }
llvm::opt::Visibility
Driver::getOptionVisibilityMask(bool UseDriverMode) const { … }
const char *Driver::getExecutableForDriverMode(DriverMode Mode) { … }
bool clang::driver::isOptimizationLevelFast(const ArgList &Args) { … }
bool clang::driver::willEmitRemarks(const ArgList &Args) { … }
llvm::StringRef clang::driver::getDriverMode(StringRef ProgName,
ArrayRef<const char *> Args) { … }
bool driver::IsClangCL(StringRef DriverMode) { … }
llvm::Error driver::expandResponseFiles(SmallVectorImpl<const char *> &Args,
bool ClangCLMode,
llvm::BumpPtrAllocator &Alloc,
llvm::vfs::FileSystem *FS) { … }
static const char *GetStableCStr(llvm::StringSet<> &SavedStrings, StringRef S) { … }
static void applyOneOverrideOption(raw_ostream &OS,
SmallVectorImpl<const char *> &Args,
StringRef Edit,
llvm::StringSet<> &SavedStrings) { … }
void driver::applyOverrideOptions(SmallVectorImpl<const char *> &Args,
const char *OverrideStr,
llvm::StringSet<> &SavedStrings,
raw_ostream *OS) { … }