@@ -201,7 +201,7 @@ class RustCLikeEnum : public RustType {
201201 }
202202
203203 uint64_t ByteSize () const override {
204- return m_underlying_type.GetByteSize (nullptr );
204+ return m_underlying_type.GetByteSize (nullptr ). getValueOr ( 0 ) ;
205205 }
206206
207207 bool IsSigned () const {
@@ -337,7 +337,7 @@ class RustArray : public RustType {
337337 }
338338
339339 uint64_t ByteSize () const override {
340- return m_elem.GetByteSize (nullptr ) * m_length;
340+ return m_elem.GetByteSize (nullptr ). getValueOr ( 0 ) * m_length;
341341 }
342342
343343 std::string GetCABITypeDeclaration (RustASTContext::TypeNameMap *name_map,
@@ -804,7 +804,7 @@ class RustTypedef : public RustType {
804804 }
805805
806806 uint64_t ByteSize () const override {
807- return m_type.GetByteSize (nullptr );
807+ return m_type.GetByteSize (nullptr ). getValueOr ( 0 ) ;
808808 }
809809
810810 std::string GetCABITypeDeclaration (RustASTContext::TypeNameMap *name_map,
@@ -1266,7 +1266,7 @@ RustASTContext::GetArrayElementType(lldb::opaque_compiler_type_t type,
12661266 RustArray *array = static_cast <RustType *>(type)->AsArray ();
12671267 if (array) {
12681268 if (stride) {
1269- *stride = array->ElementType ().GetByteSize (nullptr );
1269+ *stride = array->ElementType ().GetByteSize (nullptr ). getValueOr ( 0 ) ;
12701270 }
12711271 return array->ElementType ();
12721272 }
@@ -1499,8 +1499,11 @@ CompilerType RustASTContext::GetChildCompilerTypeAtIndex(
14991499 uint64_t bit_offset;
15001500 CompilerType ret =
15011501 GetFieldAtIndex (type, idx, child_name, &bit_offset, nullptr , nullptr );
1502- child_byte_size = ret.GetByteSize (
1502+ llvm::Optional< uint64_t > size = ret.GetByteSize (
15031503 exe_ctx ? exe_ctx->GetBestExecutionContextScope () : nullptr );
1504+ if (!size)
1505+ return {};
1506+ child_byte_size = *size;
15041507 child_byte_offset = bit_offset / 8 ;
15051508 return ret;
15061509 } else if (RustPointer *ptr = t->AsPointer ()) {
@@ -1525,8 +1528,11 @@ CompilerType RustASTContext::GetChildCompilerTypeAtIndex(
15251528
15261529 // We have a pointer to an simple type
15271530 if (idx == 0 && pointee.GetCompleteType ()) {
1528- child_byte_size = pointee.GetByteSize (
1531+ llvm::Optional< uint64_t > size = pointee.GetByteSize (
15291532 exe_ctx ? exe_ctx->GetBestExecutionContextScope () : NULL );
1533+ if (!size)
1534+ return {};
1535+ child_byte_size = *size;
15301536 child_byte_offset = 0 ;
15311537 return pointee;
15321538 }
@@ -1538,8 +1544,11 @@ CompilerType RustASTContext::GetChildCompilerTypeAtIndex(
15381544 char element_name[64 ];
15391545 ::snprintf (element_name, sizeof (element_name), "[%zu]", idx);
15401546 child_name.assign (element_name);
1541- child_byte_size = element_type.GetByteSize (
1547+ llvm::Optional< uint64_t > size = element_type.GetByteSize (
15421548 exe_ctx ? exe_ctx->GetBestExecutionContextScope () : NULL );
1549+ if (!size)
1550+ return {};
1551+ child_byte_size = *size;
15431552 child_byte_offset = (int32_t )idx * (int32_t )child_byte_size;
15441553 return element_type;
15451554 }
@@ -1634,14 +1643,17 @@ bool RustASTContext::DumpTypeValue(lldb::opaque_compiler_type_t type, Stream *s,
16341643 CompilerType typedef_compiler_type = typ->UnderlyingType ();
16351644 if (format == eFormatDefault)
16361645 format = typedef_compiler_type.GetFormat ();
1637- uint64_t typedef_byte_size = typedef_compiler_type.GetByteSize (exe_scope);
1646+ llvm::Optional<uint64_t > typedef_byte_size =
1647+ typedef_compiler_type.GetByteSize (exe_scope);
1648+ if (!typedef_byte_size)
1649+ return false ;
16381650
16391651 return typedef_compiler_type.DumpTypeValue (
16401652 s,
16411653 format, // The format with which to display the element
16421654 data, // Data buffer containing all bytes for this type
16431655 byte_offset, // Offset into "data" where to grab value from
1644- typedef_byte_size, // Size of this type in bytes
1656+ * typedef_byte_size,// Size of this type in bytes
16451657 bitfield_bit_size, // Size in bits of a bitfield value, if zero don't
16461658 // treat as a bitfield
16471659 bitfield_bit_offset, // Offset in bits of a bitfield value if
0 commit comments