[llvm-branch-commits] [llvm] e334c52 - [llvm-objcopy] Use llvm::erase_if (NFC)
Kazu Hirata via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Dec 25 10:18:06 PST 2020
Author: Kazu Hirata
Date: 2020-12-25T10:13:18-08:00
New Revision: e334c52addc591b95bb0c125e8e289abbf3b67af
URL: https://github.com/llvm/llvm-project/commit/e334c52addc591b95bb0c125e8e289abbf3b67af
DIFF: https://github.com/llvm/llvm-project/commit/e334c52addc591b95bb0c125e8e289abbf3b67af.diff
LOG: [llvm-objcopy] Use llvm::erase_if (NFC)
Added:
Modified:
llvm/tools/llvm-objcopy/COFF/Object.cpp
llvm/tools/llvm-objcopy/MachO/Object.cpp
llvm/tools/llvm-objcopy/wasm/Object.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-objcopy/COFF/Object.cpp b/llvm/tools/llvm-objcopy/COFF/Object.cpp
index 2a57f9707055..cf3afe5e545e 100644
--- a/llvm/tools/llvm-objcopy/COFF/Object.cpp
+++ b/llvm/tools/llvm-objcopy/COFF/Object.cpp
@@ -40,17 +40,14 @@ const Symbol *Object::findSymbol(size_t UniqueId) const {
Error Object::removeSymbols(
function_ref<Expected<bool>(const Symbol &)> ToRemove) {
Error Errs = Error::success();
- Symbols.erase(std::remove_if(std::begin(Symbols), std::end(Symbols),
- [ToRemove, &Errs](const Symbol &Sym) {
- Expected<bool> ShouldRemove = ToRemove(Sym);
- if (!ShouldRemove) {
- Errs = joinErrors(std::move(Errs),
- ShouldRemove.takeError());
- return false;
- }
- return *ShouldRemove;
- }),
- std::end(Symbols));
+ llvm::erase_if(Symbols, [ToRemove, &Errs](const Symbol &Sym) {
+ Expected<bool> ShouldRemove = ToRemove(Sym);
+ if (!ShouldRemove) {
+ Errs = joinErrors(std::move(Errs), ShouldRemove.takeError());
+ return false;
+ }
+ return *ShouldRemove;
+ });
updateSymbols();
return Errs;
diff --git a/llvm/tools/llvm-objcopy/MachO/Object.cpp b/llvm/tools/llvm-objcopy/MachO/Object.cpp
index e0a59b180465..cdb97531fb66 100644
--- a/llvm/tools/llvm-objcopy/MachO/Object.cpp
+++ b/llvm/tools/llvm-objcopy/MachO/Object.cpp
@@ -26,9 +26,7 @@ SymbolEntry *SymbolTable::getSymbolByIndex(uint32_t Index) {
void SymbolTable::removeSymbols(
function_ref<bool(const std::unique_ptr<SymbolEntry> &)> ToRemove) {
- Symbols.erase(
- std::remove_if(std::begin(Symbols), std::end(Symbols), ToRemove),
- std::end(Symbols));
+ llvm::erase_if(Symbols, ToRemove);
}
void Object::updateLoadCommandIndexes() {
diff --git a/llvm/tools/llvm-objcopy/wasm/Object.cpp b/llvm/tools/llvm-objcopy/wasm/Object.cpp
index 0c416483663f..e7a2956fedca 100644
--- a/llvm/tools/llvm-objcopy/wasm/Object.cpp
+++ b/llvm/tools/llvm-objcopy/wasm/Object.cpp
@@ -26,9 +26,7 @@ void Object::addSectionWithOwnedContents(
void Object::removeSections(function_ref<bool(const Section &)> ToRemove) {
// TODO: remove reloc sections for the removed section, handle symbols, etc.
- Sections.erase(
- std::remove_if(std::begin(Sections), std::end(Sections), ToRemove),
- std::end(Sections));
+ llvm::erase_if(Sections, ToRemove);
}
} // end namespace wasm
More information about the llvm-branch-commits
mailing list