Skip to content

Commit

Permalink
Add an ArgList::AddAllArgs that accepts a vector of OptSpecifier.
Browse files Browse the repository at this point in the history
This lifts the somewhat arbitrary restriction on 3 OptSpecifiers.

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

llvm-svn: 243539
  • Loading branch information
snuglas committed Jul 29, 2015
1 parent 6093d14 commit f2b9608
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions llvm/include/llvm/Option/ArgList.h
Expand Up @@ -259,6 +259,9 @@ class ArgList {
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;
Expand Down
15 changes: 15 additions & 0 deletions llvm/lib/Option/ArgList.cpp
Expand Up @@ -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)) {
Expand Down

0 comments on commit f2b9608

Please sign in to comment.