Skip to content

Implement TypeSystemSwiftTypeRef::GetReferentType() #2268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion lldb/source/Plugins/TypeSystem/Swift/TypeSystemSwiftTypeRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2515,7 +2515,21 @@ CompilerType TypeSystemSwiftTypeRef::GetErrorType() {

CompilerType
TypeSystemSwiftTypeRef::GetReferentType(opaque_compiler_type_t type) {
return m_swift_ast_context->GetReferentType(ReconstructType(type));
auto impl = [&]() -> CompilerType {
using namespace swift::Demangle;
Demangler dem;
NodePointer node = GetDemangledType(dem, AsMangledName(type));
if (!node ||
(node->getKind() != Node::Kind::Unowned &&
node->getKind() != Node::Kind::Unmanaged) ||
!node->hasChildren())
return {this, type};
node = node->getFirstChild();
if (!node || node->getKind() != Node::Kind::Type || !node->hasChildren())
return {this, type};
return RemangleAsType(dem, node);
};
VALIDATE_AND_RETURN(impl, GetReferentType, type, (ReconstructType(type)));
}

CompilerType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,7 @@ llvm::Optional<uint64_t> SwiftLanguageRuntimeImpl::GetMemberVariableOffset(

static CompilerType GetWeakReferent(TypeSystemSwiftTypeRef &ts,
CompilerType type) {
// FIXME: This is very similar to TypeSystemSwiftTypeRef::GetReferentType().
using namespace swift::Demangle;
Demangler dem;
auto mangled = type.GetMangledTypeName().GetStringRef();
Expand Down