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/Core/IOHandler.cpp b/lldb/source/Core/IOHandler.cpp
index f3d08ed..b23f49a 100644
--- a/lldb/source/Core/IOHandler.cpp
+++ b/lldb/source/Core/IOHandler.cpp
@@ -995,16 +995,18 @@
                            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 @@
 
   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 @@
             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 @@
         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);
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index a72006c..26611e9 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -87,7 +87,8 @@
 } // namespace
 
 ModuleListProperties::ModuleListProperties() {
-  m_collection_sp.reset(new OptionValueProperties(ConstString("symbols")));
+  m_collection_sp =
+      std::make_shared<OptionValueProperties>(ConstString("symbols"));
   m_collection_sp->Initialize(g_properties);
 
   llvm::SmallString<128> path;
@@ -829,7 +830,7 @@
   if (module_sp)
     return error;
 
-  module_sp.reset(new Module(module_spec));
+  module_sp = std::make_shared<Module>(module_spec);
   // Make sure there are a module and an object file since we can specify a
   // valid file path with an architecture that might not be in that file. By
   // getting the object file we can guarantee that the architecture matches
@@ -871,7 +872,7 @@
 
       auto resolved_module_spec(module_spec);
       resolved_module_spec.GetFileSpec() = search_path_spec;
-      module_sp.reset(new Module(resolved_module_spec));
+      module_sp = std::make_shared<Module>(resolved_module_spec);
       if (module_sp->GetObjectFile()) {
         // If we get in here we got the correct arch, now we just need to
         // verify the UUID if one was given
@@ -970,7 +971,7 @@
     }
 
     if (!module_sp) {
-      module_sp.reset(new Module(platform_module_spec));
+      module_sp = std::make_shared<Module>(platform_module_spec);
       // Make sure there are a module and an object file since we can specify a
       // valid file path with an architecture that might not be in that file.
       // By getting the object file we can guarantee that the architecture
diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index 433733b..b0a1962 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -928,7 +928,7 @@
 
 static bool CopyStringDataToBufferSP(const StreamString &source,
                                      lldb::DataBufferSP &destination) {
-  destination.reset(new DataBufferHeap(source.GetSize() + 1, 0));
+  destination = std::make_shared<DataBufferHeap>(source.GetSize() + 1, 0);
   memcpy(destination->GetBytes(), source.GetString().data(), source.GetSize());
   return true;
 }
@@ -991,7 +991,7 @@
           CopyStringDataToBufferSP(s, buffer_sp);
           return {0, was_capped};
         }
-        buffer_sp.reset(new DataBufferHeap(cstr_len, 0));
+        buffer_sp = std::make_shared<DataBufferHeap>(cstr_len, 0);
         memcpy(buffer_sp->GetBytes(), cstr, cstr_len);
         return {cstr_len, was_capped};
       } else {
@@ -1168,7 +1168,7 @@
     if (my_format != m_last_format || m_value_str.empty()) {
       m_last_format = my_format;
       if (!format_sp)
-        format_sp.reset(new TypeFormatImpl_Format(my_format));
+        format_sp = std::make_shared<TypeFormatImpl_Format>(my_format);
       if (GetValueAsCString(*format_sp.get(), m_value_str)) {
         if (!m_value_did_change && m_old_value_valid) {
           // The value was gotten successfully, so we consider the value as