summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/ObjectFile
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2019-02-11 23:13:08 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2019-02-11 23:13:08 +0000
commit796ac80b863ed92c3d8bcc296f678ff416afc8a8 (patch)
tree2d135344aad0612c190b08cf7fd218d98a2a368b /lldb/source/Plugins/ObjectFile
parent6cbc92915ae8f5cb1d5b265e15858e79c718e7ba (diff)
downloadbcm5719-llvm-796ac80b863ed92c3d8bcc296f678ff416afc8a8.tar.gz
bcm5719-llvm-796ac80b863ed92c3d8bcc296f678ff416afc8a8.zip
Use std::make_shared in LLDB (NFC)
Unlike std::make_unique, which is only available since C++14, std::make_shared is available since C++11. Not only is std::make_shared a lot more readable compared to ::reset(new), it also performs a single heap allocation for the object and control block. Differential revision: https://reviews.llvm.org/D57990 llvm-svn: 353764
Diffstat (limited to 'lldb/source/Plugins/ObjectFile')
-rw-r--r--lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index 4046082c02c..dc583815d65 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -59,6 +59,8 @@
#include <uuid/uuid.h>
#endif
+#include <memory>
+
#define THUMB_ADDRESS_BIT_MASK 0xfffffffffffffffeull
using namespace lldb;
using namespace lldb_private;
@@ -1645,7 +1647,7 @@ void ObjectFileMachO::ProcessSegmentCommand(const load_command &load_cmd_,
// conflict with any of the sections.
SectionSP segment_sp;
if (add_section && (const_segname || is_core)) {
- segment_sp.reset(new Section(
+ segment_sp = std::make_shared<Section>(
module_sp, // Module to which this section belongs
this, // Object file to which this sections belongs
++context.NextSegmentIdx
@@ -1663,7 +1665,7 @@ void ObjectFileMachO::ProcessSegmentCommand(const load_command &load_cmd_,
load_cmd.filesize, // Size in bytes of this section as found
// in the file
0, // Segments have no alignment information
- load_cmd.flags)); // Flags for this section
+ load_cmd.flags); // Flags for this section
segment_sp->SetIsEncrypted(segment_is_encrypted);
m_sections_ap->AddSection(segment_sp);
@@ -1784,7 +1786,7 @@ void ObjectFileMachO::ProcessSegmentCommand(const load_command &load_cmd_,
}
} else {
// Create a fake section for the section's named segment
- segment_sp.reset(new Section(
+ segment_sp = std::make_shared<Section>(
segment_sp, // Parent section
module_sp, // Module to which this section belongs
this, // Object file to which this section belongs
@@ -1805,7 +1807,7 @@ void ObjectFileMachO::ProcessSegmentCommand(const load_command &load_cmd_,
// this section as
// found in the file
sect64.align,
- load_cmd.flags)); // Flags for this section
+ load_cmd.flags); // Flags for this section
segment_sp->SetIsFake(true);
segment_sp->SetPermissions(segment_permissions);
m_sections_ap->AddSection(segment_sp);
@@ -5525,19 +5527,23 @@ ObjectFileMachO::GetThreadContextAtIndex(uint32_t idx,
switch (m_header.cputype) {
case llvm::MachO::CPU_TYPE_ARM64:
- reg_ctx_sp.reset(new RegisterContextDarwin_arm64_Mach(thread, data));
+ reg_ctx_sp =
+ std::make_shared<RegisterContextDarwin_arm64_Mach>(thread, data);
break;
case llvm::MachO::CPU_TYPE_ARM:
- reg_ctx_sp.reset(new RegisterContextDarwin_arm_Mach(thread, data));
+ reg_ctx_sp =
+ std::make_shared<RegisterContextDarwin_arm_Mach>(thread, data);
break;
case llvm::MachO::CPU_TYPE_I386:
- reg_ctx_sp.reset(new RegisterContextDarwin_i386_Mach(thread, data));
+ reg_ctx_sp =
+ std::make_shared<RegisterContextDarwin_i386_Mach>(thread, data);
break;
case llvm::MachO::CPU_TYPE_X86_64:
- reg_ctx_sp.reset(new RegisterContextDarwin_x86_64_Mach(thread, data));
+ reg_ctx_sp =
+ std::make_shared<RegisterContextDarwin_x86_64_Mach>(thread, data);
break;
}
}
OpenPOWER on IntegriCloud