Skip to content

Commit 5e6723f

Browse files
committed
[lldb] TSSTypeRef::GetBitSize fallback to SASTContext if runtime fails
The usual strategy of TypeSystemSwiftTypeRef functions is to fallback to SwiftASTContext in case it fails, make GetBitSize follow that pattern. Also, always log that failure even in the case of types defined in the expression, as we've been recovering information for those types for a while now. rdar://96166383
1 parent 862cd9f commit 5e6723f

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,18 +2520,15 @@ TypeSystemSwiftTypeRef::GetBitSize(opaque_compiler_type_t type,
25202520
SwiftLanguageRuntime::Get(exe_scope->CalculateProcess())) {
25212521
if (auto result = runtime->GetBitSize({this, type}, exe_scope))
25222522
return result;
2523-
// If this is an expression context, perhaps the type was
2524-
// defined in the expression. In that case we don't have debug
2525-
// info for it, so defer to SwiftASTContext.
2526-
if (llvm::isa_and_nonnull<SwiftASTContextForExpressions>(
2527-
GetSwiftASTContext()))
2528-
return ReconstructType({this, type}).GetBitSize(exe_scope);
2523+
// Runtime failed, fallback to SwiftASTContext.
25292524
LLDB_LOGF(GetLog(LLDBLog::Types),
25302525
"Couldn't compute size of type %s using SwiftLanguageRuntime.",
25312526
AsMangledName(type));
2532-
return {};
2527+
if (auto *swift_ast_context = GetSwiftASTContext())
2528+
return swift_ast_context->GetBitSize(ReconstructType(type), exe_scope);
25332529
}
25342530

2531+
25352532
// FIXME: Move this to the top. Currently this causes VALIDATE
25362533
// errors on resilient types, and Foundation overlay types. These
25372534
// are most likely bugs in the Swift compiler that need to be

0 commit comments

Comments
 (0)