[clang] Use llvm::erase_if (NFC)

This commit is contained in:
Kazu Hirata 2021-10-17 13:50:29 -07:00
parent dc3382dc2c
commit d245f2e859
15 changed files with 37 additions and 71 deletions

View File

@ -312,8 +312,7 @@ public:
template <typename ExcludePredicate>
bool removeBindings(const ExcludePredicate &Predicate) {
Bindings.erase(std::remove_if(Bindings.begin(), Bindings.end(), Predicate),
Bindings.end());
llvm::erase_if(Bindings, Predicate);
return !Bindings.empty();
}

View File

@ -235,9 +235,7 @@ public:
static void filterGroups(
std::vector<CloneDetector::CloneGroup> &CloneGroups,
llvm::function_ref<bool(const CloneDetector::CloneGroup &)> Filter) {
CloneGroups.erase(
std::remove_if(CloneGroups.begin(), CloneGroups.end(), Filter),
CloneGroups.end());
llvm::erase_if(CloneGroups, Filter);
}
/// Splits the given CloneGroups until the given Compare function returns true

View File

@ -9199,13 +9199,9 @@ void getIntersectionOfProtocols(ASTContext &Context,
// Remove any implied protocols from the list of inherited protocols.
if (!ImpliedProtocols.empty()) {
IntersectionSet.erase(
std::remove_if(IntersectionSet.begin(),
IntersectionSet.end(),
[&](ObjCProtocolDecl *proto) -> bool {
return ImpliedProtocols.count(proto) > 0;
}),
IntersectionSet.end());
llvm::erase_if(IntersectionSet, [&](ObjCProtocolDecl *proto) -> bool {
return ImpliedProtocols.count(proto) > 0;
});
}
// Sort the remaining protocols by name.
@ -11719,13 +11715,9 @@ ASTContext::filterFunctionTargetAttrs(const TargetAttr *TD) const {
assert(TD != nullptr);
ParsedTargetAttr ParsedAttr = TD->parse();
ParsedAttr.Features.erase(
llvm::remove_if(ParsedAttr.Features,
[&](const std::string &Feat) {
return !Target->isValidFeatureName(
StringRef{Feat}.substr(1));
}),
ParsedAttr.Features.end());
llvm::erase_if(ParsedAttr.Features, [&](const std::string &Feat) {
return !Target->isValidFeatureName(StringRef{Feat}.substr(1));
});
return ParsedAttr;
}

View File

@ -671,9 +671,7 @@ CXXRecordDecl::getFinalOverriders(CXXFinalOverriderMap &FinalOverriders) const {
// FIXME: IsHidden reads from Overriding from the middle of a remove_if
// over the same sequence! Is this guaranteed to work?
Overriding.erase(
std::remove_if(Overriding.begin(), Overriding.end(), IsHidden),
Overriding.end());
llvm::erase_if(Overriding, IsHidden);
}
}
}

View File

