Skip to content

Commit 17511c0

Browse files
committed
MetadataReader: Build demanglings for opaque type contexts.
When building for debug, the opaque return type context is nested under an anonymous context for the defining function. Demangle the anonymous context name to reconstruct the mangling for the opaque type.
1 parent fc8be62 commit 17511c0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

include/swift/Remote/MetadataReader.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2111,6 +2111,29 @@ class MetadataReader {
21112111
// contexts; just create the node directly here and return.
21122112
return dem.createNode(nodeKind, std::move(moduleName));
21132113
}
2114+
2115+
case ContextDescriptorKind::OpaqueType: {
2116+
// The opaque type may have a named anonymous context for us to map
2117+
// back to its defining decl.
2118+
if (!parentDescriptorResult)
2119+
return nullptr;
2120+
auto anonymous =
2121+
dyn_cast_or_null<TargetAnonymousContextDescriptor<Runtime>>(
2122+
parentDescriptorResult->getLocalBuffer());
2123+
if (!anonymous)
2124+
return nullptr;
2125+
2126+
auto mangledNode =
2127+
demangleAnonymousContextName(*parentDescriptorResult, dem);
2128+
if (!mangledNode)
2129+
return nullptr;
2130+
if (mangledNode->getKind() == Node::Kind::Global)
2131+
mangledNode = mangledNode->getChild(0);
2132+
2133+
auto opaqueNode = dem.createNode(Node::Kind::OpaqueReturnTypeOf);
2134+
opaqueNode->addChild(mangledNode, dem);
2135+
return opaqueNode;
2136+
}
21142137

21152138
default:
21162139
// Not a kind of context we know about.

0 commit comments

Comments
 (0)