From 34edb2537fd700451dece7fd76d48deb8fc14ab8 Mon Sep 17 00:00:00 2001 From: Alex Denisov Date: Fri, 29 Jul 2022 10:33:55 +0200 Subject: [PATCH] Swift: mangle TypeAliasDecls differently --- swift/extractor/visitors/DeclVisitor.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/swift/extractor/visitors/DeclVisitor.cpp b/swift/extractor/visitors/DeclVisitor.cpp index dc693e66a0f0..05392711a54e 100644 --- a/swift/extractor/visitors/DeclVisitor.cpp +++ b/swift/extractor/visitors/DeclVisitor.cpp @@ -296,6 +296,14 @@ std::string DeclVisitor::mangledName(const swift::ValueDecl& decl) { if (decl.getKind() == swift::DeclKind::Module) { return static_cast(decl).getRealName().str().str(); } + // In cases like this (when coming from PCM) + // typealias CFXMLTree = CFTree + // typealias CFXMLTreeRef = CFXMLTree + // mangleAnyDecl mangles both CFXMLTree and CFXMLTreeRef into 'So12CFXMLTreeRefa' + // which is not correct and causes inconsistencies. mangleEntity makes these two distinct + if (decl.getKind() == swift::DeclKind::TypeAlias) { + return mangler.mangleEntity(&decl); + } // prefix adds a couple of special symbols, we don't necessary need them return mangler.mangleAnyDecl(&decl, /* prefix = */ false); }