diff options
author | Adrian Prantl <aprantl@apple.com> | 2020-07-25 08:27:21 -0700 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2020-07-25 08:27:21 -0700 |
commit | 1d9b860fb6a85df33fd52fcacc6a5efb421621bd (patch) | |
tree | 2da33a75ca5ab308ae38214fc45432af8e07230a /lldb/source/Expression/Materializer.cpp | |
parent | c09a10845b429307a38a93799e7520c0e16850fd (diff) | |
download | llvm-1d9b860fb6a85df33fd52fcacc6a5efb421621bd.zip llvm-1d9b860fb6a85df33fd52fcacc6a5efb421621bd.tar.gz llvm-1d9b860fb6a85df33fd52fcacc6a5efb421621bd.tar.bz2 |
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
Diffstat (limited to 'lldb/source/Expression/Materializer.cpp')
-rw-r--r-- | lldb/source/Expression/Materializer.cpp | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp index 6f8d9b1..327e15a2 100644 --- a/lldb/source/Expression/Materializer.cpp +++ b/lldb/source/Expression/Materializer.cpp @@ -67,7 +67,7 @@ public: const bool zero_memory = false; lldb::addr_t mem = map.Malloc( - m_persistent_variable_sp->GetByteSize(), 8, + m_persistent_variable_sp->GetByteSize().getValueOr(0), 8, lldb::ePermissionsReadable | lldb::ePermissionsWritable, IRMemoryMap::eAllocationPolicyMirror, zero_memory, allocate_error); @@ -106,7 +106,8 @@ public: Status write_error; map.WriteMemory(mem, m_persistent_variable_sp->GetValueBytes(), - m_persistent_variable_sp->GetByteSize(), write_error); + m_persistent_variable_sp->GetByteSize().getValueOr(0), + write_error); if (!write_error.Success()) { err.SetErrorStringWithFormat( @@ -234,7 +235,7 @@ public: map.GetBestExecutionContextScope(), m_persistent_variable_sp.get()->GetCompilerType(), m_persistent_variable_sp->GetName(), location, eAddressTypeLoad, - m_persistent_variable_sp->GetByteSize()); + m_persistent_variable_sp->GetByteSize().getValueOr(0)); if (frame_top != LLDB_INVALID_ADDRESS && frame_bottom != LLDB_INVALID_ADDRESS && location >= frame_bottom && @@ -279,7 +280,8 @@ public: LLDB_LOGF(log, "Dematerializing %s from 0x%" PRIx64 " (size = %llu)", m_persistent_variable_sp->GetName().GetCString(), (uint64_t)mem, - (unsigned long long)m_persistent_variable_sp->GetByteSize()); + (unsigned long long)m_persistent_variable_sp->GetByteSize() + .getValueOr(0)); // Read the contents of the spare memory area @@ -288,7 +290,7 @@ public: Status read_error; map.ReadMemory(m_persistent_variable_sp->GetValueBytes(), mem, - m_persistent_variable_sp->GetByteSize(), read_error); + m_persistent_variable_sp->GetByteSize().getValueOr(0), read_error); if (!read_error.Success()) { err.SetErrorStringWithFormat( @@ -369,10 +371,11 @@ public: if (!err.Success()) { dump_stream.Printf(" <could not be read>\n"); } else { - DataBufferHeap data(m_persistent_variable_sp->GetByteSize(), 0); + DataBufferHeap data( + m_persistent_variable_sp->GetByteSize().getValueOr(0), 0); map.ReadMemory(data.GetBytes(), target_address, - m_persistent_variable_sp->GetByteSize(), err); + m_persistent_variable_sp->GetByteSize().getValueOr(0), err); if (!err.Success()) { dump_stream.Printf(" <could not be read>\n"); @@ -621,8 +624,8 @@ public: Status extract_error; - map.GetMemoryData(data, m_temporary_allocation, valobj_sp->GetByteSize(), - extract_error); + map.GetMemoryData(data, m_temporary_allocation, + valobj_sp->GetByteSize().getValueOr(0), extract_error); if (!extract_error.Success()) { err.SetErrorStringWithFormat("couldn't get the data for variable %s", @@ -919,7 +922,7 @@ public: ret->ValueUpdated(); - const size_t pvar_byte_size = ret->GetByteSize(); + const size_t pvar_byte_size = ret->GetByteSize().getValueOr(0); uint8_t *pvar_data = ret->GetValueBytes(); map.ReadMemory(pvar_data, address, pvar_byte_size, read_error); |