From 1c0bbe4341ac0ffbaf2e1f482239b45166607f2d Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Wed, 24 Jun 2020 16:25:05 -0700 Subject: [PATCH] [lldb/API] Use std::make_unique<> (NFC) 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. --- lldb/source/API/SBAddress.cpp | 6 +++--- lldb/source/API/SBBreakpointName.cpp | 13 +++++++------ lldb/source/API/SBCommandInterpreterRunOptions.cpp | 4 ++-- lldb/source/API/SBDeclaration.cpp | 2 +- lldb/source/API/SBError.cpp | 2 +- lldb/source/API/SBLineEntry.cpp | 2 +- lldb/source/API/SBProcessInfo.cpp | 2 +- lldb/source/API/SBSourceManager.cpp | 8 ++++---- lldb/source/API/SBStream.cpp | 2 +- lldb/source/API/SBStringList.cpp | 8 ++++---- lldb/source/API/SBSymbolContext.cpp | 4 ++-- lldb/source/API/SBType.cpp | 8 ++++---- lldb/source/API/SBTypeEnumMember.cpp | 2 +- lldb/source/API/SBTypeSummary.cpp | 6 +++--- lldb/source/API/SBValueList.cpp | 8 ++++---- lldb/source/API/SBVariablesOptions.cpp | 2 +- 16 files changed, 40 insertions(+), 39 deletions(-) diff --git a/lldb/source/API/SBAddress.cpp b/lldb/source/API/SBAddress.cpp index d2b9b80..6444a00 100644 --- a/lldb/source/API/SBAddress.cpp +++ b/lldb/source/API/SBAddress.cpp @@ -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
(); } 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
(); } 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
(); return *m_opaque_up; } diff --git a/lldb/source/API/SBBreakpointName.cpp b/lldb/source/API/SBBreakpointName.cpp index e5a0dbc..3995def 100644 --- a/lldb/source/API/SBBreakpointName.cpp +++ b/lldb/source/API/SBBreakpointName.cpp @@ -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(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(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( + 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(rhs.m_impl_up->GetTarget(), + rhs.m_impl_up->GetName()); return LLDB_RECORD_RESULT(*this); } diff --git a/lldb/source/API/SBCommandInterpreterRunOptions.cpp b/lldb/source/API/SBCommandInterpreterRunOptions.cpp index 7f880dc..fcfbf5e 100644 --- a/lldb/source/API/SBCommandInterpreterRunOptions.cpp +++ b/lldb/source/API/SBCommandInterpreterRunOptions.cpp @@ -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(); } 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(rhs); } SBCommandInterpreterRunResult::~SBCommandInterpreterRunResult() = default; diff --git a/lldb/source/API/SBDeclaration.cpp b/lldb/source/API/SBDeclaration.cpp index 0377efc3..f1066d6 100644 --- a/lldb/source/API/SBDeclaration.cpp +++ b/lldb/source/API/SBDeclaration.cpp @@ -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(); return *m_opaque_up; } diff --git a/lldb/source/API/SBError.cpp b/lldb/source/API/SBError.cpp index 9efabe4..67c7663 100644 --- a/lldb/source/API/SBError.cpp +++ b/lldb/source/API/SBError.cpp @@ -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(); } lldb_private::Status *SBError::operator->() { return m_opaque_up.get(); } diff --git a/lldb/source/API/SBLineEntry.cpp b/lldb/source/API/SBLineEntry.cpp index 44168df..cefbe3e 100644 --- a/lldb/source/API/SBLineEntry.cpp +++ b/lldb/source/API/SBLineEntry.cpp @@ -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(); return *m_opaque_up; } diff --git a/lldb/source/API/SBProcessInfo.cpp b/lldb/source/API/SBProcessInfo.cpp index aa97b5a..29a9c7b 100644 --- a/lldb/source/API/SBProcessInfo.cpp +++ b/lldb/source/API/SBProcessInfo.cpp @@ -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(); } return *m_opaque_up; } diff --git a/lldb/source/API/SBSourceManager.cpp b/lldb/source/API/SBSourceManager.cpp index 6fe3dac..43c3443 100644 --- a/lldb/source/API/SBSourceManager.cpp +++ b/lldb/source/API/SBSourceManager.cpp @@ -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(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(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(*(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(*(rhs.m_opaque_up.get())); return LLDB_RECORD_RESULT(*this); } diff --git a/lldb/source/API/SBStream.cpp b/lldb/source/API/SBStream.cpp index 0f49c51..eb81153 100644 --- a/lldb/source/API/SBStream.cpp +++ b/lldb/source/API/SBStream.cpp @@ -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(); return *m_opaque_up; } diff --git a/lldb/source/API/SBStringList.cpp b/lldb/source/API/SBStringList.cpp index 5364a4d..d9b0369 100644 --- a/lldb/source/API/SBStringList.cpp +++ b/lldb/source/API/SBStringList.cpp @@ -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(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(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(); 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(); m_opaque_up->AppendList(strings); } diff --git a/lldb/source/API/SBSymbolContext.cpp b/lldb/source/API/SBSymbolContext.cpp index 4878bfe..488d498 100644 --- a/lldb/source/API/SBSymbolContext.cpp +++ b/lldb/source/API/SBSymbolContext.cpp @@ -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(); 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(); return *m_opaque_up; } diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp index 64f9103..852630f 100644 --- a/lldb/source/API/SBType.cpp +++ b/lldb/source/API/SBType.cpp @@ -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(); for (uint32_t i = 0, rhs_size = const_cast(rhs).GetSize(); i < rhs_size; i++) Append(const_cast(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(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(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(); return *m_opaque_up; } diff --git a/lldb/source/API/SBTypeEnumMember.cpp b/lldb/source/API/SBTypeEnumMember.cpp index fd95d6e..43a4891 100644 --- a/lldb/source/API/SBTypeEnumMember.cpp +++ b/lldb/source/API/SBTypeEnumMember.cpp @@ -141,7 +141,7 @@ operator=(const SBTypeEnumMemberList &rhs) { rhs); if (this != &rhs) { - m_opaque_up.reset(new TypeEnumMemberListImpl()); + m_opaque_up = std::make_unique(); for (uint32_t i = 0, rhs_size = const_cast(rhs).GetSize(); i < rhs_size; i++) diff --git a/lldb/source/API/SBTypeSummary.cpp b/lldb/source/API/SBTypeSummary.cpp index e8a6f4c..3800ae9 100644 --- a/lldb/source/API/SBTypeSummary.cpp +++ b/lldb/source/API/SBTypeSummary.cpp @@ -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(); } 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(*lldb_object_ptr); else - m_opaque_up.reset(new TypeSummaryOptions()); + m_opaque_up = std::make_unique(); } SBTypeSummary::SBTypeSummary() : m_opaque_sp() { diff --git a/lldb/source/API/SBValueList.cpp b/lldb/source/API/SBValueList.cpp index d8d40b1..0fd2a59 100644 --- a/lldb/source/API/SBValueList.cpp +++ b/lldb/source/API/SBValueList.cpp @@ -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(*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(*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(*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(); } SBValue SBValueList::FindValueObjectByUID(lldb::user_id_t uid) { diff --git a/lldb/source/API/SBVariablesOptions.cpp b/lldb/source/API/SBVariablesOptions.cpp index 4156377..4ef1636 100644 --- a/lldb/source/API/SBVariablesOptions.cpp +++ b/lldb/source/API/SBVariablesOptions.cpp @@ -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(options.ref()); return LLDB_RECORD_RESULT(*this); } -- 2.7.4