[clang] aebd232 - [Driver][FreeBSD][NFC] A bit of clean up
Brad Smith via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 11 17:42:47 PST 2023
Author: Brad Smith
Date: 2023-11-11T20:42:37-05:00
New Revision: aebd23204b305c86e8e8d2cd0a072f9df4dc55d5
URL: https://github.com/llvm/llvm-project/commit/aebd23204b305c86e8e8d2cd0a072f9df4dc55d5
DIFF: https://github.com/llvm/llvm-project/commit/aebd23204b305c86e8e8d2cd0a072f9df4dc55d5.diff
LOG: [Driver][FreeBSD][NFC] A bit of clean up
Added:
Modified:
clang/lib/Driver/ToolChains/FreeBSD.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index 264700acc77bf3b..d46feb3459a6344 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -30,13 +30,16 @@ void freebsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
- claimNoWarnArgs(Args);
- ArgStringList CmdArgs;
+ const auto &ToolChain = static_cast<const FreeBSD &>(getToolChain());
const auto &D = getToolChain().getDriver();
+ const llvm::Triple &Triple = ToolChain.getTriple();
+ ArgStringList CmdArgs;
+
+ claimNoWarnArgs(Args);
// When building 32-bit code on FreeBSD/amd64, we have to explicitly
// instruct as in the base system to assemble 32-bit code.
- switch (getToolChain().getArch()) {
+ switch (ToolChain.getArch()) {
default:
break;
case llvm::Triple::x86:
@@ -52,7 +55,7 @@ void freebsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
case llvm::Triple::mips64el: {
StringRef CPUName;
StringRef ABIName;
- mips::getMipsCPUAndABI(Args, getToolChain().getTriple(), CPUName, ABIName);
+ mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
CmdArgs.push_back("-march");
CmdArgs.push_back(CPUName.data());
@@ -60,7 +63,7 @@ void freebsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-mabi");
CmdArgs.push_back(mips::getGnuCompatibleMipsABIName(ABIName).data());
- if (getToolChain().getTriple().isLittleEndian())
+ if (Triple.isLittleEndian())
CmdArgs.push_back("-EL");
else
CmdArgs.push_back("-EB");
@@ -71,14 +74,14 @@ void freebsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
A->claim();
}
- AddAssemblerKPIC(getToolChain(), Args, CmdArgs);
+ AddAssemblerKPIC(ToolChain, Args, CmdArgs);
break;
}
case llvm::Triple::arm:
case llvm::Triple::armeb:
case llvm::Triple::thumb:
case llvm::Triple::thumbeb: {
- arm::FloatABI ABI = arm::getARMFloatABI(getToolChain(), Args);
+ arm::FloatABI ABI = arm::getARMFloatABI(ToolChain, Args);
if (ABI == arm::FloatABI::Hard)
CmdArgs.push_back("-mfpu=vfp");
@@ -89,10 +92,9 @@ void freebsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
break;
}
case llvm::Triple::sparcv9: {
- std::string CPU = getCPUName(D, Args, getToolChain().getTriple());
- CmdArgs.push_back(
- sparc::getSparcAsmModeForCPU(CPU, getToolChain().getTriple()));
- AddAssemblerKPIC(getToolChain(), Args, CmdArgs);
+ std::string CPU = getCPUName(D, Args, Triple);
+ CmdArgs.push_back(sparc::getSparcAsmModeForCPU(CPU, Triple));
+ AddAssemblerKPIC(ToolChain, Args, CmdArgs);
break;
}
}
@@ -118,7 +120,7 @@ void freebsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
for (const auto &II : Inputs)
CmdArgs.push_back(II.getFilename());
- const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as"));
+ const char *Exec = Args.MakeArgString(ToolChain.GetProgramPath("as"));
C.addCommand(std::make_unique<Command>(JA, *this,
ResponseFileSupport::AtFileCurCP(),
Exec, CmdArgs, Inputs, Output));
@@ -366,10 +368,12 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles,
options::OPT_r)) {
+ const char *crtend = nullptr;
if (Args.hasArg(options::OPT_shared) || IsPIE)
- CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtendS.o")));
+ crtend = "crtendS.o";
else
- CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o")));
+ crtend = "crtend.o";
+ CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtend)));
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));
}
More information about the cfe-commits
mailing list