[llvm-objcopy][MachO] Change the storage of sections
In this diff we change the storage of a section to unique_ptr.
This refactoring was factored out from D71647.
Test plan: make check-all
Differential revision: https://reviews.llvm.org/D74946
diff --git a/llvm/tools/llvm-objcopy/MachO/Object.h b/llvm/tools/llvm-objcopy/MachO/Object.h
index eb8db57..a5cb7b1 100644
--- a/llvm/tools/llvm-objcopy/MachO/Object.h
+++ b/llvm/tools/llvm-objcopy/MachO/Object.h
@@ -89,7 +89,7 @@
// though the contents of the sections are stored separately. The struct
// Section describes only sections' metadata and where to find the
// corresponding content inside the binary.
- std::vector<Section> Sections;
+ std::vector<std::unique_ptr<Section>> Sections;
// Returns the segment name if the load command is a segment command.
Optional<StringRef> getSegmentName() const;
@@ -292,7 +292,7 @@
Object() : NewSectionsContents(Alloc) {}
- void removeSections(function_ref<bool(const Section &)> ToRemove);
+ void removeSections(function_ref<bool(const std::unique_ptr<Section> &)> ToRemove);
void addLoadCommand(LoadCommand LC);
/// Creates a new segment load command in the object and returns a reference