Skip to content

Commit f9306f6

Browse files
[ADT] Rename llvm::erase_value to llvm::erase (NFC) (llvm#70156)
C++20 comes with std::erase to erase a value from std::vector. This patch renames llvm::erase_value to llvm::erase for consistency with C++20. We could make llvm::erase more similar to std::erase by having it return the number of elements removed, but I'm not doing that for now because nobody seems to care about that in our code base. Since there are only 50 occurrences of erase_value in our code base, this patch replaces all of them with llvm::erase and deprecates llvm::erase_value.
1 parent f999e1d commit f9306f6

File tree

42 files changed

+57
-51
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+57
-51
lines changed

bolt/lib/Passes/HFSortPlus.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ class HFSortPlus {
567567
Into->Score = score(Into);
568568

569569
// Remove chain From From the list of active chains
570-
llvm::erase_value(HotChains, From);
570+
llvm::erase(HotChains, From);
571571
}
572572

573573
private:

bolt/lib/Passes/IndirectCallPromotion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ IndirectCallPromotion::findCallTargetSymbols(std::vector<Callsite> &Targets,
591591

592592
NewTargets.push_back(Target);
593593
std::vector<uint64_t>({JTIndex}).swap(NewTargets.back().JTIndices);
594-
llvm::erase_value(Target.JTIndices, JTIndex);
594+
llvm::erase(Target.JTIndices, JTIndex);
595595

596596
// Keep fixCFG counts sane if more indices use this same target later
597597
assert(IndicesPerTarget[Target.To.Sym] > 0 && "wrong map");

clang-tools-extra/clangd/FindTarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,7 @@ class ExplicitReferenceCollector
11311131
void reportReference(ReferenceLoc &&Ref, DynTypedNode N) {
11321132
// Strip null targets that can arise from invalid code.
11331133
// (This avoids having to check for null everywhere we insert)
1134-
llvm::erase_value(Ref.Targets, nullptr);
1134+
llvm::erase(Ref.Targets, nullptr);
11351135
// Our promise is to return only references from the source code. If we lack
11361136
// location information, skip these nodes.
11371137
// Normally this should not happen in practice, unless there are bugs in the

clang-tools-extra/clangd/SystemIncludeExtractor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ extractSystemIncludesAndTarget(const DriverArgs &InputArgs,
389389
auto Path = llvm::StringRef(*BuiltinHeaders).trim();
390390
if (!Path.empty() && llvm::sys::path::is_absolute(Path)) {
391391
auto Size = Info->SystemIncludes.size();
392-
llvm::erase_value(Info->SystemIncludes, Path);
392+
llvm::erase(Info->SystemIncludes, Path);
393393
vlog("System includes extractor: builtin headers {0} {1}", Path,
394394
(Info->SystemIncludes.size() != Size)
395395
? "excluded"

clang/include/clang/Analysis/Analyses/Dominators.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ struct ChildrenGetterTy<clang::CFGBlock, IsPostDom> {
202202

203203
auto Children = children<OrderedNodeTy>(N);
204204
ChildrenTy Ret{Children.begin(), Children.end()};
205-
llvm::erase_value(Ret, nullptr);
205+
llvm::erase(Ret, nullptr);
206206
return Ret;
207207
}
208208
};

clang/include/clang/Basic/JsonSupport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ inline std::string JsonFormat(StringRef RawSR, bool AddQuotes) {
7171
}
7272

7373
// Remove new-lines.
74-
llvm::erase_value(Str, '\n');
74+
llvm::erase(Str, '\n');
7575

7676
if (!AddQuotes)
7777
return Str;

clang/include/clang/Sema/ScopeInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ class LambdaScopeInfo final :
10271027
return NonODRUsedCapturingExprs.count(CapturingVarExpr);
10281028
}
10291029
void removePotentialCapture(Expr *E) {
1030-
llvm::erase_value(PotentiallyCapturingExprs, E);
1030+
llvm::erase(PotentiallyCapturingExprs, E);
10311031
}
10321032
void clearPotentialCaptures() {
10331033
PotentiallyCapturingExprs.clear();

clang/lib/AST/ASTContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ void ASTContext::deduplicateMergedDefinitonsFor(NamedDecl *ND) {
10811081
for (Module *&M : Merged)
10821082
if (!Found.insert(M).second)
10831083
M = nullptr;
1084-
llvm::erase_value(Merged, nullptr);
1084+
llvm::erase(Merged, nullptr);
10851085
}
10861086

10871087
ArrayRef<Module *>

clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ computeBlockInputState(const CFGBlock &Block, AnalysisContext &AC) {
307307
auto &StmtToBlock = AC.CFCtx.getStmtToBlock();
308308
auto StmtBlock = StmtToBlock.find(Block.getTerminatorStmt());
309309
assert(StmtBlock != StmtToBlock.end());
310-
llvm::erase_value(Preds, StmtBlock->getSecond());
310+
llvm::erase(Preds, StmtBlock->getSecond());
311311
}
312312
}
313313

clang/lib/Sema/SemaExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18303,7 +18303,7 @@ void Sema::CheckUnusedVolatileAssignment(Expr *E) {
1830318303
if (auto *BO = dyn_cast<BinaryOperator>(E->IgnoreParenImpCasts())) {
1830418304
if (BO->getOpcode() == BO_Assign) {
1830518305
auto &LHSs = ExprEvalContexts.back().VolatileAssignmentLHSs;
18306-
llvm::erase_value(LHSs, BO->getLHS());
18306+
llvm::erase(LHSs, BO->getLHS());
1830718307
}
1830818308
}
1830918309
}

0 commit comments

Comments
 (0)