From f32fb674927ea34fced96d9f7fc937795359c2e3 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 21 Feb 2025 10:31:40 -0800 Subject: [PATCH] [lldb] Thread llvm::Expected through closure (cherry picked from commit 86937ad9a51892ae1a1e3320ae2c98d8a49ea5ed) --- .../SwiftLanguageRuntimeDynamicTypeResolution.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp b/lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp index e886d3a500711..b40b46682c87e 100644 --- a/lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp +++ b/lldb/source/Plugins/LanguageRuntime/Swift/SwiftLanguageRuntimeDynamicTypeResolution.cpp @@ -1201,7 +1201,7 @@ llvm::Expected SwiftLanguageRuntime::GetChildCompilerTypeAtIndex( auto get_from_field_info = [&](const swift::reflection::FieldInfo &field, std::optional tuple, - bool hide_existentials, bool is_enum) -> CompilerType { + bool hide_existentials, bool is_enum) -> llvm::Expected { bool is_indirect_enum = is_enum && !field.Offset && field.TR && llvm::isa(field.TR) && @@ -1228,20 +1228,18 @@ llvm::Expected SwiftLanguageRuntime::GetChildCompilerTypeAtIndex( else if (is_indirect_enum) { ThreadSafeReflectionContext reflection_ctx = GetReflectionContext(); if (!reflection_ctx) - return {}; + return llvm::createStringError("no reflection context"); // The indirect enum field should point to a closure context. LLDBTypeInfoProvider tip(*this, &exe_ctx); lldb::addr_t instance = ::MaskMaybeBridgedPointer(GetProcess(), pointer); auto ti_or_err = reflection_ctx->GetTypeInfoFromInstance( instance, &tip, ts->GetDescriptorFinder()); - if (!ti_or_err) { - LLDB_LOG_ERRORV(GetLog(LLDBLog::Types), ti_or_err.takeError(), "{0}"); - return {}; - } + if (!ti_or_err) + return ti_or_err.takeError(); auto *ti = &*ti_or_err; auto *rti = llvm::dyn_cast_or_null(ti); if (rti->getFields().size() < 1) - return {}; + return llvm::createStringError("no fields in indirect enum"); auto &field = rti->getFields()[0]; auto *type_ref = field.TR; result = GetTypeFromTypeRef(*ts, type_ref);