Author: Fangrui Song Date: 2024-05-23T16:03:46-07:00 New Revision: d03e56b27cd992e29482a21d88693f626f3dfffb
URL: https://github.com/llvm/llvm-project/commit/d03e56b27cd992e29482a21d88693f626f3dfffb DIFF: https://github.com/llvm/llvm-project/commit/d03e56b27cd992e29482a21d88693f626f3dfffb.diff LOG: [Driver] Simplify -f[no-]sized-deallocation forwarding. NFC Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp llvm/include/llvm/Option/ArgList.h Removed: ################################################################################ diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 588f0c511cd2e..18de8781e894a 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -7265,13 +7265,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, // -fsized-deallocation is on by default in C++14 onwards and otherwise off // by default. - if (Arg *A = Args.getLastArg(options::OPT_fsized_deallocation, - options::OPT_fno_sized_deallocation)) { - if (A->getOption().matches(options::OPT_fno_sized_deallocation)) - CmdArgs.push_back("-fno-sized-deallocation"); - else - CmdArgs.push_back("-fsized-deallocation"); - } + Args.addLastArg(CmdArgs, options::OPT_fsized_deallocation, + options::OPT_fno_sized_deallocation); // -faligned-allocation is on by default in C++17 onwards and otherwise off // by default. diff --git a/llvm/include/llvm/Option/ArgList.h b/llvm/include/llvm/Option/ArgList.h index fcde68e0b7fe8..09812f976d016 100644 --- a/llvm/include/llvm/Option/ArgList.h +++ b/llvm/include/llvm/Option/ArgList.h @@ -319,11 +319,15 @@ class ArgList { } /// Render only the last argument match \p Id0, if present. - template<typename ...OptSpecifiers> - void AddLastArg(ArgStringList &Output, OptSpecifiers ...Ids) const { + template <typename... OptSpecifiers> + void addLastArg(ArgStringList &Output, OptSpecifiers... Ids) const { if (Arg *A = getLastArg(Ids...)) // Calls claim() on all Ids's Args. A->render(*this, Output); } + template <typename... OptSpecifiers> + void AddLastArg(ArgStringList &Output, OptSpecifiers... Ids) const { + addLastArg(Output, Ids...); + } /// AddAllArgsExcept - Render all arguments matching any of the given ids /// and not matching any of the excluded ids. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits