[Lldb-commits] [PATCH] D101585: [lldb] Handle missing SBStructuredData copy assignment cases
Dave Lee via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu Apr 29 17:22:32 PDT 2021
kastiglione updated this revision to Diff 341721.
kastiglione added a comment.
Ensure m_impl_up is always non-null
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101585/new/
https://reviews.llvm.org/D101585
Files:
lldb/source/API/SBStructuredData.cpp
Index: lldb/source/API/SBStructuredData.cpp
===================================================================
--- lldb/source/API/SBStructuredData.cpp
+++ lldb/source/API/SBStructuredData.cpp
@@ -29,7 +29,7 @@
}
SBStructuredData::SBStructuredData(const lldb::SBStructuredData &rhs)
- : m_impl_up(new StructuredDataImpl(*rhs.m_impl_up.get())) {
+ : m_impl_up(new StructuredDataImpl(*rhs.m_impl_up)) {
LLDB_RECORD_CONSTRUCTOR(SBStructuredData, (const lldb::SBStructuredData &),
rhs);
}
@@ -40,7 +40,7 @@
}
SBStructuredData::SBStructuredData(lldb_private::StructuredDataImpl *impl)
- : m_impl_up(impl) {
+ : m_impl_up(impl ? impl : new StructuredDataImpl()) {
LLDB_RECORD_CONSTRUCTOR(SBStructuredData,
(lldb_private::StructuredDataImpl *), impl);
}
@@ -111,22 +111,19 @@
LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::StructuredDataType, SBStructuredData,
GetType);
- return (m_impl_up ? m_impl_up->GetType() : eStructuredDataTypeInvalid);
+ return m_impl_up->GetType();
}
size_t SBStructuredData::GetSize() const {
LLDB_RECORD_METHOD_CONST_NO_ARGS(size_t, SBStructuredData, GetSize);
- return (m_impl_up ? m_impl_up->GetSize() : 0);
+ return m_impl_up->GetSize();
}
bool SBStructuredData::GetKeys(lldb::SBStringList &keys) const {
LLDB_RECORD_METHOD_CONST(bool, SBStructuredData, GetKeys,
(lldb::SBStringList &), keys);
- if (!m_impl_up)
- return false;
-
if (GetType() != eStructuredDataTypeDictionary)
return false;
@@ -154,9 +151,6 @@
LLDB_RECORD_METHOD_CONST(lldb::SBStructuredData, SBStructuredData,
GetValueForKey, (const char *), key);
- if (!m_impl_up)
- return LLDB_RECORD_RESULT(SBStructuredData());
-
SBStructuredData result;
result.m_impl_up->SetObjectSP(m_impl_up->GetValueForKey(key));
return LLDB_RECORD_RESULT(result);
@@ -166,9 +160,6 @@
LLDB_RECORD_METHOD_CONST(lldb::SBStructuredData, SBStructuredData,
GetItemAtIndex, (size_t), idx);
- if (!m_impl_up)
- return LLDB_RECORD_RESULT(SBStructuredData());
-
SBStructuredData result;
result.m_impl_up->SetObjectSP(m_impl_up->GetItemAtIndex(idx));
return LLDB_RECORD_RESULT(result);
@@ -178,28 +169,28 @@
LLDB_RECORD_METHOD_CONST(uint64_t, SBStructuredData, GetIntegerValue,
(uint64_t), fail_value);
- return (m_impl_up ? m_impl_up->GetIntegerValue(fail_value) : fail_value);
+ return m_impl_up->GetIntegerValue(fail_value);
}
double SBStructuredData::GetFloatValue(double fail_value) const {
LLDB_RECORD_METHOD_CONST(double, SBStructuredData, GetFloatValue, (double),
fail_value);
- return (m_impl_up ? m_impl_up->GetFloatValue(fail_value) : fail_value);
+ return m_impl_up->GetFloatValue(fail_value);
}
bool SBStructuredData::GetBooleanValue(bool fail_value) const {
LLDB_RECORD_METHOD_CONST(bool, SBStructuredData, GetBooleanValue, (bool),
fail_value);
- return (m_impl_up ? m_impl_up->GetBooleanValue(fail_value) : fail_value);
+ return m_impl_up->GetBooleanValue(fail_value);
}
size_t SBStructuredData::GetStringValue(char *dst, size_t dst_len) const {
LLDB_RECORD_CHAR_PTR_METHOD_CONST(size_t, SBStructuredData, GetStringValue,
(char *, size_t), dst, "", dst_len);
- return (m_impl_up ? m_impl_up->GetStringValue(dst, dst_len) : 0);
+ return m_impl_up->GetStringValue(dst, dst_len);
}
namespace lldb_private {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101585.341721.patch
Type: text/x-patch
Size: 3615 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210430/449b369a/attachment-0001.bin>
More information about the lldb-commits
mailing list