<div dir="auto">No problem, thanks! :)</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jul 27, 2020, 9:26 AM Adrian Prantl <<a href="mailto:aprantl@apple.com">aprantl@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">Thanks, Eric! Sorry for not paying attention after landing this.<div><br></div><div>-- adrian<br><div><br><blockquote type="cite"><div>On Jul 25, 2020, at 6:43 PM, Eric Christopher <<a href="mailto:echristo@gmail.com" target="_blank" rel="noreferrer">echristo@gmail.com</a>> wrote:</div><br><div><div dir="ltr">Hi Adrian,<div><br></div><div>I'm really sorry, but I've just reverted this. I'm not sure what's up, but it's causing massive test failures in lldb on linux. Happy to help sync up with you.</div><div><br></div><div>echristo@athyra ~/s/llvm-project> git push<br>To <a href="http://github.com" target="_blank" rel="noreferrer">github.com</a>:llvm/llvm-project.git<br>   18975762c19..4b14ef33e81  master -> master<br></div><div><br></div><div>Thanks!</div><div><br></div><div>-eric</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jul 25, 2020 at 8:28 AM Adrian Prantl via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org" target="_blank" rel="noreferrer">lldb-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Author: Adrian Prantl<br>
Date: 2020-07-25T08:27:21-07:00<br>
New Revision: 1d9b860fb6a85df33fd52fcacc6a5efb421621bd<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/1d9b860fb6a85df33fd52fcacc6a5efb421621bd" rel="noreferrer noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/1d9b860fb6a85df33fd52fcacc6a5efb421621bd</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/1d9b860fb6a85df33fd52fcacc6a5efb421621bd.diff" rel="noreferrer noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/1d9b860fb6a85df33fd52fcacc6a5efb421621bd.diff</a><br>
<br>
LOG: Unify the return value of GetByteSize to an llvm::Optional<uint64_t> (NFC-ish)<br>
<br>
This cleanup patch unifies all methods called GetByteSize() in the<br>
ValueObject hierarchy to return an optional, like the methods in<br>
CompilerType do. This means fewer magic 0 values, which could fix bugs<br>
down the road in languages where types can have a size of zero, such<br>
as Swift and C (but not C++).<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D84285" rel="noreferrer noreferrer" target="_blank">https://reviews.llvm.org/D84285</a><br>
<br>
Added: <br>
<br>
<br>
Modified: <br>
    lldb/include/lldb/Core/ValueObject.h<br>
    lldb/include/lldb/Core/ValueObjectCast.h<br>
    lldb/include/lldb/Core/ValueObjectChild.h<br>
    lldb/include/lldb/Core/ValueObjectConstResult.h<br>
    lldb/include/lldb/Core/ValueObjectDynamicValue.h<br>
    lldb/include/lldb/Core/ValueObjectMemory.h<br>
    lldb/include/lldb/Core/ValueObjectRegister.h<br>
    lldb/include/lldb/Core/ValueObjectSyntheticFilter.h<br>
    lldb/include/lldb/Core/ValueObjectVariable.h<br>
    lldb/include/lldb/Expression/ExpressionVariable.h<br>
    lldb/include/lldb/Target/StackFrameRecognizer.h<br>
    lldb/source/API/SBValue.cpp<br>
    lldb/source/Commands/CommandObjectWatchpoint.cpp<br>
    lldb/source/Core/ValueObject.cpp<br>
    lldb/source/Core/ValueObjectCast.cpp<br>
    lldb/source/Core/ValueObjectConstResult.cpp<br>
    lldb/source/Core/ValueObjectDynamicValue.cpp<br>
    lldb/source/Core/ValueObjectMemory.cpp<br>
    lldb/source/Core/ValueObjectRegister.cpp<br>
    lldb/source/Core/ValueObjectSyntheticFilter.cpp<br>
    lldb/source/Core/ValueObjectVariable.cpp<br>
    lldb/source/Expression/ExpressionVariable.cpp<br>
    lldb/source/Expression/Materializer.cpp<br>
    lldb/source/Target/StackFrame.cpp<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff  --git a/lldb/include/lldb/Core/ValueObject.h b/lldb/include/lldb/Core/ValueObject.h<br>
