From 796ac80b863ed92c3d8bcc296f678ff416afc8a8 Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Mon, 11 Feb 2019 23:13:08 +0000 Subject: 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 --- .../SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp') diff --git a/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp b/lldb/source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp index 6dca6b650f5..513bdb3cc5c 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 + using namespace lldb; using namespace lldb_private; @@ -495,9 +497,9 @@ ThreadSP SystemRuntimeMacOSX::GetExtendedBacktraceThread(ThreadSP real_thread, 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( *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 @@ SystemRuntimeMacOSX::GetExtendedBacktraceFromItemRef(lldb::addr_t item_ref) { 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( *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 @@ SystemRuntimeMacOSX::GetExtendedBacktraceForQueueItem(QueueItemSP queue_item_sp, 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( + *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()); -- cgit v1.2.3