[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
This commit is contained in:
Augusto Noronha
2025-12-08 14:35:11 -08:00
parent df3aa1e011
commit ab507becb4

View File

@@ -2643,6 +2643,26 @@ private:
return resultAddress;
}
Demangle::NodePointer
buildContextDescriptorManglingForSymbol(llvm::StringRef symbol,
Demangler &dem) {
if (auto demangledSymbol = buildContextManglingForSymbol(symbol, dem)) {
// Look through Type nodes since we're building up a mangling here.
if (demangledSymbol->getKind() == Demangle::Node::Kind::Type) {
demangledSymbol = demangledSymbol->getChild(0);
}
return demangledSymbol;
}
return nullptr;
}
Demangle::NodePointer
buildContextDescriptorManglingForSymbol(const std::string &symbol,
Demangler &dem) {
return buildContextDescriptorManglingForSymbol(dem.copyString(symbol), dem);
}
Demangle::NodePointer
buildContextDescriptorMangling(const ParentContextDescriptorRef &descriptor,
Demangler &dem, int recursion_limit) {
@@ -2656,15 +2676,7 @@ private:
// Try to demangle the symbol name to figure out what context it would
// point to.
auto demangledSymbol = buildContextManglingForSymbol(descriptor.getSymbol(),
dem);
if (!demangledSymbol)
return nullptr;
// Look through Type notes since we're building up a mangling here.
if (demangledSymbol->getKind() == Demangle::Node::Kind::Type){
demangledSymbol = demangledSymbol->getChild(0);
}
return demangledSymbol;
return buildContextDescriptorManglingForSymbol(descriptor.getSymbol(), dem);
}
Demangle::NodePointer
@@ -2680,7 +2692,7 @@ private:
Reader->resolvePointerAsSymbol(descriptor.getRemoteAddress())) {
auto symbol = remoteAbsolutePointer->getSymbol();
if (!symbol.empty()) {
if (auto demangledSymbol = buildContextManglingForSymbol(symbol, dem)) {
if (auto demangledSymbol = buildContextDescriptorManglingForSymbol(symbol, dem)) {
return demangledSymbol;
}
}