From 4a77e2a0fc8041bd7ccf6776805b8c142e21b043 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 26 Jun 2019 17:51:47 +0000 Subject: [PATCH] Make AddLastArg() variadic and use it more. No behavior change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364453 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Option/ArgList.h | 10 ++++++---- lib/Option/ArgList.cpp | 15 --------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/include/llvm/Option/ArgList.h b/include/llvm/Option/ArgList.h index a0cd2b8a400..74bfadcba72 100644 --- a/include/llvm/Option/ArgList.h +++ b/include/llvm/Option/ArgList.h @@ -301,10 +301,12 @@ public: bool hasFlag(OptSpecifier Pos, OptSpecifier PosAlias, OptSpecifier Neg, bool Default = true) const; - /// AddLastArg - Render only the last argument match \p Id0, if present. - void AddLastArg(ArgStringList &Output, OptSpecifier Id0) const; - void AddLastArg(ArgStringList &Output, OptSpecifier Id0, - OptSpecifier Id1) const; + /// Render only the last argument match \p Id0, if present. + template + void AddLastArg(ArgStringList &Output, OptSpecifiers ...Ids) const { + if (Arg *A = getLastArg(Ids...)) // Calls claim() on all Ids's Args. + A->render(*this, Output); + } /// AddAllArgsExcept - Render all arguments matching any of the given ids /// and not matching any of the excluded ids. diff --git a/lib/Option/ArgList.cpp b/lib/Option/ArgList.cpp index 36e2f45fe39..f37c142da69 100644 --- a/lib/Option/ArgList.cpp +++ b/lib/Option/ArgList.cpp @@ -95,21 +95,6 @@ std::vector ArgList::getAllArgValues(OptSpecifier Id) const { return std::vector(Values.begin(), Values.end()); } -void ArgList::AddLastArg(ArgStringList &Output, OptSpecifier Id) const { - if (Arg *A = getLastArg(Id)) { - A->claim(); - A->render(*this, Output); - } -} - -void ArgList::AddLastArg(ArgStringList &Output, OptSpecifier Id0, - OptSpecifier Id1) const { - if (Arg *A = getLastArg(Id0, Id1)) { - A->claim(); - A->render(*this, Output); - } -} - void ArgList::AddAllArgsExcept(ArgStringList &Output, ArrayRef Ids, ArrayRef ExcludeIds) const { -- 2.40.0