Switch to an idiomatic C++ erase/remove for this loop, and fix a bug in the

process (I don't believe it's possible to write a testcase for the bug with
a non-checking STL implementation).

llvm-svn: 203042
This commit is contained in:
Richard Smith 2014-03-06 00:33:23 +00:00
parent 2a9d318e4a
commit bb29e518c8
1 changed files with 5 additions and 3 deletions

View File

@ -1684,9 +1684,11 @@ void ASTReader::removeOverriddenMacros(IdentifierInfo *II,
}
// If this macro is already in our list of conflicts, remove it from there.
for (unsigned AI = 0, AN = Ambig.size(); AI != AN; ++AI)
if (Ambig[AI]->getInfo()->getOwningModuleID() == OwnerID)
Ambig.erase(Ambig.begin() + AI);
Ambig.erase(
std::remove_if(Ambig.begin(), Ambig.end(), [&](DefMacroDirective *MD) {
return MD->getInfo()->getOwningModuleID() == OwnerID;
}),
Ambig.end());
}
}