@@ -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 ;
@@ -2236,7 +2239,9 @@ bool SwiftLanguageRuntime::GetDynamicTypeAndAddress_Existential(
2236
2239
2237
2240
2238
2241
if (use_local_buffer)
2239
- PushLocalBuffer (existential_address, in_value.GetByteSize ().value_or (0 ));
2242
+ PushLocalBuffer (
2243
+ existential_address,
2244
+ llvm::expectedToOptional (in_value.GetByteSize ()).value_or (0 ));
2240
2245
2241
2246
swift::remote::RemoteAddress remote_existential (existential_address);
2242
2247
@@ -2522,7 +2527,7 @@ CompilerType SwiftLanguageRuntime::BindGenericTypeParameters(
2522
2527
LLDB_LOG_ERROR (
2523
2528
GetLog (LLDBLog::Expressions | LLDBLog::Types),
2524
2529
type_ref_or_err.takeError (),
2525
- " Couldn't get rype ref when binding generic type parameters: {0}" );
2530
+ " Couldn't get type ref when binding generic type parameters: {0}" );
2526
2531
failure = true ;
2527
2532
return ;
2528
2533
}
@@ -2687,8 +2692,8 @@ bool SwiftLanguageRuntime::GetDynamicTypeAndAddress_Value(
2687
2692
ExecutionContextScope *exe_scope = exe_ctx.GetBestExecutionContextScope ();
2688
2693
if (!exe_scope)
2689
2694
return false ;
2690
- std::optional<uint64_t > size =
2691
- bound_type.GetByteSize (exe_ctx.GetBestExecutionContextScope ());
2695
+ std::optional<uint64_t > size = llvm::expectedToOptional (
2696
+ bound_type.GetByteSize (exe_ctx.GetBestExecutionContextScope ())) ;
2692
2697
if (!size)
2693
2698
return false ;
2694
2699
AddressType address_type;
@@ -2704,7 +2709,8 @@ bool SwiftLanguageRuntime::GetDynamicTypeAndAddress_Value(
2704
2709
if (in_value_buffer.empty ())
2705
2710
return false ;
2706
2711
// If the dynamic type doesn't in the buffer we can't use it either.
2707
- if (in_value_buffer.size () < bound_type.GetByteSize (exe_scope))
2712
+ if (in_value_buffer.size () <
2713
+ llvm::expectedToOptional (bound_type.GetByteSize (exe_scope)).value_or (0 ))
2708
2714
return false ;
2709
2715
2710
2716
value_type = Value::GetValueTypeFromAddressType (address_type);
@@ -2810,8 +2816,9 @@ Value::ValueType SwiftLanguageRuntime::GetValueType(
2810
2816
}
2811
2817
2812
2818
if (use_local_buffer)
2813
- PushLocalBuffer (existential_address,
2814
- in_value.GetByteSize ().value_or (0 ));
2819
+ PushLocalBuffer (
2820
+ existential_address,
2821
+ llvm::expectedToOptional (in_value.GetByteSize ()).value_or (0 ));
2815
2822
2816
2823
// Read the value witness table and check if the data is inlined in
2817
2824
// the existential container or not.
@@ -3331,7 +3338,10 @@ SwiftLanguageRuntime::GetTypeRef(CompilerType type,
3331
3338
auto type_ref_or_err = reflection_ctx->GetTypeRef (
3332
3339
dem, node, module_holder->GetDescriptorFinder ());
3333
3340
if (!type_ref_or_err)
3334
- return type_ref_or_err.takeError ();
3341
+ return llvm::joinErrors (
3342
+ llvm::createStringError (" cannot get typeref for type %s" ,
3343
+ type.GetMangledTypeName ().GetCString ()),
3344
+ type_ref_or_err.takeError ());
3335
3345
3336
3346
if (log && log->GetVerbose ()) {
3337
3347
std::stringstream ss;
@@ -3537,14 +3547,12 @@ SwiftLanguageRuntime::ResolveTypeAlias(CompilerType alias) {
3537
3547
return llvm::createStringError (" cannot resolve type alias via reflection" );
3538
3548
}
3539
3549
3540
- std::optional <uint64_t >
3550
+ llvm::Expected <uint64_t >
3541
3551
SwiftLanguageRuntime::GetBitSize (CompilerType type,
3542
3552
ExecutionContextScope *exe_scope) {
3543
3553
auto type_info_or_err = GetSwiftRuntimeTypeInfo (type, exe_scope);
3544
- if (!type_info_or_err) {
3545
- LLDB_LOG_ERROR (GetLog (LLDBLog::Types), type_info_or_err.takeError (), " {0}" );
3546
- return {};
3547
- }
3554
+ if (!type_info_or_err)
3555
+ return type_info_or_err.takeError ();
3548
3556
3549
3557
return type_info_or_err->getSize () * 8 ;
3550
3558
}
0 commit comments