Make getLastArgNoClaim work for up to 4 arguments.
authorFilipe Cabecinhas <me@filcab.net>
Fri, 20 Mar 2015 23:32:58 +0000 (23:32 +0000)
committerFilipe Cabecinhas <me@filcab.net>
Fri, 20 Mar 2015 23:32:58 +0000 (23:32 +0000)
Summary:
This is needed for http://reviews.llvm.org/D8507
I have no idea what stand-alone tests could be done, if needed.

Reviewers: Bigcheese, craig.topper, samsonov

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D8508

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232859 91177308-0d34-0410-b5e6-96231b3b80d8

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

index ab3f95dafe25ae4ec0ef5ed742f3aacf17c00905..9a093092faed5b5bf07feee65ca29d7f1baf7e4a 100644 (file)
@@ -190,6 +190,10 @@ public:
   /// \p Claim Whether the argument should be claimed, if it exists.
   Arg *getLastArgNoClaim(OptSpecifier Id) const;
   Arg *getLastArgNoClaim(OptSpecifier Id0, OptSpecifier Id1) const;
+  Arg *getLastArgNoClaim(OptSpecifier Id0, OptSpecifier Id1,
+                         OptSpecifier Id2) const;
+  Arg *getLastArgNoClaim(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2,
+                         OptSpecifier Id3) const;
   Arg *getLastArg(OptSpecifier Id) const;
   Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1) const;
   Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2) const;
index f2547d68842882523459839ee88b01a647c0ae92..4bc8f925e1ba6af4237918a2aa2226a21f5389f1 100644 (file)
@@ -63,6 +63,26 @@ Arg *ArgList::getLastArgNoClaim(OptSpecifier Id0, OptSpecifier Id1) const {
   return nullptr;
 }
 
+Arg *ArgList::getLastArgNoClaim(OptSpecifier Id0, OptSpecifier Id1,
+                                OptSpecifier Id2) const {
+  // FIXME: Make search efficient?
+  for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it)
+    if ((*it)->getOption().matches(Id0) || (*it)->getOption().matches(Id1) ||
+        (*it)->getOption().matches(Id2))
+      return *it;
+  return nullptr;
+}
+
+Arg *ArgList::getLastArgNoClaim(OptSpecifier Id0, OptSpecifier Id1,
+                                OptSpecifier Id2, OptSpecifier Id3) const {
+  // FIXME: Make search efficient?
+  for (const_reverse_iterator it = rbegin(), ie = rend(); it != ie; ++it)
+    if ((*it)->getOption().matches(Id0) || (*it)->getOption().matches(Id1) ||
+        (*it)->getOption().matches(Id2) || (*it)->getOption().matches(Id3))
+      return *it;
+  return nullptr;
+}
+
 Arg *ArgList::getLastArg(OptSpecifier Id) const {
   Arg *Res = nullptr;
   for (const_iterator it = begin(), ie = end(); it != ie; ++it) {