Add an overload of getLastArgNoClaim taking two OptSpecifiers.
authorEhsan Akhgari <ehsan.akhgari@gmail.com>
Fri, 12 Sep 2014 19:42:53 +0000 (19:42 +0000)
committerEhsan Akhgari <ehsan.akhgari@gmail.com>
Fri, 12 Sep 2014 19:42:53 +0000 (19:42 +0000)
Summary: This will be used in clang.

Test Plan: Will be tested on the clang side.

Reviewers: hansw

Subscribers: llvm-commits

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

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

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

index d46b0e892faf9d65b813e8e7cb4e384b03b767b0..3f8547e7fe4183c92c28d23e6a3ecb0ae49eb4f9 100644 (file)
@@ -187,6 +187,7 @@ 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 *getLastArg(OptSpecifier Id) const;
   Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1) const;
   Arg *getLastArg(OptSpecifier Id0, OptSpecifier Id1, OptSpecifier Id2) const;
index 5848bb11bfa1cb9dac24c2321dcdaa8a5991566f..041e5522f47a4c1ed02546e64b87b8c32a5177b1 100644 (file)
@@ -54,6 +54,15 @@ Arg *ArgList::getLastArgNoClaim(OptSpecifier Id) const {
   return nullptr;
 }
 
+Arg *ArgList::getLastArgNoClaim(OptSpecifier Id0, OptSpecifier Id1) 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))
+      return *it;
+  return nullptr;
+}
+
 Arg *ArgList::getLastArg(OptSpecifier Id) const {
   Arg *Res = nullptr;
   for (const_iterator it = begin(), ie = end(); it != ie; ++it) {