summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Option/Arg.h2
-rw-r--r--llvm/lib/Option/ArgList.cpp11
2 files changed, 4 insertions, 9 deletions
diff --git a/llvm/include/llvm/Option/Arg.h b/llvm/include/llvm/Option/Arg.h
index d1e1aa1ce73..dcaa5405ba7 100644
--- a/llvm/include/llvm/Option/Arg.h
+++ b/llvm/include/llvm/Option/Arg.h
@@ -67,7 +67,7 @@ public:
const char *Value0, const char *Value1, const Arg *BaseArg = nullptr);
~Arg();
- const Option getOption() const { return Opt; }
+ const Option &getOption() const { return Opt; }
StringRef getSpelling() const { return Spelling; }
unsigned getIndex() const { return Index; }
diff --git a/llvm/lib/Option/ArgList.cpp b/llvm/lib/Option/ArgList.cpp
index 1f16331e079..a5ab8d747d8 100644
--- a/llvm/lib/Option/ArgList.cpp
+++ b/llvm/lib/Option/ArgList.cpp
@@ -41,14 +41,9 @@ void ArgList::append(Arg *A) {
}
void ArgList::eraseArg(OptSpecifier Id) {
- for (iterator it = begin(), ie = end(); it != ie; ) {
- if ((*it)->getOption().matches(Id)) {
- it = Args.erase(it);
- ie = end();
- } else {
- ++it;
- }
- }
+ Args.erase(std::remove_if(begin(), end(),
+ [=](Arg *A) { return A->getOption().matches(Id); }),
+ end());
}
Arg *ArgList::getLastArgNoClaim(OptSpecifier Id) const {
OpenPOWER on IntegriCloud