[Lldb-commits] [lldb] 4b14ef3 - Temporarily Revert "Unify the return value of GetByteSize to an llvm::Optional<uint64_t> (NFC-ish)"

Eric Christopher via lldb-commits lldb-commits at lists.llvm.org
Sat Jul 25 18:42:47 PDT 2020


Author: Eric Christopher
Date: 2020-07-25T18:42:04-07:00
New Revision: 4b14ef33e81c01632e848e7a67ccc6b11fb4c595

URL: https://github.com/llvm/llvm-project/commit/4b14ef33e81c01632e848e7a67ccc6b11fb4c595
DIFF: https://github.com/llvm/llvm-project/commit/4b14ef33e81c01632e848e7a67ccc6b11fb4c595.diff

LOG: Temporarily Revert "Unify the return value of GetByteSize to an llvm::Optional<uint64_t> (NFC-ish)"
as it's causing numerous (176) test failures on linux.

This reverts commit 1d9b860fb6a85df33fd52fcacc6a5efb421621bd.

Added: 
    

Modified: 
    lldb/include/lldb/Core/ValueObject.h
    lldb/include/lldb/Core/ValueObjectCast.h
    lldb/include/lldb/Core/ValueObjectChild.h
    lldb/include/lldb/Core/ValueObjectConstResult.h
    lldb/include/lldb/Core/ValueObjectDynamicValue.h
    lldb/include/lldb/Core/ValueObjectMemory.h
    lldb/include/lldb/Core/ValueObjectRegister.h
    lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
    lldb/include/lldb/Core/ValueObjectVariable.h
    lldb/include/lldb/Expression/ExpressionVariable.h
    lldb/include/lldb/Target/StackFrameRecognizer.h
    lldb/source/API/SBValue.cpp
    lldb/source/Commands/CommandObjectWatchpoint.cpp
    lldb/source/Core/ValueObject.cpp
    lldb/source/Core/ValueObjectCast.cpp
    lldb/source/Core/ValueObjectConstResult.cpp
    lldb/source/Core/ValueObjectDynamicValue.cpp
    lldb/source/Core/ValueObjectMemory.cpp
    lldb/source/Core/ValueObjectRegister.cpp
    lldb/source/Core/ValueObjectSyntheticFilter.cpp
    lldb/source/Core/ValueObjectVariable.cpp
    lldb/source/Expression/ExpressionVariable.cpp
    lldb/source/Expression/Materializer.cpp
    lldb/source/Target/StackFrame.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h
