Skip to content

Commit b82ad6d

Browse files
committed
[lldb] Wire-up TypeSystemSwiftTypeRef::GetNumChildren
1 parent 2919e1a commit b82ad6d

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2065,13 +2065,30 @@ lldb::Encoding TypeSystemSwiftTypeRef::GetEncoding(opaque_compiler_type_t type,
20652065
lldb::Format TypeSystemSwiftTypeRef::GetFormat(opaque_compiler_type_t type) {
20662066
return m_swift_ast_context->GetFormat(ReconstructType(type));
20672067
}
2068+
20682069
uint32_t
20692070
TypeSystemSwiftTypeRef::GetNumChildren(opaque_compiler_type_t type,
20702071
bool omit_empty_base_classes,
20712072
const ExecutionContext *exe_ctx) {
2072-
return m_swift_ast_context->GetNumChildren(ReconstructType(type),
2073-
omit_empty_base_classes, exe_ctx);
2073+
auto impl = [&]() -> uint32_t {
2074+
if (!exe_ctx)
2075+
return 0;
2076+
2077+
// TODO: which of these should be logged on failure?
2078+
if (auto *exe_scope = exe_ctx->GetBestExecutionContextScope())
2079+
if (auto *runtime =
2080+
SwiftLanguageRuntime::Get(exe_scope->CalculateProcess()))
2081+
if (auto num_children =
2082+
runtime->GetNumChildren(GetCanonicalType(type), nullptr))
2083+
return *num_children;
2084+
2085+
return 0;
2086+
};
2087+
VALIDATE_AND_RETURN(
2088+
impl, GetNumChildren, type,
2089+
(ReconstructType(type), omit_empty_base_classes, exe_ctx));
20742090
}
2091+
20752092
uint32_t TypeSystemSwiftTypeRef::GetNumFields(opaque_compiler_type_t type) {
20762093
return m_swift_ast_context->GetNumFields(ReconstructType(type));
20772094
}

0 commit comments

Comments
 (0)