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
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index ef13bd7..f95dc23 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 @@
}
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 @@
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 @@
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 @@
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 @@
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();
}