[llvm] 2bb4ebb - [llvm-objcopy][ELF][NFC] Remove unneeded methods of Object

Igor Kudrin via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 9 01:44:54 PDT 2021


Author: Igor Kudrin
Date: 2021-08-09T15:44:03+07:00
New Revision: 2bb4ebb19e8893634fd2491d55c127b8ba58e637

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

LOG: [llvm-objcopy][ELF][NFC] Remove unneeded methods of Object

The patch removes mutable accessor methods for sections and segments.
As for now, const variants of them are not used because all callers have
mutable access to an instance of Object. On the other hand, they do not
actually modify the sets, so it looks better to keep only const ones.

Differential Revision: https://reviews.llvm.org/D107652

Added: 
    

Modified: 
    llvm/tools/llvm-objcopy/ELF/Object.h

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-objcopy/ELF/Object.h b/llvm/tools/llvm-objcopy/ELF/Object.h
index 6fd26afa3ca1e..d03eb4d682873 100644
--- a/llvm/tools/llvm-objcopy/ELF/Object.h
+++ b/llvm/tools/llvm-objcopy/ELF/Object.h
@@ -48,12 +48,12 @@ class Object;
 struct Symbol;
 
 class SectionTableRef {
-  MutableArrayRef<std::unique_ptr<SectionBase>> Sections;
+  ArrayRef<std::unique_ptr<SectionBase>> Sections;
 
 public:
-  using iterator = pointee_iterator<std::unique_ptr<SectionBase> *>;
+  using iterator = pointee_iterator<const std::unique_ptr<SectionBase> *>;
 
-  explicit SectionTableRef(MutableArrayRef<std::unique_ptr<SectionBase>> Secs)
+  explicit SectionTableRef(ArrayRef<std::unique_ptr<SectionBase>> Secs)
       : Sections(Secs) {}
   SectionTableRef(const SectionTableRef &) = default;
 
@@ -1022,10 +1022,6 @@ class Object {
   };
 
 public:
-  template <class T>
-  using Range = iterator_range<
-      pointee_iterator<typename std::vector<std::unique_ptr<T>>::iterator>>;
-
   template <class T>
   using ConstRange = iterator_range<pointee_iterator<
       typename std::vector<std::unique_ptr<T>>::const_iterator>>;
@@ -1055,10 +1051,7 @@ class Object {
   SectionIndexSection *SectionIndexTable = nullptr;
 
   void sortSections();
-  SectionTableRef sections() { return SectionTableRef(Sections); }
-  ConstRange<SectionBase> sections() const {
-    return make_pointee_range(Sections);
-  }
+  SectionTableRef sections() const { return SectionTableRef(Sections); }
   iterator_range<
       filter_iterator<pointee_iterator<std::vector<SecPtr>::const_iterator>,
                       decltype(&sectionIsAlloc)>>
@@ -1073,7 +1066,6 @@ class Object {
   }
   SectionTableRef removedSections() { return SectionTableRef(RemovedSections); }
 
-  Range<Segment> segments() { return make_pointee_range(Segments); }
   ConstRange<Segment> segments() const { return make_pointee_range(Segments); }
 
   Error removeSections(bool AllowBrokenLinks,


        


More information about the llvm-commits mailing list