Skip to content

Commit e2b3e9a

Browse files
committed
[lldb] Add fallback to TypeSystemSwiftTypeRef::GetByteStride
If TypeSystemSwiftTypeRef::GetByteStride fails, we should fallback to SwiftASTContext, much like the other functions in the typeref typesystem. rdar://105124851
1 parent c478370 commit e2b3e9a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2582,8 +2582,15 @@ TypeSystemSwiftTypeRef::GetByteStride(opaque_compiler_type_t type,
25822582
auto impl = [&]() -> llvm::Optional<uint64_t> {
25832583
if (auto *runtime =
25842584
SwiftLanguageRuntime::Get(exe_scope->CalculateProcess())) {
2585-
return runtime->GetByteStride(GetCanonicalType(type));
2585+
if (auto stride = runtime->GetByteStride(GetCanonicalType(type)))
2586+
return stride;
25862587
}
2588+
// Runtime failed, fallback to SwiftASTContext.
2589+
LLDB_LOGF(GetLog(LLDBLog::Types),
2590+
"Couldn't compute stride of type %s using SwiftLanguageRuntime.",
2591+
AsMangledName(type));
2592+
if (auto *swift_ast_context = GetSwiftASTContext())
2593+
return swift_ast_context->GetByteStride(ReconstructType(type), exe_scope);
25872594
return {};
25882595
};
25892596
VALIDATE_AND_RETURN(impl, GetByteStride, type, exe_scope,

0 commit comments

Comments
 (0)