]> granicus.if.org Git - llvm/commitdiff
Make AddLastArg() variadic and use it more. No behavior change.
authorNico Weber <nicolasweber@gmx.de>
Wed, 26 Jun 2019 17:51:47 +0000 (17:51 +0000)
committerNico Weber <nicolasweber@gmx.de>
Wed, 26 Jun 2019 17:51:47 +0000 (17:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@364453 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Option/ArgList.h
lib/Option/ArgList.cpp

index a0cd2b8a400c50451e4ecfc66c66681a2b62112a..74bfadcba72675c7d7fb708391b17be4d41fd2fe 100644 (file)
@@ -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<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);
+  }
 
   /// AddAllArgsExcept - Render all arguments matching any of the given ids
   /// and not matching any of the excluded ids.
index 36e2f45fe391d0e0929909364b2051deb3765e1a..f37c142da69ba9d07c3be5d6d9b5434b458755f1 100644 (file)
@@ -95,21 +95,6 @@ std::vector<std::string> ArgList::getAllArgValues(OptSpecifier Id) const {
   return std::vector<std::string>(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<OptSpecifier> Ids,
                                ArrayRef<OptSpecifier> ExcludeIds) const {