[clang] [Driver] Group together usage of AddAllArgs (PR #68349)
Brad Smith via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 5 15:51:20 PDT 2023
https://github.com/brad0 updated https://github.com/llvm/llvm-project/pull/68349
>From c333fbefacc648600fbf84466a60a20cb2331fc3 Mon Sep 17 00:00:00 2001
From: Brad Smith <brad at comstyle.com>
Date: Thu, 5 Oct 2023 16:09:04 -0400
Subject: [PATCH] [Driver] Group together usage of AddAllArgs
---
clang/lib/Driver/ToolChains/DragonFly.cpp | 3 +--
clang/lib/Driver/ToolChains/FreeBSD.cpp | 8 +++-----
clang/lib/Driver/ToolChains/Fuchsia.cpp | 3 +--
clang/lib/Driver/ToolChains/Gnu.cpp | 3 +--
clang/lib/Driver/ToolChains/NaCl.cpp | 3 +--
clang/lib/Driver/ToolChains/NetBSD.cpp | 9 +++------
clang/lib/Driver/ToolChains/PS4CPU.cpp | 8 +++-----
clang/lib/Driver/ToolChains/RISCVToolchain.cpp | 5 +++--
clang/lib/Driver/ToolChains/WebAssembly.cpp | 4 ++--
clang/lib/Driver/ToolChains/ZOS.cpp | 5 ++---
10 files changed, 20 insertions(+), 31 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/DragonFly.cpp b/clang/lib/Driver/ToolChains/DragonFly.cpp
index a1e4937231572b7..da8b1f0cf04c138 100644
--- a/clang/lib/Driver/ToolChains/DragonFly.cpp
+++ b/clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -115,8 +115,7 @@ void dragonfly::Linker::ConstructJob(Compilation &C, const JobAction &JA,
Args.MakeArgString(getToolChain().GetFilePath("crtbegin.o")));
}
- Args.AddAllArgs(CmdArgs,
- {options::OPT_L, options::OPT_T_Group});
+ Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group});
AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp
index ff4d94c56f0d0ff..6b857203531c154 100644
--- a/clang/lib/Driver/ToolChains/FreeBSD.cpp
+++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp
@@ -262,11 +262,9 @@ void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
Args.AddAllArgs(CmdArgs, options::OPT_L);
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
- Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
- Args.AddAllArgs(CmdArgs, options::OPT_s);
- Args.AddAllArgs(CmdArgs, options::OPT_t);
- Args.AddAllArgs(CmdArgs, options::OPT_Z_Flag);
- Args.AddAllArgs(CmdArgs, options::OPT_r);
+ Args.AddAllArgs(CmdArgs,
+ {options::OPT_T_Group, options::OPT_s, options::OPT_t,
+ options::OPT_Z_Flag, options::OPT_r});
if (D.isUsingLTO()) {
assert(!Inputs.empty() && "Must have at least one input.");
diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 55c966ff39cd451..b16d834dc2c7d44 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -133,8 +133,7 @@ void fuchsia::Linker::ConstructJob(Compilation &C, const JobAction &JA,
}
}
- Args.AddAllArgs(CmdArgs, options::OPT_L);
- Args.AddAllArgs(CmdArgs, options::OPT_u);
+ Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_u});
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index 5949d9872c54f72..ae2824690a4f3aa 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -530,8 +530,7 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
ToolChain.addFastMathRuntimeIfAvailable(Args, CmdArgs);
}
- Args.AddAllArgs(CmdArgs, options::OPT_L);
- Args.AddAllArgs(CmdArgs, options::OPT_u);
+ Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_u});
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
diff --git a/clang/lib/Driver/ToolChains/NaCl.cpp b/clang/lib/Driver/ToolChains/NaCl.cpp
index 38151735ee51fa6..a17142fa3beab54 100644
--- a/clang/lib/Driver/ToolChains/NaCl.cpp
+++ b/clang/lib/Driver/ToolChains/NaCl.cpp
@@ -120,8 +120,7 @@ void nacltools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));
}
- Args.AddAllArgs(CmdArgs, options::OPT_L);
- Args.AddAllArgs(CmdArgs, options::OPT_u);
+ Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_u});
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
diff --git a/clang/lib/Driver/ToolChains/NetBSD.cpp b/clang/lib/Driver/ToolChains/NetBSD.cpp
index 54b76ae8c8553ce..9381f3620df85ce 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.cpp
+++ b/clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -266,12 +266,9 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
}
}
- Args.AddAllArgs(CmdArgs, options::OPT_L);
- Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
- Args.AddAllArgs(CmdArgs, options::OPT_s);
- Args.AddAllArgs(CmdArgs, options::OPT_t);
- Args.AddAllArgs(CmdArgs, options::OPT_Z_Flag);
- Args.AddAllArgs(CmdArgs, options::OPT_r);
+ Args.AddAllArgs(CmdArgs,
+ {options::OPT_L, options::OPT_T_Group, options::OPT_s,
+ options::OPT_t, options::OPT_Z_Flag, options::OPT_r});
bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index dd8066abbabd65d..3a8243e1c23a57c 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -208,11 +208,9 @@ void tools::PScpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("--lto=full");
}
- Args.AddAllArgs(CmdArgs, options::OPT_L);
- Args.AddAllArgs(CmdArgs, options::OPT_T_Group);
- Args.AddAllArgs(CmdArgs, options::OPT_s);
- Args.AddAllArgs(CmdArgs, options::OPT_t);
- Args.AddAllArgs(CmdArgs, options::OPT_r);
+ Args.AddAllArgs(CmdArgs,
+ {options::OPT_L, options::OPT_T_Group, options::OPT_s,
+ options::OPT_t, options::OPT_r});
if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
CmdArgs.push_back("--no-demangle");
diff --git a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
index eb990eb80966761..341aed4b135b0d8 100644
--- a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
+++ b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp
@@ -190,9 +190,10 @@ void RISCV::Linker::ConstructJob(Compilation &C, const JobAction &JA,
AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
- Args.AddAllArgs(CmdArgs, options::OPT_L);
- Args.AddAllArgs(CmdArgs, options::OPT_u);
+ Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_u});
+
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
+
Args.AddAllArgs(CmdArgs,
{options::OPT_T_Group, options::OPT_s, options::OPT_t,
options::OPT_Z_Flag, options::OPT_r});
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 2098a68cbc6e567..7048ff051b36442 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -73,8 +73,8 @@ void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (Args.hasArg(options::OPT_s))
CmdArgs.push_back("--strip-all");
- Args.AddAllArgs(CmdArgs, options::OPT_L);
- Args.AddAllArgs(CmdArgs, options::OPT_u);
+ Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_u});
+
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
bool IsCommand = true;
diff --git a/clang/lib/Driver/ToolChains/ZOS.cpp b/clang/lib/Driver/ToolChains/ZOS.cpp
index 05548fbec68b63e..dd693ee05254efd 100644
--- a/clang/lib/Driver/ToolChains/ZOS.cpp
+++ b/clang/lib/Driver/ToolChains/ZOS.cpp
@@ -156,10 +156,9 @@ void zos::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("/dev/null");
}
- Args.AddAllArgs(CmdArgs, options::OPT_u);
-
// Add archive library search paths.
- Args.AddAllArgs(CmdArgs, options::OPT_L);
+ Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_u});
+
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
// Specify linker input file(s)
More information about the cfe-commits
mailing list