Skip to content

Commit d245f2e

Browse files
[clang] Use llvm::erase_if (NFC)
1 parent dc3382d commit d245f2e

File tree

15 files changed

+37
-71
lines changed

15 files changed

+37
-71
lines changed

clang/include/clang/ASTMatchers/ASTMatchersInternal.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,7 @@ class BoundNodesTreeBuilder {
312312

313313
template <typename ExcludePredicate>
314314
bool removeBindings(const ExcludePredicate &Predicate) {
315-
Bindings.erase(std::remove_if(Bindings.begin(), Bindings.end(), Predicate),
316-
Bindings.end());
315+
llvm::erase_if(Bindings, Predicate);
317316
return !Bindings.empty();
318317
}
319318

clang/include/clang/Analysis/CloneDetection.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,7 @@ class CloneConstraint {
235235
static void filterGroups(
236236
std::vector<CloneDetector::CloneGroup> &CloneGroups,
237237
llvm::function_ref<bool(const CloneDetector::CloneGroup &)> Filter) {
238-
CloneGroups.erase(
239-
std::remove_if(CloneGroups.begin(), CloneGroups.end(), Filter),
240-
CloneGroups.end());
238+
llvm::erase_if(CloneGroups, Filter);
241239
}
242240

243241
/// Splits the given CloneGroups until the given Compare function returns true

clang/lib/AST/ASTContext.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9199,13 +9199,9 @@ void getIntersectionOfProtocols(ASTContext &Context,
91999199

92009200
// Remove any implied protocols from the list of inherited protocols.
92019201
if (!ImpliedProtocols.empty()) {
9202-
IntersectionSet.erase(
9203-
std::remove_if(IntersectionSet.begin(),
9204-
IntersectionSet.end(),
9205-
[&](ObjCProtocolDecl *proto) -> bool {
9206-
return ImpliedProtocols.count(proto) > 0;
9207-
}),
9208-
IntersectionSet.end());
9202+
llvm::erase_if(IntersectionSet, [&](ObjCProtocolDecl *proto) -> bool {
9203+
return ImpliedProtocols.count(proto) > 0;
9204+
});
92099205
}
92109206

92119207
// Sort the remaining protocols by name.
@@ -11719,13 +11715,9 @@ ASTContext::filterFunctionTargetAttrs(const TargetAttr *TD) const {
1171911715
assert(TD != nullptr);
1172011716
ParsedTargetAttr ParsedAttr = TD->parse();
1172111717

11722-
ParsedAttr.Features.erase(
11723-
llvm::remove_if(ParsedAttr.Features,
11724-
[&](const std::string &Feat) {
11725-
return !Target->isValidFeatureName(
11726-
StringRef{Feat}.substr(1));
11727-
}),
11728-
ParsedAttr.Features.end());
11718+
llvm::erase_if(ParsedAttr.Features, [&](const std::string &Feat) {
11719+
return !Target->isValidFeatureName(StringRef{Feat}.substr(1));
11720+
});
1172911721
return ParsedAttr;
1173011722
}
1173111723

clang/lib/AST/CXXInheritance.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,9 +671,7 @@ CXXRecordDecl::getFinalOverriders(CXXFinalOverriderMap &FinalOverriders) const {
671671

672672
// FIXME: IsHidden reads from Overriding from the middle of a remove_if
673673
// over the same sequence! Is this guaranteed to work?
674-
Overriding.erase(
675-
std::remove_if(Overriding.begin(), Overriding.end(), IsHidden),
676-
Overriding.end());
674+
llvm::erase_if(Overriding, IsHidden);
677675
}
678676
}
679677
}

clang/lib/AST/CommentSema.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,7 @@ void Sema::actOnParamCommandDirectionArg(ParamCommandComment *Command,
236236

237237
if (Direction == -1) {
238238
// Try again with whitespace removed.
239-
ArgLower.erase(
240-
std::remove_if(ArgLower.begin(), ArgLower.end(), clang::isWhitespace),
241-
ArgLower.end());
239+
llvm::erase_if(ArgLower, clang::isWhitespace);
242240
Direction = getParamPassDirection(ArgLower);
243241

244242
SourceRange ArgRange(ArgLocBegin, ArgLocEnd);

clang/lib/AST/DeclCXX.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,12 +2156,9 @@ CXXMethodDecl::getCorrespondingMethodInClass(const CXXRecordDecl *RD,
21562156
}
21572157

21582158
// Other candidate final overriders might be overridden by this function.
2159-
FinalOverriders.erase(
2160-
std::remove_if(FinalOverriders.begin(), FinalOverriders.end(),
2161-
[&](CXXMethodDecl *OtherD) {
2162-
return recursivelyOverrides(D, OtherD);
2163-
}),
2164-
FinalOverriders.end());
2159+
llvm::erase_if(FinalOverriders, [&](CXXMethodDecl *OtherD) {
2160+
return recursivelyOverrides(D, OtherD);
2161+
});
21652162

21662163
FinalOverriders.push_back(D);
21672164
};

clang/lib/AST/ExprConstant.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,14 +1084,10 @@ namespace {
10841084

10851085
void performLifetimeExtension() {
10861086
// Disable the cleanups for lifetime-extended temporaries.
1087-
CleanupStack.erase(std::remove_if(CleanupStack.begin(),
1088-
CleanupStack.end(),
1089-
[](Cleanup &C) {
1090-
return !C.isDestroyedAtEndOf(
1091-
ScopeKind::FullExpression);
1092-
}),
1093-
CleanupStack.end());
1094-
}
1087+
llvm::erase_if(CleanupStack, [](Cleanup &C) {
1088+
return !C.isDestroyedAtEndOf(ScopeKind::FullExpression);
1089+
});
1090+
}
10951091

10961092
/// Throw away any remaining cleanups at the end of evaluation. If any
10971093
/// cleanups would have had a side-effect, note that as an unmodeled

clang/lib/AST/ExternalASTMerger.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -425,16 +425,14 @@ void ExternalASTMerger::RemoveSources(llvm::ArrayRef<ImporterSource> Sources) {
425425
logs() << "(ExternalASTMerger*)" << (void *)this
426426
<< " removing source (ASTContext*)" << (void *)&S.getASTContext()
427427
<< "\n";
428-
Importers.erase(
429-
std::remove_if(Importers.begin(), Importers.end(),
430-
[&Sources](std::unique_ptr<ASTImporter> &Importer) -> bool {
431-
for (const ImporterSource &S : Sources) {
432-
if (&Importer->getFromContext() == &S.getASTContext())
433-
return true;
434-
}
435-
return false;
436-
}),
437-
Importers.end());
428+
llvm::erase_if(Importers,
429+
[&Sources](std::unique_ptr<ASTImporter> &Importer) -> bool {
430+
for (const ImporterSource &S : Sources) {
431+
if (&Importer->getFromContext() == &S.getASTContext())
432+
return true;
433+
}
434+
return false;
435+
});
438436
for (OriginMap::iterator OI = Origins.begin(), OE = Origins.end(); OI != OE; ) {
439437
std::pair<const DeclContext *, DCOrigin> Origin = *OI;
440438
bool Erase = false;

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3417,10 +3417,9 @@ void CodeGenModule::emitCPUDispatchDefinition(GlobalDecl GD) {
34173417
Target.getCPUSpecificCPUDispatchFeatures(II->getName(), Features);
34183418
llvm::transform(Features, Features.begin(),
34193419
[](StringRef Str) { return Str.substr(1); });
3420-
Features.erase(std::remove_if(
3421-
Features.begin(), Features.end(), [&Target](StringRef Feat) {
3422-
return !Target.validateCpuSupports(Feat);
3423-
}), Features.end());
3420+
llvm::erase_if(Features, [&Target](StringRef Feat) {
3421+
return !Target.validateCpuSupports(Feat);
3422+
});
34243423
Options.emplace_back(cast<llvm::Function>(Func), StringRef{}, Features);
34253424
++Index;
34263425
}

clang/lib/Driver/Multilib.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ MultilibSet::multilib_list MultilibSet::filterCopy(FilterCallback F,
299299
}
300300

301301
void MultilibSet::filterInPlace(FilterCallback F, multilib_list &Ms) {
302-
Ms.erase(std::remove_if(Ms.begin(), Ms.end(), F), Ms.end());
302+
llvm::erase_if(Ms, F);
303303
}
304304

305305
raw_ostream &clang::driver::operator<<(raw_ostream &OS, const MultilibSet &MS) {

clang/lib/Frontend/ASTUnit.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,9 +1069,7 @@ static void
10691069
checkAndRemoveNonDriverDiags(SmallVectorImpl<StoredDiagnostic> &StoredDiags) {
10701070
// Get rid of stored diagnostics except the ones from the driver which do not
10711071
// have a source location.
1072-
StoredDiags.erase(
1073-
std::remove_if(StoredDiags.begin(), StoredDiags.end(), isNonDriverDiag),
1074-
StoredDiags.end());
1072+
llvm::erase_if(StoredDiags, isNonDriverDiag);
10751073
}
10761074

10771075
static void checkAndSanitizeDiags(SmallVectorImpl<StoredDiagnostic> &

clang/lib/Frontend/CompilerInstance.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,14 +1151,12 @@ compileModuleImpl(CompilerInstance &ImportingInstance, SourceLocation ImportLoc,
11511151
// Remove any macro definitions that are explicitly ignored by the module.
11521152
// They aren't supposed to affect how the module is built anyway.
11531153
HeaderSearchOptions &HSOpts = Invocation->getHeaderSearchOpts();
1154-
PPOpts.Macros.erase(
1155-
std::remove_if(PPOpts.Macros.begin(), PPOpts.Macros.end(),
1156-
[&HSOpts](const std::pair<std::string, bool> &def) {
1154+
llvm::erase_if(
1155+
PPOpts.Macros, [&HSOpts](const std::pair<std::string, bool> &def) {
11571156
StringRef MacroDef = def.first;
11581157
return HSOpts.ModulesIgnoreMacros.count(
11591158
llvm::CachedHashString(MacroDef.split('=').first)) > 0;
1160-
}),
1161-
PPOpts.Macros.end());
1159+
});
11621160

11631161
// If the original compiler invocation had -fmodule-name, pass it through.
11641162
Invocation->getLangOpts()->ModuleName =

clang/lib/Lex/PPMacroExpansion.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,8 @@ ModuleMacro *Preprocessor::addModuleMacro(Module *Mod, IdentifierInfo *II,
155155
// If we were the first overrider for any macro, it's no longer a leaf.
156156
auto &LeafMacros = LeafModuleMacros[II];
157157
if (HidAny) {
158-
LeafMacros.erase(std::remove_if(LeafMacros.begin(), LeafMacros.end(),
159-
[](ModuleMacro *MM) {
160-
return MM->NumOverriddenBy != 0;
161-
}),
162-
LeafMacros.end());
158+
llvm::erase_if(LeafMacros,
159+
[](ModuleMacro *MM) { return MM->NumOverriddenBy != 0; });
163160
}
164161

165162
// The new macro is always a leaf macro.

clang/lib/Serialization/ModuleManager.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,7 @@ void ModuleManager::removeModules(ModuleIterator First, ModuleMap *modMap) {
270270
I->Imports.remove_if(IsVictim);
271271
I->ImportedBy.remove_if(IsVictim);
272272
}
273-
Roots.erase(std::remove_if(Roots.begin(), Roots.end(), IsVictim),
274-
Roots.end());
273+
llvm::erase_if(Roots, IsVictim);
275274

276275
// Remove the modules from the PCH chain.
277276
for (auto I = First; I != Last; ++I) {

clang/lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ class CheckOverflowOps :
153153
return getDecl(CheckDR) == getDecl(DR) && Pred(Check);
154154
return false;
155155
};
156-
toScanFor.erase(std::remove_if(toScanFor.begin(), toScanFor.end(), P),
157-
toScanFor.end());
156+
llvm::erase_if(toScanFor, P);
158157
}
159158

160159
void CheckExpr(const Expr *E_p) {

0 commit comments

Comments
 (0)