Skip to content

Commit 03584dc

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 (cherry picked from commit e2b3e9a)
1 parent 8b2a58f commit 03584dc

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
@@ -2666,8 +2666,15 @@ TypeSystemSwiftTypeRef::GetByteStride(opaque_compiler_type_t type,
26662666
auto impl = [&]() -> llvm::Optional<uint64_t> {
26672667
if (auto *runtime =
26682668
SwiftLanguageRuntime::Get(exe_scope->CalculateProcess())) {
2669-
return runtime->GetByteStride(GetCanonicalType(type));
2669+
if (auto stride = runtime->GetByteStride(GetCanonicalType(type)))
2670+
return stride;
26702671
}
2672+
// Runtime failed, fallback to SwiftASTContext.
2673+
LLDB_LOGF(GetLog(LLDBLog::Types),
2674+
"Couldn't compute stride of type %s using SwiftLanguageRuntime.",
2675+
AsMangledName(type));
2676+
if (auto *swift_ast_context = GetSwiftASTContext())
2677+
return swift_ast_context->GetByteStride(ReconstructType(type), exe_scope);
26712678
return {};
26722679
};
26732680
VALIDATE_AND_RETURN(impl, GetByteStride, type, exe_scope,

0 commit comments

Comments
 (0)