Skip to content

Commit 9692c6a

Browse files
committed
Switch from shared_ptr to just a local
1 parent 98581d9 commit 9692c6a

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

lldb/include/lldb/Core/Section.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ class SectionList {
4646
/// Create an empty list.
4747
SectionList() = default;
4848

49+
SectionList(const SectionList &lhs);
50+
4951
SectionList &operator=(const SectionList &rhs);
5052

5153
size_t AddSection(const lldb::SectionSP &section_sp);
@@ -104,8 +106,8 @@ class SectionList {
104106
// Function that merges two different sections into a new output list. All
105107
// unique sections will be checked for conflict and resolved using the
106108
// supplied merging callback.
107-
static std::shared_ptr<SectionList> Merge(SectionList &lhs, SectionList &rhs,
108-
MergeCallback filter);
109+
static SectionList Merge(SectionList &lhs, SectionList &rhs,
110+
MergeCallback filter);
109111

110112
protected:
111113
collection m_sections;

lldb/source/Core/Section.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,8 @@ bool Section::ContainsOnlyDebugInfo() const {
473473

474474
#pragma mark SectionList
475475

476+
SectionList::SectionList(const SectionList &rhs) : m_sections(rhs.m_sections) {}
477+
476478
SectionList &SectionList::operator=(const SectionList &rhs) {
477479
if (this != &rhs)
478480
m_sections = rhs.m_sections;
@@ -683,18 +685,18 @@ uint64_t SectionList::GetDebugInfoSize() const {
683685
return debug_info_size;
684686
}
685687

686-
std::shared_ptr<SectionList>
687-
SectionList::Merge(SectionList &lhs, SectionList &rhs, MergeCallback filter) {
688-
std::shared_ptr<SectionList> output_sp = std::make_shared<SectionList>();
688+
SectionList SectionList::Merge(SectionList &lhs, SectionList &rhs,
689+
MergeCallback filter) {
690+
SectionList output_list;
689691

690692
// Iterate through all the sections in lhs and see if we have matches in
691693
// the rhs list.
692694
for (const auto &lhs_section : lhs) {
693695
auto rhs_section = rhs.FindSectionByName(lhs_section->GetName());
694696
if (rhs_section)
695-
output_sp->AddSection(filter(lhs_section, rhs_section));
697+
output_list.AddSection(filter(lhs_section, rhs_section));
696698
else
697-
output_sp->AddSection(lhs_section);
699+
output_list.AddSection(lhs_section);
698700
}
699701

700702
// Now that we've visited all possible duplicates, we can iterate over
@@ -704,10 +706,10 @@ SectionList::Merge(SectionList &lhs, SectionList &rhs, MergeCallback filter) {
704706
// Because we already visited everything overlapping between rhs
705707
// and lhs, any section not in lhs is unique and can be output.
706708
if (!lhs_section)
707-
output_sp->AddSection(rhs_section);
709+
output_list.AddSection(rhs_section);
708710
}
709711

710-
return output_sp;
712+
return output_list;
711713
}
712714

713715
namespace llvm {

lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,9 +1992,8 @@ void ObjectFileELF::CreateSections(SectionList &unified_section_list) {
19921992

19931993
// Merge the two adding any new sections, and overwriting any existing
19941994
// sections that are SHT_NOBITS
1995-
std::shared_ptr<SectionList> merged_section_list =
1995+
unified_section_list =
19961996
SectionList::Merge(unified_section_list, *m_sections_up, MergeSections);
1997-
unified_section_list = *merged_section_list;
19981997

19991998
// If there's a .gnu_debugdata section, we'll try to read the .symtab that's
20001999
// embedded in there and replace the one in the original object file (if any).

0 commit comments

Comments
 (0)