diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2019-02-11 23:13:08 +0000 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2019-02-11 23:13:08 +0000 |
commit | 796ac80b863ed92c3d8bcc296f678ff416afc8a8 (patch) | |
tree | 2d135344aad0612c190b08cf7fd218d98a2a368b /lldb/source/Plugins/Process/MacOSX-Kernel | |
parent | 6cbc92915ae8f5cb1d5b265e15858e79c718e7ba (diff) | |
download | bcm5719-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/Process/MacOSX-Kernel')
-rw-r--r-- | lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp | 13 | ||||
-rw-r--r-- | lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp | 17 |
2 files changed, 17 insertions, 13 deletions
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp index ef13bd73346..f95dc23c3d8 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp @@ -9,6 +9,7 @@ #include <errno.h> #include <stdlib.h> +#include <memory> #include <mutex> #include "lldb/Core/Debugger.h" @@ -63,7 +64,7 @@ public: } PluginProperties() : Properties() { - m_collection_sp.reset(new OptionValueProperties(GetSettingName())); + m_collection_sp = std::make_shared<OptionValueProperties>(GetSettingName()); m_collection_sp->Initialize(g_properties); } @@ -81,7 +82,7 @@ typedef std::shared_ptr<PluginProperties> ProcessKDPPropertiesSP; static const ProcessKDPPropertiesSP &GetGlobalPluginProperties() { static ProcessKDPPropertiesSP g_settings_sp; if (!g_settings_sp) - g_settings_sp.reset(new PluginProperties()); + g_settings_sp = std::make_shared<PluginProperties>(); return g_settings_sp; } @@ -108,7 +109,7 @@ lldb::ProcessSP ProcessKDP::CreateInstance(TargetSP target_sp, const FileSpec *crash_file_path) { lldb::ProcessSP process_sp; if (crash_file_path == NULL) - process_sp.reset(new ProcessKDP(target_sp, listener_sp)); + process_sp = std::make_shared<ProcessKDP>(target_sp, listener_sp); return process_sp; } @@ -505,7 +506,7 @@ lldb::ThreadSP ProcessKDP::GetKernelThread() { ThreadSP thread_sp(m_kernel_thread_wp.lock()); if (!thread_sp) { - thread_sp.reset(new ThreadKDP(*this, g_kernel_tid)); + thread_sp = std::make_shared<ThreadKDP>(*this, g_kernel_tid); m_kernel_thread_wp = thread_sp; } return thread_sp; @@ -1030,7 +1031,7 @@ public: CommandObject *ProcessKDP::GetPluginCommandObject() { if (!m_command_sp) - m_command_sp.reset(new CommandObjectMultiwordProcessKDP( - GetTarget().GetDebugger().GetCommandInterpreter())); + m_command_sp = std::make_shared<CommandObjectMultiwordProcessKDP>( + GetTarget().GetDebugger().GetCommandInterpreter()); return m_command_sp.get(); } diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp index d0e78a8e74d..341c6329ad6 100644 --- a/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp +++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ThreadKDP.cpp @@ -29,6 +29,8 @@ #include "RegisterContextKDP_i386.h" #include "RegisterContextKDP_x86_64.h" +#include <memory> + using namespace lldb; using namespace lldb_private; @@ -98,19 +100,20 @@ ThreadKDP::CreateRegisterContextForFrame(StackFrame *frame) { ->GetCommunication() .GetCPUType()) { case llvm::MachO::CPU_TYPE_ARM: - reg_ctx_sp.reset(new RegisterContextKDP_arm(*this, concrete_frame_idx)); + reg_ctx_sp = + std::make_shared<RegisterContextKDP_arm>(*this, concrete_frame_idx); break; case llvm::MachO::CPU_TYPE_ARM64: - reg_ctx_sp.reset( - new RegisterContextKDP_arm64(*this, concrete_frame_idx)); + reg_ctx_sp = std::make_shared<RegisterContextKDP_arm64>( + *this, concrete_frame_idx); break; case llvm::MachO::CPU_TYPE_I386: - reg_ctx_sp.reset( - new RegisterContextKDP_i386(*this, concrete_frame_idx)); + reg_ctx_sp = std::make_shared<RegisterContextKDP_i386>( + *this, concrete_frame_idx); break; case llvm::MachO::CPU_TYPE_X86_64: - reg_ctx_sp.reset( - new RegisterContextKDP_x86_64(*this, concrete_frame_idx)); + reg_ctx_sp = std::make_shared<RegisterContextKDP_x86_64>( + *this, concrete_frame_idx); break; default: llvm_unreachable("Add CPU type support in KDP"); |