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/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
index 6dca6b6..513bdb3 100644
--- a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
+++ b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp
@@ -29,6 +29,8 @@
#include "SystemRuntimeMacOSX.h"
+#include <memory>
+
using namespace lldb;
using namespace lldb_private;
@@ -495,9 +497,9 @@
bool stop_id_is_valid = true;
if (item.stop_id == 0)
stop_id_is_valid = false;
- originating_thread_sp.reset(new HistoryThread(
+ originating_thread_sp = std::make_shared<HistoryThread>(
*m_process, item.enqueuing_thread_id, item.enqueuing_callstack,
- item.stop_id, stop_id_is_valid));
+ item.stop_id, stop_id_is_valid);
originating_thread_sp->SetExtendedBacktraceToken(
item.item_that_enqueued_this);
originating_thread_sp->SetQueueName(
@@ -540,9 +542,9 @@
bool stop_id_is_valid = true;
if (item.stop_id == 0)
stop_id_is_valid = false;
- return_thread_sp.reset(new HistoryThread(
+ return_thread_sp = std::make_shared<HistoryThread>(
*m_process, item.enqueuing_thread_id, item.enqueuing_callstack,
- item.stop_id, stop_id_is_valid));
+ item.stop_id, stop_id_is_valid);
return_thread_sp->SetExtendedBacktraceToken(item.item_that_enqueued_this);
return_thread_sp->SetQueueName(item.enqueuing_queue_label.c_str());
return_thread_sp->SetQueueID(item.enqueuing_queue_serialnum);
@@ -567,10 +569,10 @@
if (queue_item_sp->GetStopID() == 0)
stop_id_is_valid = false;
- extended_thread_sp.reset(
- new HistoryThread(*m_process, queue_item_sp->GetEnqueueingThreadID(),
- queue_item_sp->GetEnqueueingBacktrace(),
- queue_item_sp->GetStopID(), stop_id_is_valid));
+ extended_thread_sp = std::make_shared<HistoryThread>(
+ *m_process, queue_item_sp->GetEnqueueingThreadID(),
+ queue_item_sp->GetEnqueueingBacktrace(), queue_item_sp->GetStopID(),
+ stop_id_is_valid);
extended_thread_sp->SetExtendedBacktraceToken(
queue_item_sp->GetItemThatEnqueuedThis());
extended_thread_sp->SetQueueName(queue_item_sp->GetQueueLabel().c_str());