#include "Clang.h"
#include "AMDGPU.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 "CommonArgs.h"
#include "Hexagon.h"
#include "MSP430.h"
#include "PS4CPU.h"
#include "clang/Basic/CLWarnings.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/CodeGenOptions.h"
#include "clang/Basic/HeaderInclude.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/MakeSupport.h"
#include "clang/Basic/ObjCRuntime.h"
#include "clang/Basic/Version.h"
#include "clang/Config/config.h"
#include "clang/Driver/Action.h"
#include "clang/Driver/Distro.h"
#include "clang/Driver/DriverDiagnostic.h"
#include "clang/Driver/InputInfo.h"
#include "clang/Driver/Options.h"
#include "clang/Driver/SanitizerArgs.h"
#include "clang/Driver/Types.h"
#include "clang/Driver/XRayArgs.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/BinaryFormat/Magic.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/Frontend/Debug/Options.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Option/ArgList.h"
#include "llvm/Support/CodeGen.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/YAMLParser.h"
#include "llvm/TargetParser/AArch64TargetParser.h"
#include "llvm/TargetParser/ARMTargetParserCommon.h"
#include "llvm/TargetParser/Host.h"
#include "llvm/TargetParser/LoongArchTargetParser.h"
#include "llvm/TargetParser/PPCTargetParser.h"
#include "llvm/TargetParser/RISCVISAInfo.h"
#include "llvm/TargetParser/RISCVTargetParser.h"
#include <cctype>
usingnamespaceclang::driver;
usingnamespaceclang::driver::tools;
usingnamespaceclang;
usingnamespacellvm::opt;
static void CheckPreprocessingOptions(const Driver &D, const ArgList &Args) { … }
static void CheckCodeGenerationOptions(const Driver &D, const ArgList &Args) { … }
static void EscapeSpacesAndBackslashes(const char *Arg,
SmallVectorImpl<char> &Res) { … }
static void
forAllAssociatedToolChains(Compilation &C, const JobAction &JA,
const ToolChain &RegularToolChain,
llvm::function_ref<void(const ToolChain &)> Work) { … }
static bool getRefinementStep(StringRef In, const Driver &D,
const Arg &A, size_t &Position) { … }
static void ParseMRecip(const Driver &D, const ArgList &Args,
ArgStringList &OutStrings) { … }
static void ParseMPreferVectorWidth(const Driver &D, const ArgList &Args,
ArgStringList &CmdArgs) { … }
static bool
shouldUseExceptionTablesForObjCExceptions(const ObjCRuntime &runtime,
const llvm::Triple &Triple) { … }
static bool addExceptionArgs(const ArgList &Args, types::ID InputType,
const ToolChain &TC, bool KernelOrKext,
const ObjCRuntime &objcRuntime,
ArgStringList &CmdArgs) { … }
static bool ShouldEnableAutolink(const ArgList &Args, const ToolChain &TC,
const JobAction &JA) { … }
static const char *addDebugCompDirArg(const ArgList &Args,
ArgStringList &CmdArgs,
const llvm::vfs::FileSystem &VFS) { … }
static void addDebugObjectName(const ArgList &Args, ArgStringList &CmdArgs,
const char *DebugCompilationDir,
const char *OutputFileName) { … }
static void addDebugPrefixMapArg(const Driver &D, const ToolChain &TC,
const ArgList &Args, ArgStringList &CmdArgs) { … }
static void addMacroPrefixMapArg(const Driver &D, const ArgList &Args,
ArgStringList &CmdArgs) { … }
static void addCoveragePrefixMapArg(const Driver &D, const ArgList &Args,
ArgStringList &CmdArgs) { … }
static bool shouldEnableVectorizerAtOLevel(const ArgList &Args, bool isSlpVec) { … }
static void addDashXForInput(const ArgList &Args, const InputInfo &Input,
ArgStringList &CmdArgs) { … }
static void addPGOAndCoverageFlags(const ToolChain &TC, Compilation &C,
const JobAction &JA, const InputInfo &Output,
const ArgList &Args, SanitizerArgs &SanArgs,
ArgStringList &CmdArgs) { … }
static void
RenderDebugEnablingArgs(const ArgList &Args, ArgStringList &CmdArgs,
llvm::codegenoptions::DebugInfoKind DebugInfoKind,
unsigned DwarfVersion,
llvm::DebuggerKind DebuggerTuning) { … }
static bool checkDebugInfoOption(const Arg *A, const ArgList &Args,
const Driver &D, const ToolChain &TC) { … }
static void RenderDebugInfoCompressionArgs(const ArgList &Args,
ArgStringList &CmdArgs,
const Driver &D,
const ToolChain &TC) { … }
static void handleAMDGPUCodeObjectVersionOptions(const Driver &D,
const ArgList &Args,
ArgStringList &CmdArgs,
bool IsCC1As = false) { … }
static bool maybeHasClangPchSignature(const Driver &D, StringRef Path) { … }
static bool gchProbe(const Driver &D, StringRef Path) { … }
void Clang::AddPreprocessingOptions(Compilation &C, const JobAction &JA,
const Driver &D, const ArgList &Args,
ArgStringList &CmdArgs,
const InputInfo &Output,
const InputInfoList &Inputs) const { … }
static bool isSignedCharDefault(const llvm::Triple &Triple) { … }
static bool hasMultipleInvocations(const llvm::Triple &Triple,
const ArgList &Args) { … }
static bool checkRemarksOptions(const Driver &D, const ArgList &Args,
const llvm::Triple &Triple) { … }
static void renderRemarksOptions(const ArgList &Args, ArgStringList &CmdArgs,
const llvm::Triple &Triple,
const InputInfo &Input,
const InputInfo &Output, const JobAction &JA) { … }
void AddAAPCSVolatileBitfieldArgs(const ArgList &Args, ArgStringList &CmdArgs) { … }
namespace {
void RenderARMABI(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args, ArgStringList &CmdArgs) { … }
void AddUnalignedAccessWarning(ArgStringList &CmdArgs) { … }
}
static void handlePAuthABI(const ArgList &DriverArgs, ArgStringList &CC1Args) { … }
static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs, bool isAArch64) { … }
void Clang::AddARMTargetArgs(const llvm::Triple &Triple, const ArgList &Args,
ArgStringList &CmdArgs, bool KernelOrKext) const { … }
void Clang::RenderTargetOptions(const llvm::Triple &EffectiveTriple,
const ArgList &Args, bool KernelOrKext,
ArgStringList &CmdArgs) const { … }
namespace {
void RenderAArch64ABI(const llvm::Triple &Triple, const ArgList &Args,
ArgStringList &CmdArgs) { … }
}
void Clang::AddAArch64TargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void Clang::AddLoongArchTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void Clang::AddMIPSTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void Clang::AddPPCTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void Clang::AddRISCVTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void Clang::AddSparcTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void Clang::AddSystemZTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void Clang::AddX86TargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void Clang::AddHexagonTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void Clang::AddLanaiTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void Clang::AddWebAssemblyTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void Clang::AddVETargetArgs(const ArgList &Args, ArgStringList &CmdArgs) const { … }
void Clang::DumpCompilationDatabase(Compilation &C, StringRef Filename,
StringRef Target, const InputInfo &Output,
const InputInfo &Input, const ArgList &Args) const { … }
void Clang::DumpCompilationDatabaseFragmentToDir(
StringRef Dir, Compilation &C, StringRef Target, const InputInfo &Output,
const InputInfo &Input, const llvm::opt::ArgList &Args) const { … }
static bool CheckARMImplicitITArg(StringRef Value) { … }
static void AddARMImplicitITArgs(const ArgList &Args, ArgStringList &CmdArgs,
StringRef Value) { … }
static void CollectArgsForIntegratedAssembler(Compilation &C,
const ArgList &Args,
ArgStringList &CmdArgs,
const Driver &D) { … }
static std::string ComplexRangeKindToStr(LangOptions::ComplexRangeKind Range) { … }
static std::string ComplexArithmeticStr(LangOptions::ComplexRangeKind Range) { … }
static void EmitComplexRangeDiag(const Driver &D, std::string str1,
std::string str2) { … }
static std::string
RenderComplexRangeOption(LangOptions::ComplexRangeKind Range) { … }
static void RenderFloatingPointOptions(const ToolChain &TC, const Driver &D,
bool OFastEnabled, const ArgList &Args,
ArgStringList &CmdArgs,
const JobAction &JA) { … }
static void RenderAnalyzerOptions(const ArgList &Args, ArgStringList &CmdArgs,
const llvm::Triple &Triple,
const InputInfo &Input) { … }
static bool isValidSymbolName(StringRef S) { … }
static void RenderSSPOptions(const Driver &D, const ToolChain &TC,
const ArgList &Args, ArgStringList &CmdArgs,
bool KernelOrKext) { … }
static void RenderSCPOptions(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs) { … }
static void RenderTrivialAutoVarInitOptions(const Driver &D,
const ToolChain &TC,
const ArgList &Args,
ArgStringList &CmdArgs) { … }
static void RenderOpenCLOptions(const ArgList &Args, ArgStringList &CmdArgs,
types::ID InputType) { … }
static void RenderHLSLOptions(const ArgList &Args, ArgStringList &CmdArgs,
types::ID InputType) { … }
static void RenderOpenACCOptions(const Driver &D, const ArgList &Args,
ArgStringList &CmdArgs, types::ID InputType) { … }
static void RenderARCMigrateToolOptions(const Driver &D, const ArgList &Args,
ArgStringList &CmdArgs) { … }
static void RenderBuiltinOptions(const ToolChain &TC, const llvm::Triple &T,
const ArgList &Args, ArgStringList &CmdArgs) { … }
bool Driver::getDefaultModuleCachePath(SmallVectorImpl<char> &Result) { … }
llvm::SmallString<256>
clang::driver::tools::getCXX20NamedModuleOutputPath(const ArgList &Args,
const char *BaseInput) { … }
static bool RenderModulesOptions(Compilation &C, const Driver &D,
const ArgList &Args, const InputInfo &Input,
const InputInfo &Output, bool HaveStd20,
ArgStringList &CmdArgs) { … }
static void RenderCharacterOptions(const ArgList &Args, const llvm::Triple &T,
ArgStringList &CmdArgs) { … }
static void RenderObjCOptions(const ToolChain &TC, const Driver &D,
const llvm::Triple &T, const ArgList &Args,
ObjCRuntime &Runtime, bool InferCovariantReturns,
const InputInfo &Input, ArgStringList &CmdArgs) { … }
static void RenderDiagnosticsOptions(const Driver &D, const ArgList &Args,
ArgStringList &CmdArgs) { … }
DwarfFissionKind tools::getDebugFissionKind(const Driver &D,
const ArgList &Args, Arg *&Arg) { … }
static void renderDwarfFormat(const Driver &D, const llvm::Triple &T,
const ArgList &Args, ArgStringList &CmdArgs,
unsigned DwarfVersion) { … }
static void
renderDebugOptions(const ToolChain &TC, const Driver &D, const llvm::Triple &T,
const ArgList &Args, bool IRInput, ArgStringList &CmdArgs,
const InputInfo &Output,
llvm::codegenoptions::DebugInfoKind &DebugInfoKind,
DwarfFissionKind &DwarfFission) { … }
static void ProcessVSRuntimeLibrary(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs) { … }
void Clang::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output, const InputInfoList &Inputs,
const ArgList &Args, const char *LinkingOutput) const { … }
Clang::Clang(const ToolChain &TC, bool HasIntegratedBackend)
: … { … }
Clang::~Clang() { … }
ObjCRuntime Clang::AddObjCRuntimeArgs(const ArgList &args,
const InputInfoList &inputs,
ArgStringList &cmdArgs,
RewriteKind rewriteKind) const { … }
static bool maybeConsumeDash(const std::string &EH, size_t &I) { … }
namespace {
struct EHFlags { … };
}
static EHFlags parseClangCLEHFlags(const Driver &D, const ArgList &Args,
bool isWindowsMSVC) { … }
void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
ArgStringList &CmdArgs) const { … }
const char *Clang::getBaseInputName(const ArgList &Args,
const InputInfo &Input) { … }
const char *Clang::getBaseInputStem(const ArgList &Args,
const InputInfoList &Inputs) { … }
const char *Clang::getDependencyFileName(const ArgList &Args,
const InputInfoList &Inputs) { … }
void ClangAs::AddMIPSTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void ClangAs::AddX86TargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void ClangAs::AddLoongArchTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void ClangAs::AddRISCVTargetArgs(const ArgList &Args,
ArgStringList &CmdArgs) const { … }
void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output, const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const { … }
void OffloadBundler::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
const llvm::opt::ArgList &TCArgs,
const char *LinkingOutput) const { … }
void OffloadBundler::ConstructJobMultipleOutputs(
Compilation &C, const JobAction &JA, const InputInfoList &Outputs,
const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs,
const char *LinkingOutput) const { … }
void OffloadPackager::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
const llvm::opt::ArgList &Args,
const char *LinkingOutput) const { … }
void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &Output,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const { … }