Skip to content

Commit 2febc32

Browse files
Use llvm::erase_if (NFC)
1 parent 2b43bd0 commit 2febc32

File tree

5 files changed

+15
-24
lines changed

5 files changed

+15
-24
lines changed

bolt/lib/Core/FunctionLayout.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ void FunctionLayout::eraseBasicBlocks(
7171
unsigned NewFragment = NewFragments.back() + F.size() - ErasedBlocks;
7272
NewFragments.emplace_back(NewFragment);
7373
}
74-
Blocks.erase(std::remove_if(Blocks.begin(), Blocks.end(), IsErased),
75-
Blocks.end());
74+
llvm::erase_if(Blocks, IsErased);
7675
Fragments = std::move(NewFragments);
7776
}
7877

clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,9 @@ static std::string getNameAsString(const NamedDecl *Decl) {
7272
static std::string getExprAsString(const clang::Expr &E,
7373
clang::ASTContext &AC) {
7474
std::string Text = tooling::fixit::getText(E, AC).str();
75-
Text.erase(
76-
llvm::remove_if(
77-
Text,
78-
[](char C) { return llvm::isSpace(static_cast<unsigned char>(C)); }),
79-
Text.end());
75+
llvm::erase_if(Text, [](char C) {
76+
return llvm::isSpace(static_cast<unsigned char>(C));
77+
});
8078
return Text;
8179
}
8280

clang/include/clang/Basic/JsonSupport.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,10 @@ inline void printSourceLocationAsJson(raw_ostream &Out, SourceLocation Loc,
101101
std::string filename(PLoc.getFilename());
102102
if (is_style_windows(llvm::sys::path::Style::native)) {
103103
// Remove forbidden Windows path characters
104-
auto RemoveIt =
105-
std::remove_if(filename.begin(), filename.end(), [](auto Char) {
106-
static const char ForbiddenChars[] = "<>*?\"|";
107-
return llvm::is_contained(ForbiddenChars, Char);
108-
});
109-
filename.erase(RemoveIt, filename.end());
104+
llvm::erase_if(filename, [](auto Char) {
105+
static const char ForbiddenChars[] = "<>*?\"|";
106+
return llvm::is_contained(ForbiddenChars, Char);
107+
});
110108
// Handle windows-specific path delimiters.
111109
std::replace(filename.begin(), filename.end(), '\\', '/');
112110
}

clang/lib/Index/FileIndexRecord.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,11 @@ void FileIndexRecord::addMacroOccurence(SymbolRoleSet Roles, unsigned Offset,
4545
}
4646

4747
void FileIndexRecord::removeHeaderGuardMacros() {
48-
auto It =
49-
std::remove_if(Decls.begin(), Decls.end(), [](const DeclOccurrence &D) {
50-
if (const auto *MI = D.DeclOrMacro.dyn_cast<const MacroInfo *>())
51-
return MI->isUsedForHeaderGuard();
52-
return false;
53-
});
54-
Decls.erase(It, Decls.end());
48+
llvm::erase_if(Decls, [](const DeclOccurrence &D) {
49+
if (const auto *MI = D.DeclOrMacro.dyn_cast<const MacroInfo *>())
50+
return MI->isUsedForHeaderGuard();
51+
return false;
52+
});
5553
}
5654

5755
void FileIndexRecord::print(llvm::raw_ostream &OS, SourceManager &SM) const {

llvm/tools/llvm-nm/llvm-nm.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,10 +2287,8 @@ exportSymbolNamesFromFiles(const std::vector<std::string> &InputFilenames) {
22872287
}
22882288

22892289
// Delete symbols which should not be printed from SymolList.
2290-
SymbolList.erase(
2291-
llvm::remove_if(SymbolList,
2292-
[](const NMSymbol &s) { return !s.shouldPrint(); }),
2293-
SymbolList.end());
2290+
llvm::erase_if(SymbolList,
2291+
[](const NMSymbol &s) { return !s.shouldPrint(); });
22942292
sortSymbolList(SymbolList);
22952293
SymbolList.erase(std::unique(SymbolList.begin(), SymbolList.end()),
22962294
SymbolList.end());

0 commit comments

Comments
 (0)