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/Target/StackFrame.cpp | |
parent | 145acacaea1d7fb4ffc055a3e92ee8fee7c58634 (diff) | |
download | llvm-113f56fbb80e8d6f705be19f8ae169a3fee2e4f8.zip llvm-113f56fbb80e8d6f705be19f8ae169a3fee2e4f8.tar.gz llvm-113f56fbb80e8d6f705be19f8ae169a3fee2e4f8.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
This re-lands the patch with bogus :m_byte_size(0) initalizations removed.
Diffstat (limited to 'lldb/source/Target/StackFrame.cpp')
-rw-r--r-- | lldb/source/Target/StackFrame.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index 098aed9..22bca52 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -1408,7 +1408,7 @@ ValueObjectSP GetValueForOffset(StackFrame &frame, ValueObjectSP &parent, } int64_t child_offset = child_sp->GetByteOffset(); - int64_t child_size = child_sp->GetByteSize(); + int64_t child_size = child_sp->GetByteSize().getValueOr(0); if (offset >= child_offset && offset < (child_offset + child_size)) { return GetValueForOffset(frame, child_sp, offset - child_offset); @@ -1441,8 +1441,8 @@ ValueObjectSP GetValueForDereferincingOffset(StackFrame &frame, } if (offset >= 0 && uint64_t(offset) >= pointee->GetByteSize()) { - int64_t index = offset / pointee->GetByteSize(); - offset = offset % pointee->GetByteSize(); + int64_t index = offset / pointee->GetByteSize().getValueOr(1); + offset = offset % pointee->GetByteSize().getValueOr(1); const bool can_create = true; pointee = base->GetSyntheticArrayMember(index, can_create); } |