@ -236,9 +236,7 @@ void Sema::actOnParamCommandDirectionArg(ParamCommandComment *Command,
if (Direction == -1) {
// Try again with whitespace removed.
ArgLower.erase(
std::remove_if(ArgLower.begin(), ArgLower.end(), clang::isWhitespace),
ArgLower.end());
llvm::erase_if(ArgLower, clang::isWhitespace);
Direction = getParamPassDirection(ArgLower);
SourceRange ArgRange(ArgLocBegin, ArgLocEnd);

View File

@ -2156,12 +2156,9 @@ CXXMethodDecl::getCorrespondingMethodInClass(const CXXRecordDecl *RD,
}
// Other candidate final overriders might be overridden by this function.
FinalOverriders.erase(
std::remove_if(FinalOverriders.begin(), FinalOverriders.end(),
[&](CXXMethodDecl *OtherD) {
return recursivelyOverrides(D, OtherD);
}),
FinalOverriders.end());
llvm::erase_if(FinalOverriders, [&](CXXMethodDecl *OtherD) {
return recursivelyOverrides(D, OtherD);
});
FinalOverriders.push_back(D);
};

View File

@ -1084,14 +1084,10 @@ namespace {
void performLifetimeExtension() {
// Disable the cleanups for lifetime-extended temporaries.
CleanupStack.erase(std::remove_if(CleanupStack.begin(),
CleanupStack.end(),
[](Cleanup &C) {
return !C.isDestroyedAtEndOf(
ScopeKind::FullExpression);
}),
CleanupStack.end());
}
llvm::erase_if(CleanupStack, [](Cleanup &C) {
return !C.isDestroyedAtEndOf(ScopeKind::FullExpression);
});
}
/// Throw away any remaining cleanups at the end of evaluation. If any
/// cleanups would have had a side-effect, note that as an unmodeled

View File

@ -425,16 +425,14 @@ void ExternalASTMerger::RemoveSources(llvm::ArrayRef<ImporterSource> Sources) {
logs() << "(ExternalASTMerger*)" << (void *)this
<< " removing source (ASTContext*)" << (void *)&S.getASTContext()
<< "\n";
Importers.erase(
std::remove_if(Importers.begin(), Importers.end(),
[&Sources](std::unique_ptr<ASTImporter> &Importer) -> bool {
for (const ImporterSource &S : Sources) {
if (&Importer->getFromContext() == &S.getASTContext())
return true;
}
return false;
}),
Importers.end());
llvm::erase_if(Importers,
[&Sources](std::unique_ptr<ASTImporter> &Importer) -> bool {
for (const ImporterSource &S : Sources) {
if (&Importer->getFromContext() == &S.getASTContext())
return true;
}
return false;
});
for (OriginMap::iterator OI = Origins.begin(), OE = Origins.end(); OI != OE; ) {
std::pair<const DeclContext *, DCOrigin> Origin = *OI;
bool Erase = false;

View File

@ -3417,10 +3417,9 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) {
Target.getCPUSpecificCPUDispatchFeatures(II->getName(), Features);
llvm::transform(Features, Features.begin(),
[](StringRef Str) { return Str.substr(1); });
Features.erase(std::remove_if(
Features.begin(), Features.end(), [&Target](StringRef Feat) {
return !Target.validateCpuSupports(Feat);
}), Features.end());
llvm::erase_if(Features, [&Target](StringRef Feat) {
return !Target.validateCpuSupports(Feat);
});
Options.emplace_back(cast<llvm::Function>(Func), StringRef{}, Features);
++Index;
}

View File

@ -299,7 +299,7 @@ MultilibSet::multilib_list MultilibSet::filterCopy(FilterCallback F,
}
void MultilibSet::filterInPlace(FilterCallback F, multilib_list &Ms) {
Ms.erase(std::remove_if(Ms.begin(), Ms.end(), F), Ms.end());
llvm::erase_if(Ms, F);
}
raw_ostream &clang::driver::operator<<(raw_ostream &OS, const MultilibSet &MS) {

View File

@ -1069,9 +1069,7 @@ static void
checkAndRemoveNonDriverDiags(SmallVectorImpl<StoredDiagnostic> &StoredDiags) {
// Get rid of stored diagnostics except the ones from the driver which do not
// have a source location.
StoredDiags.erase(
std::remove_if(StoredDiags.begin(), StoredDiags.end(), isNonDriverDiag),
StoredDiags.end());
llvm::erase_if(StoredDiags, isNonDriverDiag);
}
static void checkAndSanitizeDiags(SmallVectorImpl<StoredDiagnostic> &

View File

@ -1151,14 +1151,12 @@ compileModuleImpl(CompilerInstance &ImportingInstance, SourceLocation ImportLoc,
// Remove any macro definitions that are explicitly ignored by the module.
// They aren't supposed to affect how the module is built anyway.
HeaderSearchOptions &HSOpts = Invocation->getHeaderSearchOpts();
PPOpts.Macros.erase(
std::remove_if(PPOpts.Macros.begin(), PPOpts.Macros.end(),
[&HSOpts](const std::pair<std::string, bool> &def) {
llvm::erase_if(
PPOpts.Macros, [&HSOpts](const std::pair<std::string, bool> &def) {
StringRef MacroDef = def.first;
return HSOpts.ModulesIgnoreMacros.count(
llvm::CachedHashString(MacroDef.split('=').first)) > 0;
}),
PPOpts.Macros.end());
});
// If the original compiler invocation had -fmodule-name, pass it through.
Invocation->getLangOpts()->ModuleName =

View File

@ -155,11 +155,8 @@ ModuleMacro *Preprocessor::addModuleMacro(Module *Mod, IdentifierInfo *II,
// If we were the first overrider for any macro, it's no longer a leaf.
auto &LeafMacros = LeafModuleMacros[II];
if (HidAny) {
LeafMacros.erase(std::remove_if(LeafMacros.begin(), LeafMacros.end(),
[](ModuleMacro *MM) {
return MM->NumOverriddenBy != 0;
}),
LeafMacros.end());
llvm::erase_if(LeafMacros,
[](ModuleMacro *MM) { return MM->NumOverriddenBy != 0; });
}
// The new macro is always a leaf macro.

View File

@ -270,8 +270,7 @@ void ModuleManager::removeModules(ModuleIterator First, ModuleMap *modMap) {
I->Imports.remove_if(IsVictim);
I->ImportedBy.remove_if(IsVictim);
}
Roots.erase(std::remove_if(Roots.begin(), Roots.end(), IsVictim),
Roots.end());
llvm::erase_if(Roots, IsVictim);
// Remove the modules from the PCH chain.
for (auto I = First; I != Last; ++I) {

View File

@ -153,8 +153,7 @@ private:
return getDecl(CheckDR) == getDecl(DR) && Pred(Check);
return false;
};
toScanFor.erase(std::remove_if(toScanFor.begin(), toScanFor.end(), P),
toScanFor.end());
llvm::erase_if(toScanFor, P);
}
void CheckExpr(const Expr *E_p) {