Skip to content

Commit 9d2a0f5

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 (cherry picked from commit ab507be)
1 parent eeae558 commit 9d2a0f5

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
@@ -2659,6 +2659,26 @@ class MetadataReader {
26592659
return resultAddress;
26602660
}
26612661

2662+
Demangle::NodePointer
2663+
buildContextDescriptorManglingForSymbol(llvm::StringRef symbol,
2664+
Demangler &dem) {
2665+
if (auto demangledSymbol = buildContextManglingForSymbol(symbol, dem)) {
2666+
// Look through Type nodes since we're building up a mangling here.
2667+
if (demangledSymbol->getKind() == Demangle::Node::Kind::Type) {
2668+
demangledSymbol = demangledSymbol->getChild(0);
2669+
}
2670+
return demangledSymbol;
2671+
}
2672+
2673+
return nullptr;
2674+
}
2675+
2676+
Demangle::NodePointer
2677+
buildContextDescriptorManglingForSymbol(const std::string &symbol,
2678+
Demangler &dem) {
2679+
return buildContextDescriptorManglingForSymbol(dem.copyString(symbol), dem);
2680+
}
2681+
26622682
Demangle::NodePointer
26632683
buildContextDescriptorMangling(const ParentContextDescriptorRef &descriptor,
26642684
Demangler &dem, int recursion_limit) {
@@ -2672,15 +2692,7 @@ class MetadataReader {
26722692

26732693
// Try to demangle the symbol name to figure out what context it would
26742694
// point to.
2675-
auto demangledSymbol = buildContextManglingForSymbol(descriptor.getSymbol(),
2676-
dem);
2677-
if (!demangledSymbol)
2678-
return nullptr;
2679-
// Look through Type notes since we're building up a mangling here.
2680-
if (demangledSymbol->getKind() == Demangle::Node::Kind::Type){
2681-
demangledSymbol = demangledSymbol->getChild(0);
2682-
}
2683-
return demangledSymbol;
2695+
return buildContextDescriptorManglingForSymbol(descriptor.getSymbol(), dem);
26842696
}
26852697

26862698
Demangle::NodePointer
@@ -2696,7 +2708,7 @@ class MetadataReader {
26962708
Reader->resolvePointerAsSymbol(descriptor.getRemoteAddress())) {
26972709
auto symbol = remoteAbsolutePointer->getSymbol();
26982710
if (!symbol.empty()) {
2699-
if (auto demangledSymbol = buildContextManglingForSymbol(symbol, dem)) {
2711+
if (auto demangledSymbol = buildContextDescriptorManglingForSymbol(symbol, dem)) {
27002712
return demangledSymbol;
27012713
}
27022714
}

0 commit comments

Comments
 (0)