index a557d69f3ae3..0080368fd996 100644
--- a/lldb/include/lldb/Core/ValueObject.h
+++ b/lldb/include/lldb/Core/ValueObject.h
@@ -358,7 +358,7 @@ class ValueObject : public UserID {
   virtual bool CanProvideValue();
 
   // Subclasses must implement the functions below.
-  virtual llvm::Optional<uint64_t> GetByteSize() = 0;
+  virtual uint64_t GetByteSize() = 0;
 
   virtual lldb::ValueType GetValueType() const = 0;
 

diff  --git a/lldb/include/lldb/Core/ValueObjectCast.h b/lldb/include/lldb/Core/ValueObjectCast.h
index 342803f8ca63..d91ca6a92be8 100644
--- a/lldb/include/lldb/Core/ValueObjectCast.h
+++ b/lldb/include/lldb/Core/ValueObjectCast.h
@@ -30,7 +30,7 @@ class ValueObjectCast : public ValueObject {
                                     ConstString name,
                                     const CompilerType &cast_type);
 
-  llvm::Optional<uint64_t> GetByteSize() override;
+  uint64_t GetByteSize() override;
 
   size_t CalculateNumChildren(uint32_t max) override;
 

diff  --git a/lldb/include/lldb/Core/ValueObjectChild.h b/lldb/include/lldb/Core/ValueObjectChild.h
index 9a9fd9294261..c6f44a29b059 100644
--- a/lldb/include/lldb/Core/ValueObjectChild.h
+++ b/lldb/include/lldb/Core/ValueObjectChild.h
@@ -30,7 +30,7 @@ class ValueObjectChild : public ValueObject {
 public:
   ~ValueObjectChild() override;
 
-  llvm::Optional<uint64_t> GetByteSize() override { return m_byte_size; }
+  uint64_t GetByteSize() override { return m_byte_size; }
 
   lldb::offset_t GetByteOffset() override { return m_byte_offset; }
 

diff  --git a/lldb/include/lldb/Core/ValueObjectConstResult.h b/lldb/include/lldb/Core/ValueObjectConstResult.h
index 8d823baa0b7b..0e868c687e93 100644
--- a/lldb/include/lldb/Core/ValueObjectConstResult.h
+++ b/lldb/include/lldb/Core/ValueObjectConstResult.h
@@ -62,7 +62,7 @@ class ValueObjectConstResult : public ValueObject {
   static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
                                     const Status &error);
 
-  llvm::Optional<uint64_t> GetByteSize() override;
+  uint64_t GetByteSize() override;
 
   lldb::ValueType GetValueType() const override;
 
@@ -113,7 +113,7 @@ class ValueObjectConstResult : public ValueObject {
   CompilerType GetCompilerTypeImpl() override;
 
   ConstString m_type_name;
-  llvm::Optional<uint64_t> m_byte_size;
+  uint64_t m_byte_size;
 
   ValueObjectConstResultImpl m_impl;
 

diff  --git a/lldb/include/lldb/Core/ValueObjectDynamicValue.h b/lldb/include/lldb/Core/ValueObjectDynamicValue.h
index 2806857339ef..9f5304b55e93 100644
--- a/lldb/include/lldb/Core/ValueObjectDynamicValue.h
+++ b/lldb/include/lldb/Core/ValueObjectDynamicValue.h
@@ -34,7 +34,7 @@ class ValueObjectDynamicValue : public ValueObject {
 public:
   ~ValueObjectDynamicValue() override;
 
-  llvm::Optional<uint64_t> GetByteSize() override;
+  uint64_t GetByteSize() override;
 
   ConstString GetTypeName() override;
 

diff  --git a/lldb/include/lldb/Core/ValueObjectMemory.h b/lldb/include/lldb/Core/ValueObjectMemory.h
index b5d5e6ecf4c0..d1cd6ae41445 100644
--- a/lldb/include/lldb/Core/ValueObjectMemory.h
+++ b/lldb/include/lldb/Core/ValueObjectMemory.h
@@ -40,7 +40,7 @@ class ValueObjectMemory : public ValueObject {
                                     const Address &address,
                                     const CompilerType &ast_type);
 
-  llvm::Optional<uint64_t> GetByteSize() override;
+  uint64_t GetByteSize() override;
 
   ConstString GetTypeName() override;
 

diff  --git a/lldb/include/lldb/Core/ValueObjectRegister.h b/lldb/include/lldb/Core/ValueObjectRegister.h
index 3968584ad518..41051d93b707 100644
--- a/lldb/include/lldb/Core/ValueObjectRegister.h
+++ b/lldb/include/lldb/Core/ValueObjectRegister.h
@@ -36,7 +36,7 @@ class ValueObjectRegisterSet : public ValueObject {
                                     lldb::RegisterContextSP &reg_ctx_sp,
                                     uint32_t set_idx);
 
-  llvm::Optional<uint64_t> GetByteSize() override;
+  uint64_t GetByteSize() override;
 
   lldb::ValueType GetValueType() const override {
     return lldb::eValueTypeRegisterSet;
@@ -86,7 +86,7 @@ class ValueObjectRegister : public ValueObject {
                                     lldb::RegisterContextSP &reg_ctx_sp,
                                     uint32_t reg_num);
 
-  llvm::Optional<uint64_t> GetByteSize() override;
+  uint64_t GetByteSize() override;
 
   lldb::ValueType GetValueType() const override {
     return lldb::eValueTypeRegister;

diff  --git a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
index 41c461ce13f0..cb471657aec9 100644
--- a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
+++ b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h
@@ -36,7 +36,7 @@ class ValueObjectSynthetic : public ValueObject {
 public:
   ~ValueObjectSynthetic() override;
 
-  llvm::Optional<uint64_t> GetByteSize() override;
+  uint64_t GetByteSize() override;
 
   ConstString GetTypeName() override;
 

diff  --git a/lldb/include/lldb/Core/ValueObjectVariable.h b/lldb/include/lldb/Core/ValueObjectVariable.h
index 23fdedbf5a4a..b7e262574a14 100644
--- a/lldb/include/lldb/Core/ValueObjectVariable.h
+++ b/lldb/include/lldb/Core/ValueObjectVariable.h
@@ -37,7 +37,7 @@ class ValueObjectVariable : public ValueObject {
   static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,
                                     const lldb::VariableSP &var_sp);
 
-  llvm::Optional<uint64_t> GetByteSize() override;
+  uint64_t GetByteSize() override;
 
   ConstString GetTypeName() override;
 

diff  --git a/lldb/include/lldb/Expression/ExpressionVariable.h b/lldb/include/lldb/Expression/ExpressionVariable.h
index 4259e6395da4..60062d212bad 100644
--- a/lldb/include/lldb/Expression/ExpressionVariable.h
+++ b/lldb/include/lldb/Expression/ExpressionVariable.h
@@ -32,7 +32,7 @@ class ExpressionVariable
 
   virtual ~ExpressionVariable();
 
-  llvm::Optional<uint64_t> GetByteSize() { return m_frozen_sp->GetByteSize(); }
+  size_t GetByteSize() { return m_frozen_sp->GetByteSize(); }
 
   ConstString GetName() { return m_frozen_sp->GetName(); }
 

diff  --git a/lldb/include/lldb/Target/StackFrameRecognizer.h b/lldb/include/lldb/Target/StackFrameRecognizer.h
index baffc890bb06..302b56bec907 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -154,9 +154,7 @@ class ValueObjectRecognizerSynthesizedValue : public ValueObject {
     SetName(parent.GetName());
   }
 
-  llvm::Optional<uint64_t> GetByteSize() override {
-    return m_parent->GetByteSize();
-  }
+  uint64_t GetByteSize() override { return m_parent->GetByteSize(); }
   lldb::ValueType GetValueType() const override { return m_type; }
   bool UpdateValue() override {
     if (!m_parent->UpdateValueIfNeeded()) return false;

diff  --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp
index 686d1f23a75a..7485b0ee1838 100644
--- a/lldb/source/API/SBValue.cpp
+++ b/lldb/source/API/SBValue.cpp
@@ -333,7 +333,7 @@ size_t SBValue::GetByteSize() {
   ValueLocker locker;
   lldb::ValueObjectSP value_sp(GetSP(locker));
   if (value_sp) {
-    result = value_sp->GetByteSize().getValueOr(0);
+    result = value_sp->GetByteSize();
   }
 
   return result;

diff  --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp
index c2a008af79d6..ce4662930a7c 100644
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp
@@ -905,7 +905,7 @@ corresponding to the byte size of the data type.");
         // We're in business.
         // Find out the size of this variable.
         size = m_option_watchpoint.watch_size == 0
-                   ? valobj_sp->GetByteSize().getValueOr(0)
+                   ? valobj_sp->GetByteSize()
                    : m_option_watchpoint.watch_size;
       }
       compiler_type = valobj_sp->GetCompilerType();

diff  --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp
index aedefd0cf0fd..3a775b07e5e1 100644
--- a/lldb/source/Core/ValueObject.cpp
+++ b/lldb/source/Core/ValueObject.cpp
@@ -849,7 +849,7 @@ bool ValueObject::SetData(DataExtractor &data, Status &error) {
   uint64_t count = 0;
   const Encoding encoding = GetCompilerType().GetEncoding(count);
 
-  const size_t byte_size = GetByteSize().getValueOr(0);
+  const size_t byte_size = GetByteSize();
 
   Value::ValueType value_type = m_value.GetValueType();
 
@@ -1524,7 +1524,7 @@ bool ValueObject::SetValueFromCString(const char *value_str, Status &error) {
   uint64_t count = 0;
   const Encoding encoding = GetCompilerType().GetEncoding(count);
 
-  const size_t byte_size = GetByteSize().getValueOr(0);
+  const size_t byte_size = GetByteSize();
 
   Value::ValueType value_type = m_value.GetValueType();
 
@@ -1741,13 +1741,13 @@ ValueObjectSP ValueObject::GetSyntheticBitFieldChild(uint32_t from, uint32_t to,
       uint32_t bit_field_offset = from;
       if (GetDataExtractor().GetByteOrder() == eByteOrderBig)
         bit_field_offset =
-            GetByteSize().getValueOr(0) * 8 - bit_field_size - bit_field_offset;
+            GetByteSize() * 8 - bit_field_size - bit_field_offset;
       // We haven't made a synthetic array member for INDEX yet, so lets make
       // one and cache it for any future reference.
       ValueObjectChild *synthetic_child = new ValueObjectChild(
-          *this, GetCompilerType(), index_const_str,
-          GetByteSize().getValueOr(0), 0, bit_field_size, bit_field_offset,
-          false, false, eAddressTypeInvalid, 0);
+          *this, GetCompilerType(), index_const_str, GetByteSize(), 0,
+          bit_field_size, bit_field_offset, false, false, eAddressTypeInvalid,
+          0);
 
       // Cache the value if we got one back...
       if (synthetic_child) {

diff  --git a/lldb/source/Core/ValueObjectCast.cpp b/lldb/source/Core/ValueObjectCast.cpp
index 7b6d3591faf4..22e856be539b 100644
--- a/lldb/source/Core/ValueObjectCast.cpp
+++ b/lldb/source/Core/ValueObjectCast.cpp
@@ -47,7 +47,7 @@ size_t ValueObjectCast::CalculateNumChildren(uint32_t max) {
   return children_count <= max ? children_count : max;
 }
 
-llvm::Optional<uint64_t> ValueObjectCast::GetByteSize() {
+uint64_t ValueObjectCast::GetByteSize() {
   ExecutionContext exe_ctx(GetExecutionContextRef());
   return m_value.GetValueByteSize(nullptr, &exe_ctx);
 }

diff  --git a/lldb/source/Core/ValueObjectConstResult.cpp b/lldb/source/Core/ValueObjectConstResult.cpp
index fd31ddc676b4..8d84f8e62ccc 100644
--- a/lldb/source/Core/ValueObjectConstResult.cpp
+++ b/lldb/source/Core/ValueObjectConstResult.cpp
@@ -179,7 +179,8 @@ ValueObjectSP ValueObjectConstResult::Create(ExecutionContextScope *exe_scope,
 ValueObjectConstResult::ValueObjectConstResult(ExecutionContextScope *exe_scope,
                                                ValueObjectManager &manager,
                                                const Status &error)
-    : ValueObject(exe_scope, manager), m_impl(this) {
+    : ValueObject(exe_scope, manager), m_type_name(), m_byte_size(0),
+      m_impl(this) {
   m_error = error;
   SetIsConstant();
 }
@@ -188,7 +189,8 @@ ValueObjectConstResult::ValueObjectConstResult(ExecutionContextScope *exe_scope,
                                                ValueObjectManager &manager,
                                                const Value &value,
                                                ConstString name, Module *module)
-    : ValueObject(exe_scope, manager), m_impl(this) {
+    : ValueObject(exe_scope, manager), m_type_name(), m_byte_size(0),
+      m_impl(this) {
   m_value = value;
   m_name = name;
   ExecutionContext exe_ctx;
@@ -206,9 +208,9 @@ lldb::ValueType ValueObjectConstResult::GetValueType() const {
   return eValueTypeConstResult;
 }
 
-llvm::Optional<uint64_t> ValueObjectConstResult::GetByteSize() {
+uint64_t ValueObjectConstResult::GetByteSize() {
   ExecutionContext exe_ctx(GetExecutionContextRef());
-  if (!m_byte_size) {
+  if (m_byte_size == 0) {
     if (auto size =
         GetCompilerType().GetByteSize(exe_ctx.GetBestExecutionContextScope()))
       SetByteSize(*size);

diff  --git a/lldb/source/Core/ValueObjectDynamicValue.cpp b/lldb/source/Core/ValueObjectDynamicValue.cpp
index 1c25b8c85a05..ca66740cb55d 100644
--- a/lldb/source/Core/ValueObjectDynamicValue.cpp
+++ b/lldb/source/Core/ValueObjectDynamicValue.cpp
@@ -98,7 +98,7 @@ size_t ValueObjectDynamicValue::CalculateNumChildren(uint32_t max) {
     return m_parent->GetNumChildren(max);
 }
 
-llvm::Optional<uint64_t> ValueObjectDynamicValue::GetByteSize() {
+uint64_t ValueObjectDynamicValue::GetByteSize() {
   const bool success = UpdateValueIfNeeded(false);
   if (success && m_dynamic_type_info.HasType()) {
     ExecutionContext exe_ctx(GetExecutionContextRef());

diff  --git a/lldb/source/Core/ValueObjectMemory.cpp b/lldb/source/Core/ValueObjectMemory.cpp
index 17fade9e5fdc..8e7d3ebc93f6 100644
--- a/lldb/source/Core/ValueObjectMemory.cpp
+++ b/lldb/source/Core/ValueObjectMemory.cpp
@@ -139,11 +139,13 @@ size_t ValueObjectMemory::CalculateNumChildren(uint32_t max) {
   return child_count <= max ? child_count : max;
 }
 
-llvm::Optional<uint64_t> ValueObjectMemory::GetByteSize() {
+uint64_t ValueObjectMemory::GetByteSize() {
   ExecutionContext exe_ctx(GetExecutionContextRef());
   if (m_type_sp)
-    return m_type_sp->GetByteSize(exe_ctx.GetBestExecutionContextScope());
-  return m_compiler_type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
+    return m_type_sp->GetByteSize(exe_ctx.GetBestExecutionContextScope())
+        .getValueOr(0);
+  return m_compiler_type.GetByteSize(exe_ctx.GetBestExecutionContextScope())
+      .getValueOr(0);
 }
 
 lldb::ValueType ValueObjectMemory::GetValueType() const {

diff  --git a/lldb/source/Core/ValueObjectRegister.cpp b/lldb/source/Core/ValueObjectRegister.cpp
index 27461e9cebc4..ec87c38fb367 100644
--- a/lldb/source/Core/ValueObjectRegister.cpp
+++ b/lldb/source/Core/ValueObjectRegister.cpp
@@ -81,7 +81,7 @@ size_t ValueObjectRegisterSet::CalculateNumChildren(uint32_t max) {
   return 0;
 }
 
-llvm::Optional<uint64_t> ValueObjectRegisterSet::GetByteSize() { return 0; }
+uint64_t ValueObjectRegisterSet::GetByteSize() { return 0; }
 
 bool ValueObjectRegisterSet::UpdateValue() {
   m_error.Clear();
@@ -229,9 +229,7 @@ size_t ValueObjectRegister::CalculateNumChildren(uint32_t max) {
   return children_count <= max ? children_count : max;
 }
 
-llvm::Optional<uint64_t> ValueObjectRegister::GetByteSize() {
-  return m_reg_info.byte_size;
-}
+uint64_t ValueObjectRegister::GetByteSize() { return m_reg_info.byte_size; }
 
 bool ValueObjectRegister::UpdateValue() {
   m_error.Clear();

diff  --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
index fb2d32e602ce..32d1e6ab8368 100644
--- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp
+++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp
@@ -121,9 +121,7 @@ bool ValueObjectSynthetic::MightHaveChildren() {
   return (m_might_have_children != eLazyBoolNo);
 }
 
-llvm::Optional<uint64_t> ValueObjectSynthetic::GetByteSize() {
-  return m_parent->GetByteSize();
-}
+uint64_t ValueObjectSynthetic::GetByteSize() { return m_parent->GetByteSize(); }
 
 lldb::ValueType ValueObjectSynthetic::GetValueType() const {
   return m_parent->GetValueType();

diff  --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp
index ab67e3038cf0..0d1e7b047a0a 100644
--- a/lldb/source/Core/ValueObjectVariable.cpp
+++ b/lldb/source/Core/ValueObjectVariable.cpp
@@ -105,15 +105,15 @@ size_t ValueObjectVariable::CalculateNumChildren(uint32_t max) {
   return child_count <= max ? child_count : max;
 }
 
-llvm::Optional<uint64_t> ValueObjectVariable::GetByteSize() {
+uint64_t ValueObjectVariable::GetByteSize() {
   ExecutionContext exe_ctx(GetExecutionContextRef());
 
   CompilerType type(GetCompilerType());
 
   if (!type.IsValid())
-    return {};
+    return 0;
 
-  return type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
+  return type.GetByteSize(exe_ctx.GetBestExecutionContextScope()).getValueOr(0);
 }
 
 lldb::ValueType ValueObjectVariable::GetValueType() const {

diff  --git a/lldb/source/Expression/ExpressionVariable.cpp b/lldb/source/Expression/ExpressionVariable.cpp
index 8b3dda7b2fe1..d95f0745cf4b 100644
--- a/lldb/source/Expression/ExpressionVariable.cpp
+++ b/lldb/source/Expression/ExpressionVariable.cpp
@@ -16,10 +16,10 @@ using namespace lldb_private;
 ExpressionVariable::~ExpressionVariable() {}
 
 uint8_t *ExpressionVariable::GetValueBytes() {
-  llvm::Optional<uint64_t> byte_size = m_frozen_sp->GetByteSize();
-  if (byte_size && *byte_size) {
-    if (m_frozen_sp->GetDataExtractor().GetByteSize() < *byte_size) {
-      m_frozen_sp->GetValue().ResizeData(*byte_size);
+  const size_t byte_size = m_frozen_sp->GetByteSize();
+  if (byte_size > 0) {
+    if (m_frozen_sp->GetDataExtractor().GetByteSize() < byte_size) {
+      m_frozen_sp->GetValue().ResizeData(byte_size);
       m_frozen_sp->GetValue().GetData(m_frozen_sp->GetDataExtractor());
     }
     return const_cast<uint8_t *>(

diff  --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp
index 327e15a26266..6f8d9b154570 100644
--- a/lldb/source/Expression/Materializer.cpp
+++ b/lldb/source/Expression/Materializer.cpp
@@ -67,7 +67,7 @@ class EntityPersistentVariable : public Materializer::Entity {
     const bool zero_memory = false;
 
     lldb::addr_t mem = map.Malloc(
-        m_persistent_variable_sp->GetByteSize().getValueOr(0), 8,
+        m_persistent_variable_sp->GetByteSize(), 8,
         lldb::ePermissionsReadable | lldb::ePermissionsWritable,
         IRMemoryMap::eAllocationPolicyMirror, zero_memory, allocate_error);
 
@@ -106,8 +106,7 @@ class EntityPersistentVariable : public Materializer::Entity {
     Status write_error;
 
     map.WriteMemory(mem, m_persistent_variable_sp->GetValueBytes(),
-                    m_persistent_variable_sp->GetByteSize().getValueOr(0),
-                    write_error);
+                    m_persistent_variable_sp->GetByteSize(), write_error);
 
     if (!write_error.Success()) {
       err.SetErrorStringWithFormat(
@@ -235,7 +234,7 @@ class EntityPersistentVariable : public Materializer::Entity {
             map.GetBestExecutionContextScope(),
             m_persistent_variable_sp.get()->GetCompilerType(),
             m_persistent_variable_sp->GetName(), location, eAddressTypeLoad,
-            m_persistent_variable_sp->GetByteSize().getValueOr(0));
+            m_persistent_variable_sp->GetByteSize());
 
         if (frame_top != LLDB_INVALID_ADDRESS &&
             frame_bottom != LLDB_INVALID_ADDRESS && location >= frame_bottom &&
@@ -280,8 +279,7 @@ class EntityPersistentVariable : public Materializer::Entity {
         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()
-                      .getValueOr(0));
+                  (unsigned long long)m_persistent_variable_sp->GetByteSize());
 
         // Read the contents of the spare memory area
 
@@ -290,7 +288,7 @@ class EntityPersistentVariable : public Materializer::Entity {
         Status read_error;
 
         map.ReadMemory(m_persistent_variable_sp->GetValueBytes(), mem,
-                       m_persistent_variable_sp->GetByteSize().getValueOr(0), read_error);
+                       m_persistent_variable_sp->GetByteSize(), read_error);
 
         if (!read_error.Success()) {
           err.SetErrorStringWithFormat(
@@ -371,11 +369,10 @@ class EntityPersistentVariable : public Materializer::Entity {
       if (!err.Success()) {
         dump_stream.Printf("  <could not be read>\n");
       } else {
-        DataBufferHeap data(
-            m_persistent_variable_sp->GetByteSize().getValueOr(0), 0);
+        DataBufferHeap data(m_persistent_variable_sp->GetByteSize(), 0);
 
         map.ReadMemory(data.GetBytes(), target_address,
-                       m_persistent_variable_sp->GetByteSize().getValueOr(0), err);
+                       m_persistent_variable_sp->GetByteSize(), err);
 
         if (!err.Success()) {
           dump_stream.Printf("  <could not be read>\n");
@@ -624,8 +621,8 @@ class EntityVariable : public Materializer::Entity {
 
       Status extract_error;
 
-      map.GetMemoryData(data, m_temporary_allocation,
-                        valobj_sp->GetByteSize().getValueOr(0), extract_error);
+      map.GetMemoryData(data, m_temporary_allocation, valobj_sp->GetByteSize(),
+                        extract_error);
 
       if (!extract_error.Success()) {
         err.SetErrorStringWithFormat("couldn't get the data for variable %s",
@@ -922,7 +919,7 @@ class EntityResultVariable : public Materializer::Entity {
 
     ret->ValueUpdated();
 
-    const size_t pvar_byte_size = ret->GetByteSize().getValueOr(0);
+    const size_t pvar_byte_size = ret->GetByteSize();
     uint8_t *pvar_data = ret->GetValueBytes();
 
     map.ReadMemory(pvar_data, address, pvar_byte_size, read_error);

diff  --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp
index 22bca52d7f98..098aed9cd812 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().getValueOr(0);
+    int64_t child_size = child_sp->GetByteSize();
 
     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().getValueOr(1);
-    offset = offset % pointee->GetByteSize().getValueOr(1);
+    int64_t index = offset / pointee->GetByteSize();
+    offset = offset % pointee->GetByteSize();
     const bool can_create = true;
     pointee = base->GetSyntheticArrayMember(index, can_create);
   }


        


More information about the lldb-commits mailing list