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
This commit is contained in:
Douglas Katzman 2015-07-29 17:34:41 +00:00
parent eb745dc50b
commit de85af6733
2 changed files with 18 additions and 0 deletions

View File

@ -259,6 +259,9 @@ public:
void AddLastArg(ArgStringList &Output, OptSpecifier Id0,
OptSpecifier Id1) const;
/// AddAllArgs - Render all arguments matching any of the given ids.
void AddAllArgs(ArgStringList &Output, ArrayRef<OptSpecifier> Ids) const;
/// AddAllArgs - Render all arguments matching the given ids.
void AddAllArgs(ArgStringList &Output, OptSpecifier Id0,
OptSpecifier Id1 = 0U, OptSpecifier Id2 = 0U) const;

View File

@ -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)) {