Skip to content

Commit ab507be

Browse files
committed
[RemoteInspection] Factor out buildContextDescriptorManglingForSymbol
A previous commit introduced the usage of buildContextManglingForSymbol in buildContextDescriptorMangling, which was not quite correct, since type nodes needed extra handling, which was done in the other version of buildContextDescriptorMangling. This patch factors out the handling of building context descriptors mangling from symbols, and updates both call sites to use the new function instead. rdar://165950673
1 parent df3aa1e commit ab507be

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

include/swift/Remote/MetadataReader.h

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2643,6 +2643,26 @@ class MetadataReader {
26432643
return resultAddress;
26442644
}
26452645

2646+
Demangle::NodePointer
2647+
buildContextDescriptorManglingForSymbol(llvm::StringRef symbol,
2648+
Demangler &dem) {
2649+
if (auto demangledSymbol = buildContextManglingForSymbol(symbol, dem)) {
2650+
// Look through Type nodes since we're building up a mangling here.
2651+
if (demangledSymbol->getKind() == Demangle::Node::Kind::Type) {
2652+
demangledSymbol = demangledSymbol->getChild(0);
2653+
}
2654+
return demangledSymbol;
2655+
}
2656+
2657+
return nullptr;
2658+
}
2659+
2660+
Demangle::NodePointer
2661+
buildContextDescriptorManglingForSymbol(const std::string &symbol,
2662+
Demangler &dem) {
2663+
return buildContextDescriptorManglingForSymbol(dem.copyString(symbol), dem);
2664+
}
2665+
26462666
Demangle::NodePointer
26472667
buildContextDescriptorMangling(const ParentContextDescriptorRef &descriptor,
26482668
Demangler &dem, int recursion_limit) {
@@ -2656,15 +2676,7 @@ class MetadataReader {
26562676

26572677
// Try to demangle the symbol name to figure out what context it would
26582678
// point to.
2659-
auto demangledSymbol = buildContextManglingForSymbol(descriptor.getSymbol(),
2660-
dem);
2661-
if (!demangledSymbol)
2662-
return nullptr;
2663-
// Look through Type notes since we're building up a mangling here.
2664-
if (demangledSymbol->getKind() == Demangle::Node::Kind::Type){
2665-
demangledSymbol = demangledSymbol->getChild(0);
2666-
}
2667-
return demangledSymbol;
2679+
return buildContextDescriptorManglingForSymbol(descriptor.getSymbol(), dem);
26682680
}
26692681

26702682
Demangle::NodePointer
@@ -2680,7 +2692,7 @@ class MetadataReader {
26802692
Reader->resolvePointerAsSymbol(descriptor.getRemoteAddress())) {
26812693
auto symbol = remoteAbsolutePointer->getSymbol();
26822694
if (!symbol.empty()) {
2683-
if (auto demangledSymbol = buildContextManglingForSymbol(symbol, dem)) {
2695+
if (auto demangledSymbol = buildContextDescriptorManglingForSymbol(symbol, dem)) {
26842696
return demangledSymbol;
26852697
}
26862698
}

0 commit comments

Comments
 (0)