mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-27 15:14:31 +00:00
[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.
This commit is contained in:
1 parent
6330653547
commit
1c0bbe4341
16 files changed
+40
-39
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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(); }
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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++)
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user