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
This commit is contained in:
Jonas Devlieghere
2019-02-11 23:13:08 +00:00
parent 6cbc92915a
commit 796ac80b86
98 changed files with 645 additions and 443 deletions

View File

@@ -9,6 +9,7 @@
#ifndef LLDB_DISABLE_PYTHON
#include "OperatingSystemPython.h"
#include "Plugins/Process/Utility/DynamicRegisterInfo.h"
#include "Plugins/Process/Utility/RegisterContextDummy.h"
#include "Plugins/Process/Utility/RegisterContextMemory.h"
@@ -31,6 +32,8 @@
#include "lldb/Utility/StreamString.h"
#include "lldb/Utility/StructuredData.h"
#include <memory>
using namespace lldb;
using namespace lldb_private;
@@ -259,8 +262,8 @@ ThreadSP OperatingSystemPython::CreateThreadFromThreadInfo(
if (!thread_sp) {
if (did_create_ptr)
*did_create_ptr = true;
thread_sp.reset(
new ThreadMemory(*m_process, tid, name, queue, reg_data_addr));
thread_sp = std::make_shared<ThreadMemory>(*m_process, tid, name, queue,
reg_data_addr);
}
if (core_number < core_thread_list.GetSize(false)) {
@@ -321,8 +324,8 @@ OperatingSystemPython::CreateRegisterContextForThread(Thread *thread,
"= 0x%" PRIx64 ", 0x%" PRIx64 ", reg_data_addr = 0x%" PRIx64
") creating memory register context",
thread->GetID(), thread->GetProtocolID(), reg_data_addr);
reg_ctx_sp.reset(new RegisterContextMemory(
*thread, 0, *GetDynamicRegisterInfo(), reg_data_addr));
reg_ctx_sp = std::make_shared<RegisterContextMemory>(
*thread, 0, *GetDynamicRegisterInfo(), reg_data_addr);
} else {
// No register data address is provided, query the python plug-in to let it
// make up the data as it sees fit
@@ -355,8 +358,8 @@ OperatingSystemPython::CreateRegisterContextForThread(Thread *thread,
log->Printf("OperatingSystemPython::CreateRegisterContextForThread (tid "
"= 0x%" PRIx64 ") forcing a dummy register context",
thread->GetID());
reg_ctx_sp.reset(new RegisterContextDummy(
*thread, 0, target.GetArchitecture().GetAddressByteSize()));
reg_ctx_sp = std::make_shared<RegisterContextDummy>(
*thread, 0, target.GetArchitecture().GetAddressByteSize());
}
return reg_ctx_sp;
}