#include "CommonArgs.h"
#include "Arch/AArch64.h"
#include "Arch/ARM.h"
#include "Arch/CSKY.h"
#include "Arch/LoongArch.h"
#include "Arch/M68k.h"
#include "Arch/Mips.h"
#include "Arch/PPC.h"
#include "Arch/RISCV.h"
#include "Arch/Sparc.h"
#include "Arch/SystemZ.h"
#include "Arch/VE.h"
#include "Arch/X86.h"
#include "HIPAMD.h"
#include "Hexagon.h"
#include "MSP430.h"
#include "Solaris.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/ObjCRuntime.h"
#include "clang/Basic/Version.h"
#include "clang/Config/config.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Compilation.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/ToolChain.h"
#include "clang/Driver/Util.h"
#include "clang/Driver/XRayArgs.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Twine.h"
#include "llvm/BinaryFormat/Magic.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/Option/Arg.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Option/Option.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/Threading.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/YAMLParser.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/PPCTargetParser.h"
#include "llvm/TargetParser/TargetParser.h"
#include <optional>
usingnamespaceclang::driver;
usingnamespaceclang::driver::tools;
usingnamespaceclang;
usingnamespacellvm::opt;
static bool useFramePointerForTargetByDefault(const llvm::opt::ArgList &Args,
const llvm::Triple &Triple) { … }
static bool useLeafFramePointerForTargetByDefault(const llvm::Triple &Triple) { … }
static bool mustUseNonLeafFramePointerForTarget(const llvm::Triple &Triple) { … }
static bool mustMaintainValidFrameChain(const llvm::opt::ArgList &Args,
const llvm::Triple &Triple) { … }
static bool framePointerImpliesLeafFramePointer(const llvm::opt::ArgList &Args,
const llvm::Triple &Triple) { … }
clang::CodeGenOptions::FramePointerKind
getFramePointerKind(const llvm::opt::ArgList &Args,
const llvm::Triple &Triple) { … }
static void renderRpassOptions(const ArgList &Args, ArgStringList &CmdArgs,
const StringRef PluginOptPrefix) { … }
static void renderRemarksOptions(const ArgList &Args, ArgStringList &CmdArgs,
const llvm::Triple &Triple,
const InputInfo &Input,
const InputInfo &Output,
const StringRef PluginOptPrefix) { … }
static void renderRemarksHotnessOptions(const ArgList &Args,
ArgStringList &CmdArgs,
const StringRef PluginOptPrefix) { … }
static bool shouldIgnoreUnsupportedTargetFeature(const Arg &TargetFeatureArg,
llvm::Triple T,
StringRef Processor) { … }
void tools::addPathIfExists(const Driver &D, const Twine &Path,
ToolChain::path_list &Paths) { … }
void tools::handleTargetFeaturesGroup(const Driver &D,
const llvm::Triple &Triple,
const ArgList &Args,
std::vector<StringRef> &Features,
OptSpecifier Group) { … }
SmallVector<StringRef>
tools::unifyTargetFeatures(ArrayRef<StringRef> Features) { … }
void tools::addDirectoryList(const ArgList &Args, ArgStringList &CmdArgs,
const char *ArgName, const char *EnvVar) { … }
void tools::AddLinkerInputs(const ToolChain &TC, const InputInfoList &Inputs,
const ArgList &Args, ArgStringList &CmdArgs,
const JobAction &JA) { … }
void tools::addLinkerCompressDebugSectionsOption(
const ToolChain &TC, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) { … }
void tools::AddTargetFeature(const ArgList &Args,
std::vector<StringRef> &Features,
OptSpecifier OnOpt, OptSpecifier OffOpt,
StringRef FeatureName) { … }
static std::string getAMDGPUTargetGPU(const llvm::Triple &T,
const ArgList &Args) { … }
static std::string getLanaiTargetCPU(const ArgList &Args) { … }
static StringRef getWebAssemblyTargetCPU(const ArgList &Args) { … }
std::string tools::getCPUName(const Driver &D, const ArgList &Args,
const llvm::Triple &T, bool FromAs) { … }
static void getWebAssemblyTargetFeatures(const Driver &D,
const llvm::Triple &Triple,
const ArgList &Args,
std::vector<StringRef> &Features) { … }
void tools::getTargetFeatures(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args, ArgStringList &CmdArgs,
bool ForAS, bool IsAux) { … }
llvm::StringRef tools::getLTOParallelism(const ArgList &Args, const Driver &D) { … }
bool tools::isUseSeparateSections(const llvm::Triple &Triple) { … }
bool tools::isTLSDESCEnabled(const ToolChain &TC,
const llvm::opt::ArgList &Args) { … }
void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
ArgStringList &CmdArgs, const InputInfo &Output,
const InputInfo &Input, bool IsThinLTO) { … }
void tools::addOpenMPRuntimeLibraryPath(const ToolChain &TC,
const ArgList &Args,
ArgStringList &CmdArgs) { … }
void tools::addArchSpecificRPath(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs) { … }
bool tools::addOpenMPRuntime(const Compilation &C, ArgStringList &CmdArgs,
const ToolChain &TC, const ArgList &Args,
bool ForceStaticHostRuntime, bool IsOffloadingHost,
bool GompNeedsRT) { … }
void tools::addOpenMPHostOffloadingArgs(const Compilation &C,
const JobAction &JA,
const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) { … }
void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) { … }
void tools::addFortranRuntimeLibraryPath(const ToolChain &TC,
const llvm::opt::ArgList &Args,
ArgStringList &CmdArgs) { … }
static void addSanitizerRuntime(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs, StringRef Sanitizer,
bool IsShared, bool IsWhole) { … }
static bool addSanitizerDynamicList(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs,
StringRef Sanitizer) { … }
void tools::addAsNeededOption(const ToolChain &TC,
const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
bool as_needed) { … }
void tools::linkSanitizerRuntimeDeps(const ToolChain &TC,
const llvm::opt::ArgList &Args,
ArgStringList &CmdArgs) { … }
static void
collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
SmallVectorImpl<StringRef> &SharedRuntimes,
SmallVectorImpl<StringRef> &StaticRuntimes,
SmallVectorImpl<StringRef> &NonWholeStaticRuntimes,
SmallVectorImpl<StringRef> &HelperStaticRuntimes,
SmallVectorImpl<StringRef> &RequiredSymbols) { … }
bool tools::addSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs) { … }
bool tools::addXRayRuntime(const ToolChain&TC, const ArgList &Args, ArgStringList &CmdArgs) { … }
void tools::linkXRayRuntimeDeps(const ToolChain &TC,
const llvm::opt::ArgList &Args,
ArgStringList &CmdArgs) { … }
bool tools::areOptimizationsEnabled(const ArgList &Args) { … }
const char *tools::SplitDebugName(const JobAction &JA, const ArgList &Args,
const InputInfo &Input,
const InputInfo &Output) { … }
void tools::SplitDebugInfo(const ToolChain &TC, Compilation &C, const Tool &T,
const JobAction &JA, const ArgList &Args,
const InputInfo &Output, const char *OutFile) { … }
void tools::claimNoWarnArgs(const ArgList &Args) { … }
Arg *tools::getLastCSProfileGenerateArg(const ArgList &Args) { … }
Arg *tools::getLastProfileUseArg(const ArgList &Args) { … }
Arg *tools::getLastProfileSampleUseArg(const ArgList &Args) { … }
const char *tools::RelocationModelName(llvm::Reloc::Model Model) { … }
std::tuple<llvm::Reloc::Model, unsigned, bool>
tools::ParsePICArgs(const ToolChain &ToolChain, const ArgList &Args) { … }
unsigned tools::ParseFunctionAlignment(const ToolChain &TC,
const ArgList &Args) { … }
void tools::addDebugInfoKind(
ArgStringList &CmdArgs, llvm::codegenoptions::DebugInfoKind DebugInfoKind) { … }
llvm::codegenoptions::DebugInfoKind tools::debugLevelToInfoKind(const Arg &A) { … }
static unsigned ParseDebugDefaultVersion(const ToolChain &TC,
const ArgList &Args) { … }
unsigned tools::DwarfVersionNum(StringRef ArgValue) { … }
const Arg *tools::getDwarfNArg(const ArgList &Args) { … }
unsigned tools::getDwarfVersion(const ToolChain &TC,
const llvm::opt::ArgList &Args) { … }
void tools::AddAssemblerKPIC(const ToolChain &ToolChain, const ArgList &Args,
ArgStringList &CmdArgs) { … }
bool tools::isObjCAutoRefCount(const ArgList &Args) { … }
enum class LibGccType { … };
static LibGccType getLibGccType(const ToolChain &TC, const Driver &D,
const ArgList &Args) { … }
static void AddUnwindLibrary(const ToolChain &TC, const Driver &D,
ArgStringList &CmdArgs, const ArgList &Args) { … }
static void AddLibgcc(const ToolChain &TC, const Driver &D,
ArgStringList &CmdArgs, const ArgList &Args) { … }
void tools::AddRunTimeLibs(const ToolChain &TC, const Driver &D,
ArgStringList &CmdArgs, const ArgList &Args) { … }
SmallString<128> tools::getStatsFileName(const llvm::opt::ArgList &Args,
const InputInfo &Output,
const InputInfo &Input,
const Driver &D) { … }
void tools::addMultilibFlag(bool Enabled, const StringRef Flag,
Multilib::flags_list &Flags) { … }
void tools::addX86AlignBranchArgs(const Driver &D, const ArgList &Args,
ArgStringList &CmdArgs, bool IsLTO,
const StringRef PluginOptPrefix) { … }
static bool SDLSearch(const Driver &D, const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
const SmallVectorImpl<std::string> &LibraryPaths,
StringRef Lib, StringRef Arch, StringRef Target,
bool isBitCodeSDL) { … }
static void GetSDLFromOffloadArchive(
Compilation &C, const Driver &D, const Tool &T, const JobAction &JA,
const InputInfoList &Inputs, const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
const SmallVectorImpl<std::string> &LibraryPaths, StringRef Lib,
StringRef Arch, StringRef Target, bool isBitCodeSDL) { … }
void tools::AddStaticDeviceLibsLinking(Compilation &C, const Tool &T,
const JobAction &JA,
const InputInfoList &Inputs,
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
StringRef Arch, StringRef Target,
bool isBitCodeSDL) { … }
void tools::AddStaticDeviceLibs(Compilation *C, const Tool *T,
const JobAction *JA,
const InputInfoList *Inputs, const Driver &D,
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
StringRef Arch, StringRef Target,
bool isBitCodeSDL) { … }
static llvm::opt::Arg *
getAMDGPUCodeObjectArgument(const Driver &D, const llvm::opt::ArgList &Args) { … }
void tools::checkAMDGPUCodeObjectVersion(const Driver &D,
const llvm::opt::ArgList &Args) { … }
unsigned tools::getAMDGPUCodeObjectVersion(const Driver &D,
const llvm::opt::ArgList &Args) { … }
bool tools::haveAMDGPUCodeObjectVersionArgument(
const Driver &D, const llvm::opt::ArgList &Args) { … }
void tools::addMachineOutlinerArgs(const Driver &D,
const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
const llvm::Triple &Triple, bool IsLTO,
const StringRef PluginOptPrefix) { … }
void tools::addOpenMPDeviceRTL(const Driver &D,
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
StringRef BitcodeSuffix,
const llvm::Triple &Triple,
const ToolChain &HostTC) { … }
void tools::addHIPRuntimeLibArgs(const ToolChain &TC, Compilation &C,
const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) { … }
void tools::addOutlineAtomicsArgs(const Driver &D, const ToolChain &TC,
const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
const llvm::Triple &Triple) { … }
void tools::addOffloadCompressArgs(const llvm::opt::ArgList &TCArgs,
llvm::opt::ArgStringList &CmdArgs) { … }
void tools::addMCModel(const Driver &D, const llvm::opt::ArgList &Args,
const llvm::Triple &Triple,
const llvm::Reloc::Model &RelocationModel,
llvm::opt::ArgStringList &CmdArgs) { … }
void tools::handleColorDiagnosticsArgs(const Driver &D, const ArgList &Args,
ArgStringList &CmdArgs) { … }