@@ -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 ;
@@ -2203,7 +2206,9 @@ bool SwiftLanguageRuntime::GetDynamicTypeAndAddress_Existential(
2203
2206
2204
2207
2205
2208
if (use_local_buffer)
2206
- PushLocalBuffer (existential_address, in_value.GetByteSize ().value_or (0 ));
2209
+ PushLocalBuffer (
2210
+ existential_address,
2211
+ llvm::expectedToOptional (in_value.GetByteSize ()).value_or (0 ));
2207
2212
2208
2213
swift::remote::RemoteAddress remote_existential (existential_address);
2209
2214
@@ -2451,7 +2456,7 @@ CompilerType SwiftLanguageRuntime::BindGenericTypeParameters(
2451
2456
LLDB_LOG_ERROR (
2452
2457
GetLog (LLDBLog::Expressions | LLDBLog::Types),
2453
2458
type_ref_or_err.takeError (),
2454
- " Couldn't get rype ref when binding generic type parameters: {0}" );
2459
+ " Couldn't get type ref when binding generic type parameters: {0}" );
2455
2460
failure = true ;
2456
2461
return ;
2457
2462
}
@@ -2616,8 +2621,8 @@ bool SwiftLanguageRuntime::GetDynamicTypeAndAddress_Value(
2616
2621
ExecutionContextScope *exe_scope = exe_ctx.GetBestExecutionContextScope ();
2617
2622
if (!exe_scope)
2618
2623
return false ;
2619
- std::optional<uint64_t > size =
2620
- bound_type.GetByteSize (exe_ctx.GetBestExecutionContextScope ());
2624
+ std::optional<uint64_t > size = llvm::expectedToOptional (
2625
+ bound_type.GetByteSize (exe_ctx.GetBestExecutionContextScope ())) ;
2621
2626
if (!size)
2622
2627
return false ;
2623
2628
AddressType address_type;
@@ -2633,7 +2638,8 @@ bool SwiftLanguageRuntime::GetDynamicTypeAndAddress_Value(
2633
2638
if (in_value_buffer.empty ())
2634
2639
return false ;
2635
2640
// If the dynamic type doesn't in the buffer we can't use it either.
2636
- if (in_value_buffer.size () < bound_type.GetByteSize (exe_scope))
2641
+ if (in_value_buffer.size () <
2642
+ llvm::expectedToOptional (bound_type.GetByteSize (exe_scope)).value_or (0 ))
2637
2643
return false ;
2638
2644
2639
2645
value_type = Value::GetValueTypeFromAddressType (address_type);
@@ -2739,8 +2745,9 @@ Value::ValueType SwiftLanguageRuntime::GetValueType(
2739
2745
}
2740
2746
2741
2747
if (use_local_buffer)
2742
- PushLocalBuffer (existential_address,
2743
- in_value.GetByteSize ().value_or (0 ));
2748
+ PushLocalBuffer (
2749
+ existential_address,
2750
+ llvm::expectedToOptional (in_value.GetByteSize ()).value_or (0 ));
2744
2751
2745
2752
// Read the value witness table and check if the data is inlined in
2746
2753
// the existential container or not.
@@ -3260,7 +3267,10 @@ SwiftLanguageRuntime::GetTypeRef(CompilerType type,
3260
3267
auto type_ref_or_err = reflection_ctx->GetTypeRef (
3261
3268
dem, node, module_holder->GetDescriptorFinder ());
3262
3269
if (!type_ref_or_err)
3263
- return type_ref_or_err.takeError ();
3270
+ return llvm::joinErrors (
3271
+ llvm::createStringError (" cannot get typeref for type %s" ,
3272
+ type.GetMangledTypeName ().GetCString ()),
3273
+ type_ref_or_err.takeError ());
3264
3274
3265
3275
if (log && log->GetVerbose ()) {
3266
3276
std::stringstream ss;
@@ -3466,14 +3476,12 @@ SwiftLanguageRuntime::ResolveTypeAlias(CompilerType alias) {
3466
3476
return llvm::createStringError (" cannot resolve type alias via reflection" );
3467
3477
}
3468
3478
3469
- std::optional <uint64_t >
3479
+ llvm::Expected <uint64_t >
3470
3480
SwiftLanguageRuntime::GetBitSize (CompilerType type,
3471
3481
ExecutionContextScope *exe_scope) {
3472
3482
auto type_info_or_err = GetSwiftRuntimeTypeInfo (type, exe_scope);
3473
- if (!type_info_or_err) {
3474
- LLDB_LOG_ERROR (GetLog (LLDBLog::Types), type_info_or_err.takeError (), " {0}" );
3475
- return {};
3476
- }
3483
+ if (!type_info_or_err)
3484
+ return type_info_or_err.takeError ();
3477
3485
3478
3486
return type_info_or_err->getSize () * 8 ;
3479
3487
}
0 commit comments