[llvm] 2febc32 - Use llvm::erase_if (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 13 12:56:04 PDT 2022
Author: Kazu Hirata
Date: 2022-08-13T12:55:48-07:00
New Revision: 2febc32c9c7dd9d23bb340568ef3178331d9afbe
URL: https://github.com/llvm/llvm-project/commit/2febc32c9c7dd9d23bb340568ef3178331d9afbe
DIFF: https://github.com/llvm/llvm-project/commit/2febc32c9c7dd9d23bb340568ef3178331d9afbe.diff
LOG: Use llvm::erase_if (NFC)
Added:
Modified:
bolt/lib/Core/FunctionLayout.cpp
clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
clang/include/clang/Basic/JsonSupport.h
clang/lib/Index/FileIndexRecord.cpp
llvm/tools/llvm-nm/llvm-nm.cpp
Removed:
################################################################################
diff --git a/bolt/lib/Core/FunctionLayout.cpp b/bolt/lib/Core/FunctionLayout.cpp
index 260fd4649adc7..bedb1c9edf5dd 100644
--- a/bolt/lib/Core/FunctionLayout.cpp
+++ b/bolt/lib/Core/FunctionLayout.cpp
@@ -71,8 +71,7 @@ void FunctionLayout::eraseBasicBlocks(
unsigned NewFragment = NewFragments.back() + F.size() - ErasedBlocks;
NewFragments.emplace_back(NewFragment);
}
- Blocks.erase(std::remove_if(Blocks.begin(), Blocks.end(), IsErased),
- Blocks.end());
+ llvm::erase_if(Blocks, IsErased);
Fragments = std::move(NewFragments);
}
diff --git a/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
index 3b8d205d0483a..02e7ca11f7d60 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ParentVirtualCallCheck.cpp
@@ -72,11 +72,9 @@ static std::string getNameAsString(const NamedDecl *Decl) {
static std::string getExprAsString(const clang::Expr &E,
clang::ASTContext &AC) {
std::string Text = tooling::fixit::getText(E, AC).str();
- Text.erase(
- llvm::remove_if(
- Text,
- [](char C) { return llvm::isSpace(static_cast<unsigned char>(C)); }),
- Text.end());
+ llvm::erase_if(Text, [](char C) {
+ return llvm::isSpace(static_cast<unsigned char>(C));
+ });
return Text;
}
diff --git a/clang/include/clang/Basic/JsonSupport.h b/clang/include/clang/Basic/JsonSupport.h
index 4b8dff382cf70..37f66ab63eb1b 100644
--- a/clang/include/clang/Basic/JsonSupport.h
+++ b/clang/include/clang/Basic/JsonSupport.h
@@ -101,12 +101,10 @@ inline void printSourceLocationAsJson(raw_ostream &Out, SourceLocation Loc,
std::string filename(PLoc.getFilename());
if (is_style_windows(llvm::sys::path::Style::native)) {
// Remove forbidden Windows path characters
- auto RemoveIt =
- std::remove_if(filename.begin(), filename.end(), [](auto Char) {
- static const char ForbiddenChars[] = "<>*?\"|";
- return llvm::is_contained(ForbiddenChars, Char);
- });
- filename.erase(RemoveIt, filename.end());
+ llvm::erase_if(filename, [](auto Char) {
+ static const char ForbiddenChars[] = "<>*?\"|";
+ return llvm::is_contained(ForbiddenChars, Char);
+ });
// Handle windows-specific path delimiters.
std::replace(filename.begin(), filename.end(), '\\', '/');
}
diff --git a/clang/lib/Index/FileIndexRecord.cpp b/clang/lib/Index/FileIndexRecord.cpp
index d4d1d2f70a9a9..f3a5e6b63bbc2 100644
--- a/clang/lib/Index/FileIndexRecord.cpp
+++ b/clang/lib/Index/FileIndexRecord.cpp
@@ -45,13 +45,11 @@ void FileIndexRecord::addMacroOccurence(SymbolRoleSet Roles, unsigned Offset,
}
void FileIndexRecord::removeHeaderGuardMacros() {
- auto It =
- std::remove_if(Decls.begin(), Decls.end(), [](const DeclOccurrence &D) {
- if (const auto *MI = D.DeclOrMacro.dyn_cast<const MacroInfo *>())
- return MI->isUsedForHeaderGuard();
- return false;
- });
- Decls.erase(It, Decls.end());
+ llvm::erase_if(Decls, [](const DeclOccurrence &D) {
+ if (const auto *MI = D.DeclOrMacro.dyn_cast<const MacroInfo *>())
+ return MI->isUsedForHeaderGuard();
+ return false;
+ });
}
void FileIndexRecord::print(llvm::raw_ostream &OS, SourceManager &SM) const {
diff --git a/llvm/tools/llvm-nm/llvm-nm.cpp b/llvm/tools/llvm-nm/llvm-nm.cpp
index f0def8b74e608..e8dbbd4e87bc2 100644
--- a/llvm/tools/llvm-nm/llvm-nm.cpp
+++ b/llvm/tools/llvm-nm/llvm-nm.cpp
@@ -2287,10 +2287,8 @@ exportSymbolNamesFromFiles(const std::vector<std::string> &InputFilenames) {
}
// Delete symbols which should not be printed from SymolList.
- SymbolList.erase(
- llvm::remove_if(SymbolList,
- [](const NMSymbol &s) { return !s.shouldPrint(); }),
- SymbolList.end());
+ llvm::erase_if(SymbolList,
+ [](const NMSymbol &s) { return !s.shouldPrint(); });
sortSymbolList(SymbolList);
SymbolList.erase(std::unique(SymbolList.begin(), SymbolList.end()),
SymbolList.end());
More information about the llvm-commits
mailing list