Author: Jonas Devlieghere Date: 2020-06-24T16:29:30-07:00 New Revision: 1c0bbe4341ac0ffbaf2e1f482239b45166607f2d
URL: https://github.com/llvm/llvm-project/commit/1c0bbe4341ac0ffbaf2e1f482239b45166607f2d DIFF: https://github.com/llvm/llvm-project/commit/1c0bbe4341ac0ffbaf2e1f482239b45166607f2d.diff LOG: [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. Added: Modified: 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 Removed: ################################################################################ diff --git a/lldb/source/API/SBAddress.cpp b/lldb/source/API/SBAddress.cpp index d2b9b80973c8..6444a006c0ff 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<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; } diff --git a/lldb/source/API/SBBreakpointName.cpp b/lldb/source/API/SBBreakpointName.cpp index e5a0dbc9ef8e..3995defcf97c 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<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); } diff --git a/lldb/source/API/SBCommandInterpreterRunOptions.cpp b/lldb/source/API/SBCommandInterpreterRunOptions.cpp index 7f880dc4605b..fcfbf5e5401a 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<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; diff --git a/lldb/source/API/SBDeclaration.cpp b/lldb/source/API/SBDeclaration.cpp index 0377efc338a4..f1066d63c06a 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<lldb_private::Declaration>(); return *m_opaque_up; } diff --git a/lldb/source/API/SBError.cpp b/lldb/source/API/SBError.cpp index 9efabe40ce93..67c7663d3583 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<Status>(); } 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 44168dfd5eb9..cefbe3ee1a1e 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<lldb_private::LineEntry>(); return *m_opaque_up; } diff --git a/lldb/source/API/SBProcessInfo.cpp b/lldb/source/API/SBProcessInfo.cpp index aa97b5af4d20..29a9c7b24b5a 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<ProcessInstanceInfo>(); } return *m_opaque_up; } diff --git a/lldb/source/API/SBSourceManager.cpp b/lldb/source/API/SBSourceManager.cpp index 6fe3dac7767d..43c3443672f7 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<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); } diff --git a/lldb/source/API/SBStream.cpp b/lldb/source/API/SBStream.cpp index 0f49c5111f28..eb81153084e8 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<StreamString>(); return *m_opaque_up; } diff --git a/lldb/source/API/SBStringList.cpp b/lldb/source/API/SBStringList.cpp index 5364a4d61c9f..d9b03692ec0e 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<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); } diff --git a/lldb/source/API/SBSymbolContext.cpp b/lldb/source/API/SBSymbolContext.cpp index 4878bfe2e32a..488d49884903 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<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; } diff --git a/lldb/source/API/SBType.cpp b/lldb/source/API/SBType.cpp index 64f9103e411a..852630f2d01a 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<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; } diff --git a/lldb/source/API/SBTypeEnumMember.cpp b/lldb/source/API/SBTypeEnumMember.cpp index fd95d6e34491..43a4891b54b1 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<TypeEnumMemberListImpl>(); for (uint32_t i = 0, rhs_size = const_cast<SBTypeEnumMemberList &>(rhs).GetSize(); i < rhs_size; i++) diff --git a/lldb/source/API/SBTypeSummary.cpp b/lldb/source/API/SBTypeSummary.cpp index e8a6f4c13088..3800ae940c70 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<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() { diff --git a/lldb/source/API/SBValueList.cpp b/lldb/source/API/SBValueList.cpp index d8d40b155b61..0fd2a591c321 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<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) { diff --git a/lldb/source/API/SBVariablesOptions.cpp b/lldb/source/API/SBVariablesOptions.cpp index 4156377e3654..4ef16364e628 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<VariablesOptionsImpl>(options.ref()); return LLDB_RECORD_RESULT(*this); } _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits