diff options
| author | Adrian Prantl <aprantl@apple.com> | 2020-07-25 08:27:21 -0700 |
|---|---|---|
| committer | Adrian Prantl <aprantl@apple.com> | 2020-07-27 13:26:35 -0700 |
| commit | 113f56fbb80e8d6f705be19f8ae169a3fee2e4f8 (patch) | |
| tree | 0e4bfabd2e0cea77293d8322a4fea2b77df8b3eb /lldb/source/Core/ValueObjectConstResult.cpp | |
| parent | 145acacaea1d7fb4ffc055a3e92ee8fee7c58634 (diff) | |
Unify the return value of GetByteSize to an llvm::Optional<uint64_t> (NFC-ish)
This cleanup patch unifies all methods called GetByteSize() in the
ValueObject hierarchy to return an optional, like the methods in
CompilerType do. This means fewer magic 0 values, which could fix bugs
down the road in languages where types can have a size of zero, such
as Swift and C (but not C++).
Differential Revision: https://reviews.llvm.org/D84285
This re-lands the patch with bogus :m_byte_size(0) initalizations removed.
Diffstat (limited to 'lldb/source/Core/ValueObjectConstResult.cpp')
| -rw-r--r-- | lldb/source/Core/ValueObjectConstResult.cpp | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/lldb/source/Core/ValueObjectConstResult.cpp b/lldb/source/Core/ValueObjectConstResult.cpp index 8d84f8e62ccc..ceb4491f8666 100644 --- a/lldb/source/Core/ValueObjectConstResult.cpp +++ b/lldb/source/Core/ValueObjectConstResult.cpp @@ -40,8 +40,7 @@ ValueObjectConstResult::ValueObjectConstResult(ExecutionContextScope *exe_scope, ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address) - : ValueObject(exe_scope, manager), m_type_name(), m_byte_size(0), - m_impl(this, address) { + : ValueObject(exe_scope, manager), m_impl(this, address) { SetIsConstant(); SetValueIsValid(true); m_data.SetByteOrder(byte_order); @@ -64,8 +63,7 @@ ValueObjectConstResult::ValueObjectConstResult( ExecutionContextScope *exe_scope, ValueObjectManager &manager, const CompilerType &compiler_type, ConstString name, const DataExtractor &data, lldb::addr_t address) - : ValueObject(exe_scope, manager), m_type_name(), m_byte_size(0), - m_impl(this, address) { + : ValueObject(exe_scope, manager), m_impl(this, address) { m_data = data; if (!m_data.GetSharedDataBuffer()) { @@ -112,8 +110,7 @@ ValueObjectConstResult::ValueObjectConstResult( const CompilerType &compiler_type, ConstString name, const lldb::DataBufferSP &data_sp, lldb::ByteOrder data_byte_order, uint32_t data_addr_size, lldb::addr_t address) - : ValueObject(exe_scope, manager), m_type_name(), m_byte_size(0), - m_impl(this, address) { + : ValueObject(exe_scope, manager), m_impl(this, address) { m_data.SetByteOrder(data_byte_order); m_data.SetAddressByteSize(data_addr_size); m_data.SetData(data_sp); @@ -143,7 +140,7 @@ ValueObjectConstResult::ValueObjectConstResult( ExecutionContextScope *exe_scope, ValueObjectManager &manager, const CompilerType &compiler_type, ConstString name, lldb::addr_t address, AddressType address_type, uint32_t addr_byte_size) - : ValueObject(exe_scope, manager), m_type_name(), m_byte_size(0), + : ValueObject(exe_scope, manager), m_type_name(), m_impl(this, address) { m_value.GetScalar() = address; m_data.SetAddressByteSize(addr_byte_size); @@ -179,8 +176,7 @@ ValueObjectSP ValueObjectConstResult::Create(ExecutionContextScope *exe_scope, ValueObjectConstResult::ValueObjectConstResult(ExecutionContextScope *exe_scope, ValueObjectManager &manager, const Status &error) - : ValueObject(exe_scope, manager), m_type_name(), m_byte_size(0), - m_impl(this) { + : ValueObject(exe_scope, manager), m_impl(this) { m_error = error; SetIsConstant(); } @@ -189,8 +185,7 @@ ValueObjectConstResult::ValueObjectConstResult(ExecutionContextScope *exe_scope, ValueObjectManager &manager, const Value &value, ConstString name, Module *module) - : ValueObject(exe_scope, manager), m_type_name(), m_byte_size(0), - m_impl(this) { + : ValueObject(exe_scope, manager), m_impl(this) { m_value = value; m_name = name; ExecutionContext exe_ctx; @@ -208,9 +203,9 @@ lldb::ValueType ValueObjectConstResult::GetValueType() const { return eValueTypeConstResult; } -uint64_t ValueObjectConstResult::GetByteSize() { +llvm::Optional<uint64_t> ValueObjectConstResult::GetByteSize() { ExecutionContext exe_ctx(GetExecutionContextRef()); - if (m_byte_size == 0) { + if (!m_byte_size) { if (auto size = GetCompilerType().GetByteSize(exe_ctx.GetBestExecutionContextScope())) SetByteSize(*size); |
