[llvm-branch-commits] [llvm] f904b46 - [llvm-objcopy] Use llvm::erase_if (NFC)

Kazu Hirata via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Dec 31 09:44:27 PST 2020


Author: Kazu Hirata
Date: 2020-12-31T09:39:09-08:00
New Revision: f904b46b1a965013a51854fafbb63763617e33b3

URL: https://github.com/llvm/llvm-project/commit/f904b46b1a965013a51854fafbb63763617e33b3
DIFF: https://github.com/llvm/llvm-project/commit/f904b46b1a965013a51854fafbb63763617e33b3.diff

LOG: [llvm-objcopy] Use llvm::erase_if (NFC)

Added: 
    

Modified: 
    llvm/tools/llvm-objcopy/COFF/Object.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-objcopy/COFF/Object.cpp b/llvm/tools/llvm-objcopy/COFF/Object.cpp
index cf3afe5e545e..a706000c0df4 100644
--- a/llvm/tools/llvm-objcopy/COFF/Object.cpp
+++ b/llvm/tools/llvm-objcopy/COFF/Object.cpp
@@ -99,31 +99,24 @@ void Object::removeSections(function_ref<bool(const Section &)> ToRemove) {
   };
   do {
     DenseSet<ssize_t> RemovedSections;
-    Sections.erase(
-        std::remove_if(std::begin(Sections), std::end(Sections),
-                       [ToRemove, &RemovedSections](const Section &Sec) {
-                         bool Remove = ToRemove(Sec);
-                         if (Remove)
-                           RemovedSections.insert(Sec.UniqueId);
-                         return Remove;
-                       }),
-        std::end(Sections));
+    llvm::erase_if(Sections, [ToRemove, &RemovedSections](const Section &Sec) {
+      bool Remove = ToRemove(Sec);
+      if (Remove)
+        RemovedSections.insert(Sec.UniqueId);
+      return Remove;
+    });
     // Remove all symbols referring to the removed sections.
     AssociatedSections.clear();
-    Symbols.erase(
-        std::remove_if(
-            std::begin(Symbols), std::end(Symbols),
-            [&RemovedSections, &AssociatedSections](const Symbol &Sym) {
-              // If there are sections that are associative to a removed
-              // section,
-              // remove those as well as nothing will include them (and we can't
-              // leave them dangling).
-              if (RemovedSections.count(Sym.AssociativeComdatTargetSectionId) ==
-                  1)
-                AssociatedSections.insert(Sym.TargetSectionId);
-              return RemovedSections.count(Sym.TargetSectionId) == 1;
-            }),
-        std::end(Symbols));
+    llvm::erase_if(
+        Symbols, [&RemovedSections, &AssociatedSections](const Symbol &Sym) {
+          // If there are sections that are associative to a removed
+          // section,
+          // remove those as well as nothing will include them (and we can't
+          // leave them dangling).
+          if (RemovedSections.count(Sym.AssociativeComdatTargetSectionId) == 1)
+            AssociatedSections.insert(Sym.TargetSectionId);
+          return RemovedSections.count(Sym.TargetSectionId) == 1;
+        });
     ToRemove = RemoveAssociated;
   } while (!AssociatedSections.empty());
   updateSections();


        


More information about the llvm-branch-commits mailing list