[Lldb-commits] [lldb] be0586d - [lldb][NFC] Use make_shared when creating Sections (#210196)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Jul 20 14:04:14 PDT 2026
Author: Alex Langford
Date: 2026-07-20T14:04:07-07:00
New Revision: be0586d81e39c051f12d6c231f6eff32a99ded60
URL: https://github.com/llvm/llvm-project/commit/be0586d81e39c051f12d6c231f6eff32a99ded60
DIFF: https://github.com/llvm/llvm-project/commit/be0586d81e39c051f12d6c231f6eff32a99ded60.diff
LOG: [lldb][NFC] Use make_shared when creating Sections (#210196)
Added:
Modified:
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
lldb/unittests/Symbol/JSONSymbolTest.cpp
lldb/unittests/Symbol/SymbolTest.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 50975bddf7776..96b52f2f28d45 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -2165,7 +2165,7 @@ void ObjectFileELF::CreateSections(SectionList &unified_section_list) {
elf::elf_xword log2align =
(header.sh_addralign == 0) ? 0 : llvm::Log2_64(header.sh_addralign);
- SectionSP section_sp(new Section(
+ SectionSP section_sp = std::make_shared<Section>(
InfoOr->Segment, GetModule(), // Module to which this section belongs.
this, // ObjectFile to which this section belongs and should
// read section data from.
@@ -2175,9 +2175,9 @@ void ObjectFileELF::CreateSections(SectionList &unified_section_list) {
InfoOr->Range.GetRangeBase(), // VM address.
InfoOr->Range.GetByteSize(), // VM size in bytes of this section.
header.sh_offset, // Offset of this section in the file.
- file_size, // Size of the section as found in the file.
- log2align, // Alignment of the section
- header.sh_flags)); // Flags for this section.
+ file_size, // Size of the section as found in the file.
+ log2align, // Alignment of the section
+ header.sh_flags); // Flags for this section.
section_sp->SetPermissions(GetPermissions(header));
section_sp->SetIsThreadSpecific(header.sh_flags & SHF_TLS);
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 23a82735b6c99..bfe88256adc67 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -1808,11 +1808,11 @@ void ObjectFileMachO::ProcessSegmentCommand(
lldb::SectionType sect_type = GetSectionType(sect64.flags, section_name);
- SectionSP section_sp(new Section(
+ SectionSP section_sp = std::make_shared<Section>(
segment_sp, module_sp, this, ++context.NextSectionIdx, section_name,
sect_type, sect64.addr - segment_sp->GetFileAddress(), sect64.size,
section_file_offset, section_file_offset == 0 ? 0 : sect64.size,
- sect64.align, sect64.flags));
+ sect64.align, sect64.flags);
// Set the section to be encrypted to match the segment
bool section_is_encrypted = false;
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 15f257f8b0ed4..5207043dde01c 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -1059,7 +1059,7 @@ void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) {
ConstString const_sect_name(sect_name);
SectionType section_type = GetSectionType(sect_name, m_sect_headers[idx]);
- SectionSP section_sp(new Section(
+ SectionSP section_sp = std::make_shared<Section>(
module_sp, // Module to which this section belongs
this, // Object file to which this section belongs
idx + 1, // Section ID is the 1 based section index.
@@ -1074,7 +1074,7 @@ void ObjectFilePECOFF::CreateSections(SectionList &unified_section_list) {
m_sect_headers[idx]
.size, // Size in bytes of this section as found in the file
m_coff_header_opt.sect_alignment, // Section alignment
- m_sect_headers[idx].flags)); // Flags for this section
+ m_sect_headers[idx].flags); // Flags for this section
uint32_t permissions = 0;
if (m_sect_headers[idx].flags & llvm::COFF::IMAGE_SCN_MEM_EXECUTE)
diff --git a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
index 0052488147eb2..a0bd55e533257 100644
--- a/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/XCOFF/ObjectFileXCOFF.cpp
@@ -339,10 +339,10 @@ void ObjectFileXCOFF::CreateSectionsWithBitness(
.Default(eSectionTypeInvalid);
}
- SectionSP section_sp(new Section(
+ SectionSP section_sp = std::make_shared<Section>(
module_sp, this, ++idx, const_sect_name, section_type,
section.VirtualAddress, section.SectionSize,
- section.FileOffsetToRawData, section.SectionSize, 0, section.Flags));
+ section.FileOffsetToRawData, section.SectionSize, 0, section.Flags);
uint32_t permissions = ePermissionsReadable;
if (section.Flags & (XCOFF::STYP_DATA | XCOFF::STYP_BSS))
diff --git a/lldb/unittests/Symbol/JSONSymbolTest.cpp b/lldb/unittests/Symbol/JSONSymbolTest.cpp
index 76c34b89f902f..9fc035b4ff2ce 100644
--- a/lldb/unittests/Symbol/JSONSymbolTest.cpp
+++ b/lldb/unittests/Symbol/JSONSymbolTest.cpp
@@ -38,7 +38,7 @@ TEST(JSONSymbolTest, DeserializeCodeAddress) {
JSONSymbol json_symbol;
ASSERT_TRUE(fromJSON(*json, json_symbol, root));
- SectionSP sect_sp(new Section(
+ SectionSP sect_sp = std::make_shared<Section>(
/*module_sp=*/ModuleSP(),
/*obj_file=*/nullptr,
/*sect_id=*/1,
@@ -49,7 +49,7 @@ TEST(JSONSymbolTest, DeserializeCodeAddress) {
/*file_offset=*/0,
/*file_size=*/0,
/*log2align=*/5,
- /*flags=*/0x10203040));
+ /*flags=*/0x10203040);
SectionList sect_list;
sect_list.AddSection(sect_sp);
@@ -171,7 +171,7 @@ TEST(JSONSymbolTest, SymbolInvalidAddressNotInSection) {
JSONSymbol json_symbol;
json_symbol.address = 0x0fff;
- SectionSP sect_sp(new Section(
+ SectionSP sect_sp = std::make_shared<Section>(
/*module_sp=*/ModuleSP(),
/*obj_file=*/nullptr,
/*sect_id=*/1,
@@ -182,7 +182,7 @@ TEST(JSONSymbolTest, SymbolInvalidAddressNotInSection) {
/*file_offset=*/0,
/*file_size=*/0,
/*log2align=*/5,
- /*flags=*/0x10203040));
+ /*flags=*/0x10203040);
SectionList sect_list;
sect_list.AddSection(sect_sp);
diff --git a/lldb/unittests/Symbol/SymbolTest.cpp b/lldb/unittests/Symbol/SymbolTest.cpp
index 5c3176fe47281..3e67a01a81f64 100644
--- a/lldb/unittests/Symbol/SymbolTest.cpp
+++ b/lldb/unittests/Symbol/SymbolTest.cpp
@@ -48,7 +48,7 @@ static void EncodeDecode(const Symbol &object, const SectionList *sect_list) {
TEST(SymbolTest, EncodeDecodeSymbol) {
- SectionSP sect_sp(new Section(
+ SectionSP sect_sp = std::make_shared<Section>(
/*module_sp=*/ModuleSP(),
/*obj_file=*/nullptr,
/*sect_id=*/1,
@@ -59,7 +59,7 @@ TEST(SymbolTest, EncodeDecodeSymbol) {
/*file_offset=*/0,
/*file_size=*/0,
/*log2align=*/5,
- /*flags=*/0x10203040));
+ /*flags=*/0x10203040);
SectionList sect_list;
sect_list.AddSection(sect_sp);
More information about the lldb-commits
mailing list