[Demangler] Stable parent identifier in OpaqueReturnTypeParent

`OpaqueReturnTypeParent` node now references the parent with a mangled parent name, rather than a parent pointer. This makes trees obtained from different demanglers (or calls to `Demangler::demangleSymbol`) for the same symbol equal.
This commit is contained in:
Dmitrii Galimzianov
2024-09-18 00:43:48 +02:00
parent 4693a4765f
commit df9ecd9a4c
4 changed files with 567 additions and 20 deletions

View File

@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "swift/Demangling/Demangle.h"
#include "swift/Demangling/Demangler.h"
#include "gtest/gtest.h"
using namespace swift::Demangle;
@@ -43,3 +44,17 @@ TEST(Demangle, CustomGenericParameterNames) {
std::string Result = demangleSymbolAsString(SymbolName, Options);
EXPECT_STREQ(DemangledName.c_str(), Result.c_str());
}
TEST(Demangle, DeepEquals) {
static std::string Symbols[]{
#define SYMBOL(Mangled, Demangled) Mangled,
#include "ManglingTestData.def"
};
for (const auto &Symbol : Symbols) {
Demangler D1;
Demangler D2;
auto tree1 = D1.demangleSymbol(Symbol);
auto tree2 = D2.demangleSymbol(Symbol);
EXPECT_TRUE(tree1->isDeepEqualTo(tree2)) << "Failing symbol: " << Symbol;
}
}