Skip to content

Commit a5d4945

Browse files
committed
move function type handling into SwiftLanguageRuntimeImpl
1 parent dc3fcf9 commit a5d4945

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,16 +2075,13 @@ uint32_t
20752075
TypeSystemSwiftTypeRef::GetNumChildren(opaque_compiler_type_t type,
20762076
bool omit_empty_base_classes,
20772077
const ExecutionContext *exe_ctx) {
2078-
if (IsFunctionType(type, nullptr))
2079-
return 0;
2080-
20812078
if (exe_ctx)
20822079
if (auto *exe_scope = exe_ctx->GetBestExecutionContextScope())
20832080
if (auto *runtime =
20842081
SwiftLanguageRuntime::Get(exe_scope->CalculateProcess()))
20852082
if (auto num_children =
20862083
runtime->GetNumChildren(GetCanonicalType(type), nullptr)) {
2087-
// Use lambda to intercept and unwrap the `Optional` return value.
2084+
// Use a lambda to intercept and unwrap the `Optional` return value.
20882085
return [&]() {
20892086
auto impl = [&]() { return num_children; };
20902087
VALIDATE_AND_RETURN(

lldb/source/Target/SwiftLanguageRuntimeDynamicTypeResolution.cpp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,14 +1012,20 @@ SwiftLanguageRuntimeImpl::GetNumChildren(CompilerType type,
10121012
// Structs and Tuples.
10131013
if (auto *rti =
10141014
llvm::dyn_cast_or_null<swift::reflection::RecordTypeInfo>(ti)) {
1015-
// `OpaqueExistential` is documented as:
1016-
// An existential is a three-word buffer followed by value metadata...
1017-
// The buffer is exposed by as children named `payload_data_{0,1,2}`, and
1018-
// requires the number of fields to be increased.
1019-
if (rti->getRecordKind() ==
1020-
swift::reflection::RecordKind::OpaqueExistential)
1015+
switch (rti->getRecordKind()) {
1016+
case swift::reflection::RecordKind::ThickFunction:
1017+
// There are two fields, `function` and `context`, but they're not exposed
1018+
// by lldb.
1019+
return 0;
1020+
case swift::reflection::RecordKind::OpaqueExistential:
1021+
// `OpaqueExistential` is documented as:
1022+
// An existential is a three-word buffer followed by value metadata...
1023+
// The buffer is exposed as children named `payload_data_{0,1,2}`, and
1024+
// the number of fields are increased to match.
10211025
return rti->getNumFields() + 3;
1022-
return rti->getNumFields();
1026+
default:
1027+
return rti->getNumFields();
1028+
}
10231029
}
10241030
if (auto *eti = llvm::dyn_cast_or_null<swift::reflection::EnumTypeInfo>(ti)) {
10251031
return eti->getNumPayloadCases();

0 commit comments

Comments
 (0)