index 0080368fd996..a557d69f3ae3 100644<br>
--- a/lldb/include/lldb/Core/ValueObject.h<br>
+++ b/lldb/include/lldb/Core/ValueObject.h<br>
@@ -358,7 +358,7 @@ class ValueObject : public UserID {<br>
   virtual bool CanProvideValue();<br>
<br>
   // Subclasses must implement the functions below.<br>
-  virtual uint64_t GetByteSize() = 0;<br>
+  virtual llvm::Optional<uint64_t> GetByteSize() = 0;<br>
<br>
   virtual lldb::ValueType GetValueType() const = 0;<br>
<br>
<br>
diff  --git a/lldb/include/lldb/Core/ValueObjectCast.h b/lldb/include/lldb/Core/ValueObjectCast.h<br>
index d91ca6a92be8..342803f8ca63 100644<br>
--- a/lldb/include/lldb/Core/ValueObjectCast.h<br>
+++ b/lldb/include/lldb/Core/ValueObjectCast.h<br>
@@ -30,7 +30,7 @@ class ValueObjectCast : public ValueObject {<br>
                                     ConstString name,<br>
                                     const CompilerType &cast_type);<br>
<br>
-  uint64_t GetByteSize() override;<br>
+  llvm::Optional<uint64_t> GetByteSize() override;<br>
<br>
   size_t CalculateNumChildren(uint32_t max) override;<br>
<br>
<br>
diff  --git a/lldb/include/lldb/Core/ValueObjectChild.h b/lldb/include/lldb/Core/ValueObjectChild.h<br>
index c6f44a29b059..9a9fd9294261 100644<br>
--- a/lldb/include/lldb/Core/ValueObjectChild.h<br>
+++ b/lldb/include/lldb/Core/ValueObjectChild.h<br>
@@ -30,7 +30,7 @@ class ValueObjectChild : public ValueObject {<br>
 public:<br>
   ~ValueObjectChild() override;<br>
<br>
-  uint64_t GetByteSize() override { return m_byte_size; }<br>
+  llvm::Optional<uint64_t> GetByteSize() override { return m_byte_size; }<br>
<br>
   lldb::offset_t GetByteOffset() override { return m_byte_offset; }<br>
<br>
<br>
diff  --git a/lldb/include/lldb/Core/ValueObjectConstResult.h b/lldb/include/lldb/Core/ValueObjectConstResult.h<br>
index 0e868c687e93..8d823baa0b7b 100644<br>
--- a/lldb/include/lldb/Core/ValueObjectConstResult.h<br>
+++ b/lldb/include/lldb/Core/ValueObjectConstResult.h<br>
@@ -62,7 +62,7 @@ class ValueObjectConstResult : public ValueObject {<br>
   static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,<br>
                                     const Status &error);<br>
<br>
-  uint64_t GetByteSize() override;<br>
+  llvm::Optional<uint64_t> GetByteSize() override;<br>
<br>
   lldb::ValueType GetValueType() const override;<br>
<br>
@@ -113,7 +113,7 @@ class ValueObjectConstResult : public ValueObject {<br>
   CompilerType GetCompilerTypeImpl() override;<br>
<br>
   ConstString m_type_name;<br>
-  uint64_t m_byte_size;<br>
+  llvm::Optional<uint64_t> m_byte_size;<br>
<br>
   ValueObjectConstResultImpl m_impl;<br>
<br>
<br>
diff  --git a/lldb/include/lldb/Core/ValueObjectDynamicValue.h b/lldb/include/lldb/Core/ValueObjectDynamicValue.h<br>
index 9f5304b55e93..2806857339ef 100644<br>
--- a/lldb/include/lldb/Core/ValueObjectDynamicValue.h<br>
+++ b/lldb/include/lldb/Core/ValueObjectDynamicValue.h<br>
@@ -34,7 +34,7 @@ class ValueObjectDynamicValue : public ValueObject {<br>
 public:<br>
   ~ValueObjectDynamicValue() override;<br>
<br>
-  uint64_t GetByteSize() override;<br>
+  llvm::Optional<uint64_t> GetByteSize() override;<br>
<br>
   ConstString GetTypeName() override;<br>
<br>
<br>
diff  --git a/lldb/include/lldb/Core/ValueObjectMemory.h b/lldb/include/lldb/Core/ValueObjectMemory.h<br>
index d1cd6ae41445..b5d5e6ecf4c0 100644<br>
--- a/lldb/include/lldb/Core/ValueObjectMemory.h<br>
+++ b/lldb/include/lldb/Core/ValueObjectMemory.h<br>
@@ -40,7 +40,7 @@ class ValueObjectMemory : public ValueObject {<br>
                                     const Address &address,<br>
                                     const CompilerType &ast_type);<br>
<br>
-  uint64_t GetByteSize() override;<br>
+  llvm::Optional<uint64_t> GetByteSize() override;<br>
<br>
   ConstString GetTypeName() override;<br>
<br>
<br>
diff  --git a/lldb/include/lldb/Core/ValueObjectRegister.h b/lldb/include/lldb/Core/ValueObjectRegister.h<br>
index 41051d93b707..3968584ad518 100644<br>
--- a/lldb/include/lldb/Core/ValueObjectRegister.h<br>
+++ b/lldb/include/lldb/Core/ValueObjectRegister.h<br>
@@ -36,7 +36,7 @@ class ValueObjectRegisterSet : public ValueObject {<br>
                                     lldb::RegisterContextSP &reg_ctx_sp,<br>
                                     uint32_t set_idx);<br>
<br>
-  uint64_t GetByteSize() override;<br>
+  llvm::Optional<uint64_t> GetByteSize() override;<br>
<br>
   lldb::ValueType GetValueType() const override {<br>
     return lldb::eValueTypeRegisterSet;<br>
@@ -86,7 +86,7 @@ class ValueObjectRegister : public ValueObject {<br>
                                     lldb::RegisterContextSP &reg_ctx_sp,<br>
                                     uint32_t reg_num);<br>
<br>
-  uint64_t GetByteSize() override;<br>
+  llvm::Optional<uint64_t> GetByteSize() override;<br>
<br>
   lldb::ValueType GetValueType() const override {<br>
     return lldb::eValueTypeRegister;<br>
<br>
diff  --git a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h<br>
index cb471657aec9..41c461ce13f0 100644<br>
--- a/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h<br>
+++ b/lldb/include/lldb/Core/ValueObjectSyntheticFilter.h<br>
@@ -36,7 +36,7 @@ class ValueObjectSynthetic : public ValueObject {<br>
 public:<br>
   ~ValueObjectSynthetic() override;<br>
<br>
-  uint64_t GetByteSize() override;<br>
+  llvm::Optional<uint64_t> GetByteSize() override;<br>
<br>
   ConstString GetTypeName() override;<br>
<br>
<br>
diff  --git a/lldb/include/lldb/Core/ValueObjectVariable.h b/lldb/include/lldb/Core/ValueObjectVariable.h<br>
index b7e262574a14..23fdedbf5a4a 100644<br>
--- a/lldb/include/lldb/Core/ValueObjectVariable.h<br>
+++ b/lldb/include/lldb/Core/ValueObjectVariable.h<br>
@@ -37,7 +37,7 @@ class ValueObjectVariable : public ValueObject {<br>
   static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope,<br>
                                     const lldb::VariableSP &var_sp);<br>
<br>
-  uint64_t GetByteSize() override;<br>
+  llvm::Optional<uint64_t> GetByteSize() override;<br>
<br>
   ConstString GetTypeName() override;<br>
<br>
<br>
diff  --git a/lldb/include/lldb/Expression/ExpressionVariable.h b/lldb/include/lldb/Expression/ExpressionVariable.h<br>
index 60062d212bad..4259e6395da4 100644<br>
--- a/lldb/include/lldb/Expression/ExpressionVariable.h<br>
+++ b/lldb/include/lldb/Expression/ExpressionVariable.h<br>
@@ -32,7 +32,7 @@ class ExpressionVariable<br>
<br>
   virtual ~ExpressionVariable();<br>
<br>
-  size_t GetByteSize() { return m_frozen_sp->GetByteSize(); }<br>
+  llvm::Optional<uint64_t> GetByteSize() { return m_frozen_sp->GetByteSize(); }<br>
<br>
   ConstString GetName() { return m_frozen_sp->GetName(); }<br>
<br>
<br>
diff  --git a/lldb/include/lldb/Target/StackFrameRecognizer.h b/lldb/include/lldb/Target/StackFrameRecognizer.h<br>
index 302b56bec907..baffc890bb06 100644<br>
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h<br>
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h<br>
@@ -154,7 +154,9 @@ class ValueObjectRecognizerSynthesizedValue : public ValueObject {<br>
     SetName(parent.GetName());<br>
   }<br>
<br>
-  uint64_t GetByteSize() override { return m_parent->GetByteSize(); }<br>
+  llvm::Optional<uint64_t> GetByteSize() override {<br>
+    return m_parent->GetByteSize();<br>
+  }<br>
   lldb::ValueType GetValueType() const override { return m_type; }<br>
   bool UpdateValue() override {<br>
     if (!m_parent->UpdateValueIfNeeded()) return false;<br>
<br>
diff  --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp<br>
index 7485b0ee1838..686d1f23a75a 100644<br>
--- a/lldb/source/API/SBValue.cpp<br>
+++ b/lldb/source/API/SBValue.cpp<br>
@@ -333,7 +333,7 @@ size_t SBValue::GetByteSize() {<br>
   ValueLocker locker;<br>
   lldb::ValueObjectSP value_sp(GetSP(locker));<br>
   if (value_sp) {<br>
-    result = value_sp->GetByteSize();<br>
+    result = value_sp->GetByteSize().getValueOr(0);<br>
   }<br>
<br>
   return result;<br>
<br>
diff  --git a/lldb/source/Commands/CommandObjectWatchpoint.cpp b/lldb/source/Commands/CommandObjectWatchpoint.cpp<br>
index ce4662930a7c..c2a008af79d6 100644<br>
--- a/lldb/source/Commands/CommandObjectWatchpoint.cpp<br>
+++ b/lldb/source/Commands/CommandObjectWatchpoint.cpp<br>
@@ -905,7 +905,7 @@ corresponding to the byte size of the data type.");<br>
         // We're in business.<br>
         // Find out the size of this variable.<br>
         size = m_option_watchpoint.watch_size == 0<br>
-                   ? valobj_sp->GetByteSize()<br>
+                   ? valobj_sp->GetByteSize().getValueOr(0)<br>
                    : m_option_watchpoint.watch_size;<br>
       }<br>
       compiler_type = valobj_sp->GetCompilerType();<br>
<br>
diff  --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp<br>
index 3a775b07e5e1..aedefd0cf0fd 100644<br>
--- a/lldb/source/Core/ValueObject.cpp<br>
+++ b/lldb/source/Core/ValueObject.cpp<br>
@@ -849,7 +849,7 @@ bool ValueObject::SetData(DataExtractor &data, Status &error) {<br>
   uint64_t count = 0;<br>
   const Encoding encoding = GetCompilerType().GetEncoding(count);<br>
<br>
-  const size_t byte_size = GetByteSize();<br>
+  const size_t byte_size = GetByteSize().getValueOr(0);<br>
<br>
   Value::ValueType value_type = m_value.GetValueType();<br>
<br>
@@ -1524,7 +1524,7 @@ bool ValueObject::SetValueFromCString(const char *value_str, Status &error) {<br>
   uint64_t count = 0;<br>
   const Encoding encoding = GetCompilerType().GetEncoding(count);<br>
<br>
-  const size_t byte_size = GetByteSize();<br>
+  const size_t byte_size = GetByteSize().getValueOr(0);<br>
<br>
   Value::ValueType value_type = m_value.GetValueType();<br>
<br>
@@ -1741,13 +1741,13 @@ ValueObjectSP ValueObject::GetSyntheticBitFieldChild(uint32_t from, uint32_t to,<br>
       uint32_t bit_field_offset = from;<br>
       if (GetDataExtractor().GetByteOrder() == eByteOrderBig)<br>
         bit_field_offset =<br>
-            GetByteSize() * 8 - bit_field_size - bit_field_offset;<br>
+            GetByteSize().getValueOr(0) * 8 - bit_field_size - bit_field_offset;<br>
       // We haven't made a synthetic array member for INDEX yet, so lets make<br>
       // one and cache it for any future reference.<br>
       ValueObjectChild *synthetic_child = new ValueObjectChild(<br>
-          *this, GetCompilerType(), index_const_str, GetByteSize(), 0,<br>
-          bit_field_size, bit_field_offset, false, false, eAddressTypeInvalid,<br>
-          0);<br>
+          *this, GetCompilerType(), index_const_str,<br>
+          GetByteSize().getValueOr(0), 0, bit_field_size, bit_field_offset,<br>
+          false, false, eAddressTypeInvalid, 0);<br>
<br>
       // Cache the value if we got one back...<br>
       if (synthetic_child) {<br>
<br>
diff  --git a/lldb/source/Core/ValueObjectCast.cpp b/lldb/source/Core/ValueObjectCast.cpp<br>
index 22e856be539b..7b6d3591faf4 100644<br>
--- a/lldb/source/Core/ValueObjectCast.cpp<br>
+++ b/lldb/source/Core/ValueObjectCast.cpp<br>
@@ -47,7 +47,7 @@ size_t ValueObjectCast::CalculateNumChildren(uint32_t max) {<br>
   return children_count <= max ? children_count : max;<br>
 }<br>
<br>
-uint64_t ValueObjectCast::GetByteSize() {<br>
+llvm::Optional<uint64_t> ValueObjectCast::GetByteSize() {<br>
   ExecutionContext exe_ctx(GetExecutionContextRef());<br>
   return m_value.GetValueByteSize(nullptr, &exe_ctx);<br>
 }<br>
<br>
diff  --git a/lldb/source/Core/ValueObjectConstResult.cpp b/lldb/source/Core/ValueObjectConstResult.cpp<br>
index 8d84f8e62ccc..fd31ddc676b4 100644<br>
--- a/lldb/source/Core/ValueObjectConstResult.cpp<br>
+++ b/lldb/source/Core/ValueObjectConstResult.cpp<br>
@@ -179,8 +179,7 @@ ValueObjectSP ValueObjectConstResult::Create(ExecutionContextScope *exe_scope,<br>
 ValueObjectConstResult::ValueObjectConstResult(ExecutionContextScope *exe_scope,<br>
                                                ValueObjectManager &manager,<br>
                                                const Status &error)<br>
-    : ValueObject(exe_scope, manager), m_type_name(), m_byte_size(0),<br>
-      m_impl(this) {<br>
+    : ValueObject(exe_scope, manager), m_impl(this) {<br>
   m_error = error;<br>
   SetIsConstant();<br>
 }<br>
@@ -189,8 +188,7 @@ ValueObjectConstResult::ValueObjectConstResult(ExecutionContextScope *exe_scope,<br>
                                                ValueObjectManager &manager,<br>
                                                const Value &value,<br>
                                                ConstString name, Module *module)<br>
-    : ValueObject(exe_scope, manager), m_type_name(), m_byte_size(0),<br>
-      m_impl(this) {<br>
+    : ValueObject(exe_scope, manager), m_impl(this) {<br>
   m_value = value;<br>
   m_name = name;<br>
   ExecutionContext exe_ctx;<br>
@@ -208,9 +206,9 @@ lldb::ValueType ValueObjectConstResult::GetValueType() const {<br>
   return eValueTypeConstResult;<br>
 }<br>
<br>
-uint64_t ValueObjectConstResult::GetByteSize() {<br>
+llvm::Optional<uint64_t> ValueObjectConstResult::GetByteSize() {<br>
   ExecutionContext exe_ctx(GetExecutionContextRef());<br>
-  if (m_byte_size == 0) {<br>
+  if (!m_byte_size) {<br>
     if (auto size =<br>
         GetCompilerType().GetByteSize(exe_ctx.GetBestExecutionContextScope()))<br>
       SetByteSize(*size);<br>
<br>
diff  --git a/lldb/source/Core/ValueObjectDynamicValue.cpp b/lldb/source/Core/ValueObjectDynamicValue.cpp<br>
index ca66740cb55d..1c25b8c85a05 100644<br>
--- a/lldb/source/Core/ValueObjectDynamicValue.cpp<br>
+++ b/lldb/source/Core/ValueObjectDynamicValue.cpp<br>
@@ -98,7 +98,7 @@ size_t ValueObjectDynamicValue::CalculateNumChildren(uint32_t max) {<br>
     return m_parent->GetNumChildren(max);<br>
 }<br>
<br>
-uint64_t ValueObjectDynamicValue::GetByteSize() {<br>
+llvm::Optional<uint64_t> ValueObjectDynamicValue::GetByteSize() {<br>
   const bool success = UpdateValueIfNeeded(false);<br>
   if (success && m_dynamic_type_info.HasType()) {<br>
     ExecutionContext exe_ctx(GetExecutionContextRef());<br>
<br>
diff  --git a/lldb/source/Core/ValueObjectMemory.cpp b/lldb/source/Core/ValueObjectMemory.cpp<br>
index 8e7d3ebc93f6..17fade9e5fdc 100644<br>
--- a/lldb/source/Core/ValueObjectMemory.cpp<br>
+++ b/lldb/source/Core/ValueObjectMemory.cpp<br>
@@ -139,13 +139,11 @@ size_t ValueObjectMemory::CalculateNumChildren(uint32_t max) {<br>
   return child_count <= max ? child_count : max;<br>
 }<br>
<br>
-uint64_t ValueObjectMemory::GetByteSize() {<br>
+llvm::Optional<uint64_t> ValueObjectMemory::GetByteSize() {<br>
   ExecutionContext exe_ctx(GetExecutionContextRef());<br>
   if (m_type_sp)<br>
-    return m_type_sp->GetByteSize(exe_ctx.GetBestExecutionContextScope())<br>
-        .getValueOr(0);<br>
-  return m_compiler_type.GetByteSize(exe_ctx.GetBestExecutionContextScope())<br>
-      .getValueOr(0);<br>
+    return m_type_sp->GetByteSize(exe_ctx.GetBestExecutionContextScope());<br>
+  return m_compiler_type.GetByteSize(exe_ctx.GetBestExecutionContextScope());<br>
 }<br>
<br>
 lldb::ValueType ValueObjectMemory::GetValueType() const {<br>
<br>
diff  --git a/lldb/source/Core/ValueObjectRegister.cpp b/lldb/source/Core/ValueObjectRegister.cpp<br>
index ec87c38fb367..27461e9cebc4 100644<br>
--- a/lldb/source/Core/ValueObjectRegister.cpp<br>
+++ b/lldb/source/Core/ValueObjectRegister.cpp<br>
@@ -81,7 +81,7 @@ size_t ValueObjectRegisterSet::CalculateNumChildren(uint32_t max) {<br>
   return 0;<br>
 }<br>
<br>
-uint64_t ValueObjectRegisterSet::GetByteSize() { return 0; }<br>
+llvm::Optional<uint64_t> ValueObjectRegisterSet::GetByteSize() { return 0; }<br>
<br>
 bool ValueObjectRegisterSet::UpdateValue() {<br>
   m_error.Clear();<br>
@@ -229,7 +229,9 @@ size_t ValueObjectRegister::CalculateNumChildren(uint32_t max) {<br>
   return children_count <= max ? children_count : max;<br>
 }<br>
<br>
-uint64_t ValueObjectRegister::GetByteSize() { return m_reg_info.byte_size; }<br>
+llvm::Optional<uint64_t> ValueObjectRegister::GetByteSize() {<br>
+  return m_reg_info.byte_size;<br>
+}<br>
<br>
 bool ValueObjectRegister::UpdateValue() {<br>
   m_error.Clear();<br>
<br>
diff  --git a/lldb/source/Core/ValueObjectSyntheticFilter.cpp b/lldb/source/Core/ValueObjectSyntheticFilter.cpp<br>
index 32d1e6ab8368..fb2d32e602ce 100644<br>
--- a/lldb/source/Core/ValueObjectSyntheticFilter.cpp<br>
+++ b/lldb/source/Core/ValueObjectSyntheticFilter.cpp<br>
@@ -121,7 +121,9 @@ bool ValueObjectSynthetic::MightHaveChildren() {<br>
   return (m_might_have_children != eLazyBoolNo);<br>
 }<br>
<br>
-uint64_t ValueObjectSynthetic::GetByteSize() { return m_parent->GetByteSize(); }<br>
+llvm::Optional<uint64_t> ValueObjectSynthetic::GetByteSize() {<br>
+  return m_parent->GetByteSize();<br>
+}<br>
<br>
 lldb::ValueType ValueObjectSynthetic::GetValueType() const {<br>
   return m_parent->GetValueType();<br>
<br>
diff  --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp<br>
index 0d1e7b047a0a..ab67e3038cf0 100644<br>
--- a/lldb/source/Core/ValueObjectVariable.cpp<br>
+++ b/lldb/source/Core/ValueObjectVariable.cpp<br>
@@ -105,15 +105,15 @@ size_t ValueObjectVariable::CalculateNumChildren(uint32_t max) {<br>
   return child_count <= max ? child_count : max;<br>
 }<br>
<br>
-uint64_t ValueObjectVariable::GetByteSize() {<br>
+llvm::Optional<uint64_t> ValueObjectVariable::GetByteSize() {<br>
   ExecutionContext exe_ctx(GetExecutionContextRef());<br>
<br>
   CompilerType type(GetCompilerType());<br>
<br>
   if (!type.IsValid())<br>
-    return 0;<br>
+    return {};<br>
<br>
-  return type.GetByteSize(exe_ctx.GetBestExecutionContextScope()).getValueOr(0);<br>
+  return type.GetByteSize(exe_ctx.GetBestExecutionContextScope());<br>
 }<br>
<br>
 lldb::ValueType ValueObjectVariable::GetValueType() const {<br>
<br>
diff  --git a/lldb/source/Expression/ExpressionVariable.cpp b/lldb/source/Expression/ExpressionVariable.cpp<br>
index d95f0745cf4b..8b3dda7b2fe1 100644<br>
--- a/lldb/source/Expression/ExpressionVariable.cpp<br>
+++ b/lldb/source/Expression/ExpressionVariable.cpp<br>
@@ -16,10 +16,10 @@ using namespace lldb_private;<br>
 ExpressionVariable::~ExpressionVariable() {}<br>
<br>
 uint8_t *ExpressionVariable::GetValueBytes() {<br>
-  const size_t byte_size = m_frozen_sp->GetByteSize();<br>
-  if (byte_size > 0) {<br>
-    if (m_frozen_sp->GetDataExtractor().GetByteSize() < byte_size) {<br>
-      m_frozen_sp->GetValue().ResizeData(byte_size);<br>
+  llvm::Optional<uint64_t> byte_size = m_frozen_sp->GetByteSize();<br>
+  if (byte_size && *byte_size) {<br>
+    if (m_frozen_sp->GetDataExtractor().GetByteSize() < *byte_size) {<br>
+      m_frozen_sp->GetValue().ResizeData(*byte_size);<br>
       m_frozen_sp->GetValue().GetData(m_frozen_sp->GetDataExtractor());<br>
     }<br>
     return const_cast<uint8_t *>(<br>
<br>
diff  --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp<br>
index 6f8d9b154570..327e15a26266 100644<br>
--- a/lldb/source/Expression/Materializer.cpp<br>
+++ b/lldb/source/Expression/Materializer.cpp<br>
@@ -67,7 +67,7 @@ class EntityPersistentVariable : public Materializer::Entity {<br>
     const bool zero_memory = false;<br>
<br>
     lldb::addr_t mem = map.Malloc(<br>
-        m_persistent_variable_sp->GetByteSize(), 8,<br>
+        m_persistent_variable_sp->GetByteSize().getValueOr(0), 8,<br>
         lldb::ePermissionsReadable | lldb::ePermissionsWritable,<br>
         IRMemoryMap::eAllocationPolicyMirror, zero_memory, allocate_error);<br>
<br>
@@ -106,7 +106,8 @@ class EntityPersistentVariable : public Materializer::Entity {<br>
     Status write_error;<br>
<br>
     map.WriteMemory(mem, m_persistent_variable_sp->GetValueBytes(),<br>
-                    m_persistent_variable_sp->GetByteSize(), write_error);<br>
+                    m_persistent_variable_sp->GetByteSize().getValueOr(0),<br>
+                    write_error);<br>
<br>
     if (!write_error.Success()) {<br>
       err.SetErrorStringWithFormat(<br>
@@ -234,7 +235,7 @@ class EntityPersistentVariable : public Materializer::Entity {<br>
             map.GetBestExecutionContextScope(),<br>
             m_persistent_variable_sp.get()->GetCompilerType(),<br>
             m_persistent_variable_sp->GetName(), location, eAddressTypeLoad,<br>
-            m_persistent_variable_sp->GetByteSize());<br>
+            m_persistent_variable_sp->GetByteSize().getValueOr(0));<br>
<br>
         if (frame_top != LLDB_INVALID_ADDRESS &&<br>
             frame_bottom != LLDB_INVALID_ADDRESS && location >= frame_bottom &&<br>
@@ -279,7 +280,8 @@ class EntityPersistentVariable : public Materializer::Entity {<br>
         LLDB_LOGF(log, "Dematerializing %s from 0x%" PRIx64 " (size = %llu)",<br>
                   m_persistent_variable_sp->GetName().GetCString(),<br>
                   (uint64_t)mem,<br>
-                  (unsigned long long)m_persistent_variable_sp->GetByteSize());<br>
+                  (unsigned long long)m_persistent_variable_sp->GetByteSize()<br>
+                      .getValueOr(0));<br>
<br>
         // Read the contents of the spare memory area<br>
<br>
@@ -288,7 +290,7 @@ class EntityPersistentVariable : public Materializer::Entity {<br>
         Status read_error;<br>
<br>
         map.ReadMemory(m_persistent_variable_sp->GetValueBytes(), mem,<br>
-                       m_persistent_variable_sp->GetByteSize(), read_error);<br>
+                       m_persistent_variable_sp->GetByteSize().getValueOr(0), read_error);<br>
<br>
         if (!read_error.Success()) {<br>
           err.SetErrorStringWithFormat(<br>
@@ -369,10 +371,11 @@ class EntityPersistentVariable : public Materializer::Entity {<br>
       if (!err.Success()) {<br>
         dump_stream.Printf("  <could not be read>\n");<br>
       } else {<br>
-        DataBufferHeap data(m_persistent_variable_sp->GetByteSize(), 0);<br>
+        DataBufferHeap data(<br>
+            m_persistent_variable_sp->GetByteSize().getValueOr(0), 0);<br>
<br>
         map.ReadMemory(data.GetBytes(), target_address,<br>
-                       m_persistent_variable_sp->GetByteSize(), err);<br>
+                       m_persistent_variable_sp->GetByteSize().getValueOr(0), err);<br>
<br>
         if (!err.Success()) {<br>
           dump_stream.Printf("  <could not be read>\n");<br>
@@ -621,8 +624,8 @@ class EntityVariable : public Materializer::Entity {<br>
<br>
       Status extract_error;<br>
<br>
-      map.GetMemoryData(data, m_temporary_allocation, valobj_sp->GetByteSize(),<br>
-                        extract_error);<br>
+      map.GetMemoryData(data, m_temporary_allocation,<br>
+                        valobj_sp->GetByteSize().getValueOr(0), extract_error);<br>
<br>
       if (!extract_error.Success()) {<br>
         err.SetErrorStringWithFormat("couldn't get the data for variable %s",<br>
@@ -919,7 +922,7 @@ class EntityResultVariable : public Materializer::Entity {<br>
<br>
     ret->ValueUpdated();<br>
<br>
-    const size_t pvar_byte_size = ret->GetByteSize();<br>
+    const size_t pvar_byte_size = ret->GetByteSize().getValueOr(0);<br>
     uint8_t *pvar_data = ret->GetValueBytes();<br>
<br>
     map.ReadMemory(pvar_data, address, pvar_byte_size, read_error);<br>
<br>
diff  --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp<br>
index 098aed9cd812..22bca52d7f98 100644<br>
--- a/lldb/source/Target/StackFrame.cpp<br>
+++ b/lldb/source/Target/StackFrame.cpp<br>
@@ -1408,7 +1408,7 @@ ValueObjectSP GetValueForOffset(StackFrame &frame, ValueObjectSP &parent,<br>
     }<br>
<br>
     int64_t child_offset = child_sp->GetByteOffset();<br>
-    int64_t child_size = child_sp->GetByteSize();<br>
+    int64_t child_size = child_sp->GetByteSize().getValueOr(0);<br>
<br>
     if (offset >= child_offset && offset < (child_offset + child_size)) {<br>
       return GetValueForOffset(frame, child_sp, offset - child_offset);<br>
@@ -1441,8 +1441,8 @@ ValueObjectSP GetValueForDereferincingOffset(StackFrame &frame,<br>
   }<br>
<br>
   if (offset >= 0 && uint64_t(offset) >= pointee->GetByteSize()) {<br>
-    int64_t index = offset / pointee->GetByteSize();<br>
-    offset = offset % pointee->GetByteSize();<br>
+    int64_t index = offset / pointee->GetByteSize().getValueOr(1);<br>
+    offset = offset % pointee->GetByteSize().getValueOr(1);<br>
     const bool can_create = true;<br>
     pointee = base->GetSyntheticArrayMember(index, can_create);<br>
   }<br>
<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank" rel="noreferrer">lldb-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div>
</div></blockquote></div><br></div></div></blockquote></div>