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

@@ -995,16 +995,18 @@ public:
bool make_active) {
WindowSP subwindow_sp;
if (m_window) {
subwindow_sp.reset(new Window(
name, ::subwin(m_window, bounds.size.height, bounds.size.width,
subwindow_sp = std::make_shared<Window>(
name,
::subwin(m_window, bounds.size.height, bounds.size.width,
bounds.origin.y, bounds.origin.x),
true));
true);
subwindow_sp->m_is_subwin = true;
} else {
subwindow_sp.reset(
new Window(name, ::newwin(bounds.size.height, bounds.size.width,
bounds.origin.y, bounds.origin.x),
true));
subwindow_sp = std::make_shared<Window>(
name,
::newwin(bounds.size.height, bounds.size.width, bounds.origin.y,
bounds.origin.x),
true);
subwindow_sp->m_is_subwin = false;
}
subwindow_sp->m_parent = this;
@@ -1881,7 +1883,7 @@ public:
WindowSP &GetMainWindow() {
if (!m_window_sp)
m_window_sp.reset(new Window("main", stdscr, false));
m_window_sp = std::make_shared<Window>("main", stdscr, false);
return m_window_sp;
}
@@ -2508,7 +2510,7 @@ public:
return; // Children are already up to date
if (!m_frame_delegate_sp) {
// Always expand the thread item the first time we show it
m_frame_delegate_sp.reset(new FrameTreeDelegate());
m_frame_delegate_sp = std::make_shared<FrameTreeDelegate>();
}
m_stop_id = process_sp->GetStopID();
@@ -2600,7 +2602,8 @@ public:
if (!m_thread_delegate_sp) {
// Always expand the thread item the first time we show it
// item.Expand();
m_thread_delegate_sp.reset(new ThreadTreeDelegate(m_debugger));
m_thread_delegate_sp =
std::make_shared<ThreadTreeDelegate>(m_debugger);
}
TreeItem t(&item, *m_thread_delegate_sp, false);