@@ -381,7 +381,8 @@ class LLDBTypeInfoProvider : public swift::remote::TypeInfoProvider {
381
381
return nullptr ;
382
382
TypeSystemSwiftTypeRef &typesystem = *m_ts;
383
383
// Build a TypeInfo for the Clang type.
384
- auto size = clang_type.GetByteSize (exe_scope);
384
+ std::optional<uint64_t > size =
385
+ llvm::expectedToOptional (clang_type.GetByteSize (exe_scope));
385
386
auto bit_align = clang_type.GetTypeBitAlign (exe_scope);
386
387
std::vector<swift::reflection::FieldInfo> fields;
387
388
if (clang_type.IsAggregateType ()) {
@@ -1214,9 +1215,11 @@ llvm::Expected<CompilerType> SwiftLanguageRuntime::GetChildCompilerTypeAtIndex(
1214
1215
if (auto pack_element_type = ts->GetSILPackElementAtIndex (type, idx)) {
1215
1216
llvm::raw_string_ostream os (child_name);
1216
1217
os << ' .' << idx;
1217
- child_byte_size =
1218
- GetBitSize (pack_element_type, exe_ctx.GetBestExecutionContextScope ())
1219
- .value_or (0 );
1218
+ auto size_or_err =
1219
+ GetBitSize (pack_element_type, exe_ctx.GetBestExecutionContextScope ());
1220
+ if (!size_or_err)
1221
+ return size_or_err.takeError ();
1222
+ child_byte_size = *size_or_err;
1220
1223
int stack_dir = -1 ;
1221
1224
child_byte_offset = ts->GetPointerByteSize () * idx * stack_dir;
1222
1225
child_bitfield_bit_size = 0 ;
@@ -2197,7 +2200,9 @@ bool SwiftLanguageRuntime::GetDynamicTypeAndAddress_Existential(
2197
2200
2198
2201
2199
2202
if (use_local_buffer)
2200
- PushLocalBuffer (existential_address, in_value.GetByteSize ().value_or (0 ));
2203
+ PushLocalBuffer (
2204
+ existential_address,
2205
+ llvm::expectedToOptional (in_value.GetByteSize ()).value_or (0 ));
2201
2206
2202
2207
swift::remote::RemoteAddress remote_existential (existential_address);
2203
2208
@@ -2445,7 +2450,7 @@ CompilerType SwiftLanguageRuntime::BindGenericTypeParameters(
2445
2450
LLDB_LOG_ERROR (
2446
2451
GetLog (LLDBLog::Expressions | LLDBLog::Types),
2447
2452
type_ref_or_err.takeError (),
2448
- " Couldn't get rype ref when binding generic type parameters: {0}" );
2453
+ " Couldn't get type ref when binding generic type parameters: {0}" );
2449
2454
failure = true ;
2450
2455
return ;
2451
2456
}
@@ -2610,8 +2615,8 @@ bool SwiftLanguageRuntime::GetDynamicTypeAndAddress_Value(
2610
2615
ExecutionContextScope *exe_scope = exe_ctx.GetBestExecutionContextScope ();
2611
2616
if (!exe_scope)
2612
2617
return false ;
2613
- std::optional<uint64_t > size =
2614
- bound_type.GetByteSize (exe_ctx.GetBestExecutionContextScope ());
2618
+ std::optional<uint64_t > size = llvm::expectedToOptional (
2619
+ bound_type.GetByteSize (exe_ctx.GetBestExecutionContextScope ())) ;
2615
2620
if (!size)
2616
2621
return false ;
2617
2622
AddressType address_type;
@@ -2627,7 +2632,8 @@ bool SwiftLanguageRuntime::GetDynamicTypeAndAddress_Value(
2627
2632
if (in_value_buffer.empty ())
2628
2633
return false ;
2629
2634
// If the dynamic type doesn't in the buffer we can't use it either.
2630
- if (in_value_buffer.size () < bound_type.GetByteSize (exe_scope))
2635
+ if (in_value_buffer.size () <
2636
+ llvm::expectedToOptional (bound_type.GetByteSize (exe_scope)).value_or (0 ))
2631
2637
return false ;
2632
2638
2633
2639
value_type = Value::GetValueTypeFromAddressType (address_type);
@@ -2733,8 +2739,9 @@ Value::ValueType SwiftLanguageRuntime::GetValueType(
2733
2739
}
2734
2740
2735
2741
if (use_local_buffer)
2736
- PushLocalBuffer (existential_address,
2737
- in_value.GetByteSize ().value_or (0 ));
2742
+ PushLocalBuffer (
2743
+ existential_address,
2744
+ llvm::expectedToOptional (in_value.GetByteSize ()).value_or (0 ));
2738
2745
2739
2746
// Read the value witness table and check if the data is inlined in
2740
2747
// the existential container or not.
@@ -3254,7 +3261,10 @@ SwiftLanguageRuntime::GetTypeRef(CompilerType type,
3254
3261
auto type_ref_or_err = reflection_ctx->GetTypeRef (
3255
3262
dem, node, module_holder->GetDescriptorFinder ());
3256
3263
if (!type_ref_or_err)
3257
- return type_ref_or_err.takeError ();
3264
+ return llvm::joinErrors (
3265
+ llvm::createStringError (" cannot get typeref for type %s" ,
3266
+ type.GetMangledTypeName ().GetCString ()),
3267
+ type_ref_or_err.takeError ());
3258
3268
3259
3269
if (log && log->GetVerbose ()) {
3260
3270
std::stringstream ss;
@@ -3460,14 +3470,12 @@ SwiftLanguageRuntime::ResolveTypeAlias(CompilerType alias) {
3460
3470
return llvm::createStringError (" cannot resolve type alias via reflection" );
3461
3471
}
3462
3472
3463
- std::optional <uint64_t >
3473
+ llvm::Expected <uint64_t >
3464
3474
SwiftLanguageRuntime::GetBitSize (CompilerType type,
3465
3475
ExecutionContextScope *exe_scope) {
3466
3476
auto type_info_or_err = GetSwiftRuntimeTypeInfo (type, exe_scope);
3467
- if (!type_info_or_err) {
3468
- LLDB_LOG_ERROR (GetLog (LLDBLog::Types), type_info_or_err.takeError (), " {0}" );
3469
- return {};
3470
- }
3477
+ if (!type_info_or_err)
3478
+ return type_info_or_err.takeError ();
3471
3479
3472
3480
return type_info_or_err->getSize () * 8 ;
3473
3481
}
0 commit comments