Skip to content

Commit d03e56b

Browse files
committed
[Driver] Simplify -f[no-]sized-deallocation forwarding. NFC
1 parent 8ccb56c commit d03e56b

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7265,13 +7265,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
72657265

72667266
// -fsized-deallocation is on by default in C++14 onwards and otherwise off
72677267
// by default.
7268-
if (Arg *A = Args.getLastArg(options::OPT_fsized_deallocation,
7269-
options::OPT_fno_sized_deallocation)) {
7270-
if (A->getOption().matches(options::OPT_fno_sized_deallocation))
7271-
CmdArgs.push_back("-fno-sized-deallocation");
7272-
else
7273-
CmdArgs.push_back("-fsized-deallocation");
7274-
}
7268+
Args.addLastArg(CmdArgs, options::OPT_fsized_deallocation,
7269+
options::OPT_fno_sized_deallocation);
72757270

72767271
// -faligned-allocation is on by default in C++17 onwards and otherwise off
72777272
// by default.

llvm/include/llvm/Option/ArgList.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,11 +319,15 @@ class ArgList {
319319
}
320320

321321
/// Render only the last argument match \p Id0, if present.
322-
template<typename ...OptSpecifiers>
323-
void AddLastArg(ArgStringList &Output, OptSpecifiers ...Ids) const {
322+
template <typename... OptSpecifiers>
323+
void addLastArg(ArgStringList &Output, OptSpecifiers... Ids) const {
324324
if (Arg *A = getLastArg(Ids...)) // Calls claim() on all Ids's Args.
325325
A->render(*this, Output);
326326
}
327+
template <typename... OptSpecifiers>
328+
void AddLastArg(ArgStringList &Output, OptSpecifiers... Ids) const {
329+
addLastArg(Output, Ids...);
330+
}
327331

328332
/// AddAllArgsExcept - Render all arguments matching any of the given ids
329333
/// and not matching any of the excluded ids.

0 commit comments

Comments
 (0)