[lldb/API] Use std::make_unique<> (NFC)
authorJonas Devlieghere <jonas@devlieghere.com>
Wed, 24 Jun 2020 23:25:05 +0000 (16:25 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Wed, 24 Jun 2020 23:29:30 +0000 (16:29 -0700)
I was holding off on this change until we moved to C++14 as to not have
to convert llvm::make_unique to std::make_unique. That happened a while
ago so here's the first patch for the API which had a bunch of raw
`new`s.

16 files changed:
lldb/source/API/SBAddress.cpp
lldb/source/API/SBBreakpointName.cpp
lldb/source/API/SBCommandInterpreterRunOptions.cpp
lldb/source/API/SBDeclaration.cpp
lldb/source/API/SBError.cpp
lldb/source/API/SBLineEntry.cpp
lldb/source/API/SBProcessInfo.cpp
lldb/source/API/SBSourceManager.cpp
lldb/source/API/SBStream.cpp
lldb/source/API/SBStringList.cpp
lldb/source/API/SBSymbolContext.cpp
lldb/source/API/SBType.cpp
lldb/source/API/SBTypeEnumMember.cpp
lldb/source/API/SBTypeSummary.cpp
lldb/source/API/SBValueList.cpp
lldb/source/API/SBVariablesOptions.cpp

index d2b9b80..6444a00 100644 (file)
@@ -89,7 +89,7 @@ SBAddress::operator bool() const {
 void SBAddress::Clear() {
   LLDB_RECORD_METHOD_NO_ARGS(void, SBAddress, Clear);
 
-  m_opaque_up.reset(new Address());
+  m_opaque_up = std::make_unique<Address>();
 }
 
 void SBAddress::SetAddress(lldb::SBSection section, lldb::addr_t offset) {
@@ -105,7 +105,7 @@ void SBAddress::SetAddress(const Address *lldb_object_ptr) {
   if (lldb_object_ptr)
     ref() = *lldb_object_ptr;
   else
-    m_opaque_up.reset(new Address());
+    m_opaque_up = std::make_unique<Address>();
 }
 
 lldb::addr_t SBAddress::GetFileAddress() const {
@@ -187,7 +187,7 @@ const Address *SBAddress::operator->() const { return m_opaque_up.get(); }
 
 Address &SBAddress::ref() {
   if (m_opaque_up == nullptr)
-    m_opaque_up.reset(new Address());
+    m_opaque_up = std::make_unique<Address>();
   return *m_opaque_up;
 }
 
index e5a0dbc..3995def 100644 (file)
@@ -115,7 +115,7 @@ SBBreakpointName::SBBreakpointName(SBTarget &sb_target, const char *name) {
   LLDB_RECORD_CONSTRUCTOR(SBBreakpointName, (lldb::SBTarget &, const char *),
                           sb_target, name);
 
-  m_impl_up.reset(new SBBreakpointNameImpl(sb_target, name));
+  m_impl_up = std::make_unique<SBBreakpointNameImpl>(sb_target, name);
   // Call FindBreakpointName here to make sure the name is valid, reset if not:
   BreakpointName *bp_name = GetBreakpointName();
   if (!bp_name)
@@ -133,7 +133,8 @@ SBBreakpointName::SBBreakpointName(SBBreakpoint &sb_bkpt, const char *name) {
   BreakpointSP bkpt_sp = sb_bkpt.GetSP();
   Target &target = bkpt_sp->GetTarget();
 
-  m_impl_up.reset(new SBBreakpointNameImpl(target.shared_from_this(), name));
+  m_impl_up =
+      std::make_unique<SBBreakpointNameImpl>(target.shared_from_this(), name);
 
   // Call FindBreakpointName here to make sure the name is valid, reset if not:
   BreakpointName *bp_name = GetBreakpointName();
@@ -154,8 +155,8 @@ SBBreakpointName::SBBreakpointName(const SBBreakpointName &rhs) {
   if (!rhs.m_impl_up)
     return;
   else
-    m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(),
-                                             rhs.m_impl_up->GetName()));
+    m_impl_up = std::make_unique<SBBreakpointNameImpl>(
+        rhs.m_impl_up->GetTarget(), rhs.m_impl_up->GetName());
 }
 
 SBBreakpointName::~SBBreakpointName() = default;
@@ -171,8 +172,8 @@ operator=(const SBBreakpointName &rhs) {
     return LLDB_RECORD_RESULT(*this);
   }
 
-  m_impl_up.reset(new SBBreakpointNameImpl(rhs.m_impl_up->GetTarget(),
-                                           rhs.m_impl_up->GetName()));
+  m_impl_up = std::make_unique<SBBreakpointNameImpl>(rhs.m_impl_up->GetTarget(),
+                                                     rhs.m_impl_up->GetName());
   return LLDB_RECORD_RESULT(*this);
 }
 
index 7f880dc..fcfbf5e 100644 (file)
@@ -21,7 +21,7 @@ using namespace lldb_private;
 SBCommandInterpreterRunOptions::SBCommandInterpreterRunOptions() {
   LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBCommandInterpreterRunOptions);
 
-  m_opaque_up.reset(new CommandInterpreterRunOptions());
+  m_opaque_up = std::make_unique<CommandInterpreterRunOptions>();
 }
 
 SBCommandInterpreterRunOptions::~SBCommandInterpreterRunOptions() = default;
@@ -182,7 +182,7 @@ SBCommandInterpreterRunResult::SBCommandInterpreterRunResult(
 SBCommandInterpreterRunResult::SBCommandInterpreterRunResult(
     const CommandInterpreterRunResult &rhs)
     : m_opaque_up() {
-  m_opaque_up.reset(new CommandInterpreterRunResult(rhs));
+  m_opaque_up = std::make_unique<CommandInterpreterRunResult>(rhs);
 }
 
 SBCommandInterpreterRunResult::~SBCommandInterpreterRunResult() = default;
index 0377efc..f1066d6 100644 (file)
@@ -148,7 +148,7 @@ const lldb_private::Declaration *SBDeclaration::operator->() const {
 
 lldb_private::Declaration &SBDeclaration::ref() {
   if (m_opaque_up == nullptr)
-    m_opaque_up.reset(new lldb_private::Declaration());
+    m_opaque_up = std::make_unique<lldb_private::Declaration>();
   return *m_opaque_up;
 }
 
index 9efabe4..67c7663 100644 (file)
@@ -149,7 +149,7 @@ SBError::operator bool() const {
 
 void SBError::CreateIfNeeded() {
   if (m_opaque_up == nullptr)
-    m_opaque_up.reset(new Status());
+    m_opaque_up = std::make_unique<Status>();
 }
 
 lldb_private::Status *SBError::operator->() { return m_opaque_up.get(); }
index 44168df..cefbe3e 100644 (file)
@@ -163,7 +163,7 @@ const lldb_private::LineEntry *SBLineEntry::operator->() const {
 
 lldb_private::LineEntry &SBLineEntry::ref() {
   if (m_opaque_up == nullptr)
-    m_opaque_up.reset(new lldb_private::LineEntry());
+    m_opaque_up = std::make_unique<lldb_private::LineEntry>();
   return *m_opaque_up;
 }
 
index aa97b5a..29a9c7b 100644 (file)
@@ -39,7 +39,7 @@ SBProcessInfo &SBProcessInfo::operator=(const SBProcessInfo &rhs) {
 
 ProcessInstanceInfo &SBProcessInfo::ref() {
   if (m_opaque_up == nullptr) {
-    m_opaque_up.reset(new ProcessInstanceInfo());
+    m_opaque_up = std::make_unique<ProcessInstanceInfo>();
   }
   return *m_opaque_up;
 }
index 6fe3dac..43c3443 100644 (file)
@@ -75,13 +75,13 @@ SBSourceManager::SBSourceManager(const SBDebugger &debugger) {
   LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBDebugger &),
                           debugger);
 
-  m_opaque_up.reset(new SourceManagerImpl(debugger.get_sp()));
+  m_opaque_up = std::make_unique<SourceManagerImpl>(debugger.get_sp());
 }
 
 SBSourceManager::SBSourceManager(const SBTarget &target) {
   LLDB_RECORD_CONSTRUCTOR(SBSourceManager, (const lldb::SBTarget &), target);
 
-  m_opaque_up.reset(new SourceManagerImpl(target.GetSP()));
+  m_opaque_up = std::make_unique<SourceManagerImpl>(target.GetSP());
 }
 
 SBSourceManager::SBSourceManager(const SBSourceManager &rhs) {
@@ -91,7 +91,7 @@ SBSourceManager::SBSourceManager(const SBSourceManager &rhs) {
   if (&rhs == this)
     return;
 
-  m_opaque_up.reset(new SourceManagerImpl(*(rhs.m_opaque_up.get())));
+  m_opaque_up = std::make_unique<SourceManagerImpl>(*(rhs.m_opaque_up.get()));
 }
 
 const lldb::SBSourceManager &SBSourceManager::
@@ -100,7 +100,7 @@ operator=(const lldb::SBSourceManager &rhs) {
                      SBSourceManager, operator=,(const lldb::SBSourceManager &),
                      rhs);
 
-  m_opaque_up.reset(new SourceManagerImpl(*(rhs.m_opaque_up.get())));
+  m_opaque_up = std::make_unique<SourceManagerImpl>(*(rhs.m_opaque_up.get()));
   return LLDB_RECORD_RESULT(*this);
 }
 
index 0f49c51..eb81153 100644 (file)
@@ -177,7 +177,7 @@ lldb_private::Stream *SBStream::get() { return m_opaque_up.get(); }
 
 lldb_private::Stream &SBStream::ref() {
   if (m_opaque_up == nullptr)
-    m_opaque_up.reset(new StreamString());
+    m_opaque_up = std::make_unique<StreamString>();
   return *m_opaque_up;
 }
 
index 5364a4d..d9b0369 100644 (file)
@@ -66,7 +66,7 @@ void SBStringList::AppendString(const char *str) {
     if (IsValid())
       m_opaque_up->AppendString(str);
     else
-      m_opaque_up.reset(new lldb_private::StringList(str));
+      m_opaque_up = std::make_unique<lldb_private::StringList>(str);
   }
 }
 
@@ -78,7 +78,7 @@ void SBStringList::AppendList(const char **strv, int strc) {
     if (IsValid())
       m_opaque_up->AppendList(strv, strc);
     else
-      m_opaque_up.reset(new lldb_private::StringList(strv, strc));
+      m_opaque_up = std::make_unique<lldb_private::StringList>(strv, strc);
   }
 }
 
@@ -88,14 +88,14 @@ void SBStringList::AppendList(const SBStringList &strings) {
 
   if (strings.IsValid()) {
     if (!IsValid())
-      m_opaque_up.reset(new lldb_private::StringList());
+      m_opaque_up = std::make_unique<lldb_private::StringList>();
     m_opaque_up->AppendList(*(strings.m_opaque_up));
   }
 }
 
 void SBStringList::AppendList(const StringList &strings) {
   if (!IsValid())
-    m_opaque_up.reset(new lldb_private::StringList());
+    m_opaque_up = std::make_unique<lldb_private::StringList>();
   m_opaque_up->AppendList(strings);
 }
 
index 4878bfe..488d498 100644 (file)
@@ -185,13 +185,13 @@ const lldb_private::SymbolContext &SBSymbolContext::operator*() const {
 
 lldb_private::SymbolContext &SBSymbolContext::operator*() {
   if (m_opaque_up == nullptr)
-    m_opaque_up.reset(new SymbolContext);
+    m_opaque_up = std::make_unique<SymbolContext>();
   return *m_opaque_up;
 }
 
 lldb_private::SymbolContext &SBSymbolContext::ref() {
   if (m_opaque_up == nullptr)
-    m_opaque_up.reset(new SymbolContext);
+    m_opaque_up = std::make_unique<SymbolContext>();
   return *m_opaque_up;
 }
 
index 64f9103..852630f 100644 (file)
@@ -589,7 +589,7 @@ SBTypeList &SBTypeList::operator=(const SBTypeList &rhs) {
                      SBTypeList, operator=,(const lldb::SBTypeList &), rhs);
 
   if (this != &rhs) {
-    m_opaque_up.reset(new TypeListImpl());
+    m_opaque_up = std::make_unique<TypeListImpl>();
     for (uint32_t i = 0, rhs_size = const_cast<SBTypeList &>(rhs).GetSize();
          i < rhs_size; i++)
       Append(const_cast<SBTypeList &>(rhs).GetTypeAtIndex(i));
@@ -632,7 +632,7 @@ SBTypeMember::SBTypeMember(const SBTypeMember &rhs) : m_opaque_up() {
 
   if (this != &rhs) {
     if (rhs.IsValid())
-      m_opaque_up.reset(new TypeMemberImpl(rhs.ref()));
+      m_opaque_up = std::make_unique<TypeMemberImpl>(rhs.ref());
   }
 }
 
@@ -642,7 +642,7 @@ lldb::SBTypeMember &SBTypeMember::operator=(const lldb::SBTypeMember &rhs) {
 
   if (this != &rhs) {
     if (rhs.IsValid())
-      m_opaque_up.reset(new TypeMemberImpl(rhs.ref()));
+      m_opaque_up = std::make_unique<TypeMemberImpl>(rhs.ref());
   }
   return LLDB_RECORD_RESULT(*this);
 }
@@ -746,7 +746,7 @@ void SBTypeMember::reset(TypeMemberImpl *type_member_impl) {
 
 TypeMemberImpl &SBTypeMember::ref() {
   if (m_opaque_up == nullptr)
-    m_opaque_up.reset(new TypeMemberImpl());
+    m_opaque_up = std::make_unique<TypeMemberImpl>();
   return *m_opaque_up;
 }
 
index fd95d6e..43a4891 100644 (file)
@@ -141,7 +141,7 @@ operator=(const SBTypeEnumMemberList &rhs) {
       rhs);
 
   if (this != &rhs) {
-    m_opaque_up.reset(new TypeEnumMemberListImpl());
+    m_opaque_up = std::make_unique<TypeEnumMemberListImpl>();
     for (uint32_t i = 0,
                   rhs_size = const_cast<SBTypeEnumMemberList &>(rhs).GetSize();
          i < rhs_size; i++)
index e8a6f4c..3800ae9 100644 (file)
@@ -21,7 +21,7 @@ using namespace lldb_private;
 SBTypeSummaryOptions::SBTypeSummaryOptions() {
   LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeSummaryOptions);
 
-  m_opaque_up.reset(new TypeSummaryOptions());
+  m_opaque_up = std::make_unique<TypeSummaryOptions>();
 }
 
 SBTypeSummaryOptions::SBTypeSummaryOptions(
@@ -111,9 +111,9 @@ SBTypeSummaryOptions::SBTypeSummaryOptions(
 void SBTypeSummaryOptions::SetOptions(
     const lldb_private::TypeSummaryOptions *lldb_object_ptr) {
   if (lldb_object_ptr)
-    m_opaque_up.reset(new TypeSummaryOptions(*lldb_object_ptr));
+    m_opaque_up = std::make_unique<TypeSummaryOptions>(*lldb_object_ptr);
   else
-    m_opaque_up.reset(new TypeSummaryOptions());
+    m_opaque_up = std::make_unique<TypeSummaryOptions>();
 }
 
 SBTypeSummary::SBTypeSummary() : m_opaque_sp() {
index d8d40b1..0fd2a59 100644 (file)
@@ -75,12 +75,12 @@ SBValueList::SBValueList(const SBValueList &rhs) : m_opaque_up() {
   LLDB_RECORD_CONSTRUCTOR(SBValueList, (const lldb::SBValueList &), rhs);
 
   if (rhs.IsValid())
-    m_opaque_up.reset(new ValueListImpl(*rhs));
+    m_opaque_up = std::make_unique<ValueListImpl>(*rhs);
 }
 
 SBValueList::SBValueList(const ValueListImpl *lldb_object_ptr) : m_opaque_up() {
   if (lldb_object_ptr)
-    m_opaque_up.reset(new ValueListImpl(*lldb_object_ptr));
+    m_opaque_up = std::make_unique<ValueListImpl>(*lldb_object_ptr);
 }
 
 SBValueList::~SBValueList() = default;
@@ -107,7 +107,7 @@ const SBValueList &SBValueList::operator=(const SBValueList &rhs) {
 
   if (this != &rhs) {
     if (rhs.IsValid())
-      m_opaque_up.reset(new ValueListImpl(*rhs));
+      m_opaque_up = std::make_unique<ValueListImpl>(*rhs);
     else
       m_opaque_up.reset();
   }
@@ -173,7 +173,7 @@ uint32_t SBValueList::GetSize() const {
 
 void SBValueList::CreateIfNeeded() {
   if (m_opaque_up == nullptr)
-    m_opaque_up.reset(new ValueListImpl());
+    m_opaque_up = std::make_unique<ValueListImpl>();
 }
 
 SBValue SBValueList::FindValueObjectByUID(lldb::user_id_t uid) {
index 4156377..4ef1636 100644 (file)
@@ -97,7 +97,7 @@ operator=(const SBVariablesOptions &options) {
       SBVariablesOptions, operator=,(const lldb::SBVariablesOptions &),
       options);
 
-  m_opaque_up.reset(new VariablesOptionsImpl(options.ref()));
+  m_opaque_up = std::make_unique<VariablesOptionsImpl>(options.ref());
   return LLDB_RECORD_RESULT(*this);
 }