summaryrefslogtreecommitdiff
path: root/lib/Option
diff options
context:
space:
mode:
authorDouglas Katzman <dougk@google.com>2015-07-29 17:34:41 +0000
committerDouglas Katzman <dougk@google.com>2015-07-29 17:34:41 +0000
commitde85af67338e6b592b64e0697d638a96edc2b360 (patch)
treeca5c86a2a4afe4fb60cd2bcdefb99bde29561bb4 /lib/Option
parenteb745dc50b9f97c546f120eb7a510ce9cb264f33 (diff)
Add an ArgList::AddAllArgs that accepts a vector of OptSpecifier.
This lifts the somewhat arbitrary restriction on 3 OptSpecifiers. Differential Revision: http://reviews.llvm.org/D11597 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243539 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Option')
-rw-r--r--lib/Option/ArgList.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Option/ArgList.cpp b/lib/Option/ArgList.cpp
index a74ead6b358..a37f443e56f 100644
--- a/lib/Option/ArgList.cpp
+++ b/lib/Option/ArgList.cpp
@@ -258,6 +258,21 @@ void ArgList::AddLastArg(ArgStringList &Output, OptSpecifier Id0,
}
}
+void ArgList::AddAllArgs(ArgStringList &Output,
+ ArrayRef<OptSpecifier> Ids) const {
+ for (const Arg *Arg : Args) {
+ for (OptSpecifier Id : Ids) {
+ if (Arg->getOption().matches(Id)) {
+ Arg->claim();
+ Arg->render(*this, Output);
+ break;
+ }
+ }
+ }
+}
+
+/// This 3-opt variant of AddAllArgs could be eliminated in favor of one
+/// that accepts a single specifier, given the above which accepts any number.
void ArgList::AddAllArgs(ArgStringList &Output, OptSpecifier Id0,
OptSpecifier Id1, OptSpecifier Id2) const {
for (auto Arg: filtered(Id0, Id1, Id2)) {