From 433d1374409a8eeaa4b0975fa187a542d5e40c23 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 7 Nov 2009 04:26:04 +0000 Subject: [PATCH] When looking up and adding substitutions to the substitution table, make sure to always use the canonical declaration. With tihs change, FileCheck compiles and links but crashes during startup. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86339 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/Mangle.cpp | 3 +++ test/CodeGenCXX/mangle-subst.cpp | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index 11bbaae018..081156cb6e 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -65,6 +65,8 @@ namespace { bool mangleStandardSubstitution(const NamedDecl *ND); void addSubstitution(const NamedDecl *ND) { + ND = cast(ND->getCanonicalDecl()); + addSubstitution(reinterpret_cast(ND)); } void addSubstitution(QualType T); @@ -1174,6 +1176,7 @@ bool CXXNameMangler::mangleSubstitution(const NamedDecl *ND) { if (mangleStandardSubstitution(ND)) return true; + ND = cast(ND->getCanonicalDecl()); return mangleSubstitution(reinterpret_cast(ND)); } diff --git a/test/CodeGenCXX/mangle-subst.cpp b/test/CodeGenCXX/mangle-subst.cpp index 46a21b62b5..a940f4f447 100644 --- a/test/CodeGenCXX/mangle-subst.cpp +++ b/test/CodeGenCXX/mangle-subst.cpp @@ -59,3 +59,11 @@ template void ft3(S1, S1); // CHECK: @_Z1fPKcS0_ void f(const char*, const char*) {} +namespace NS { + class C; +} + +namespace NS { + // CHECK: @_ZN2NS1fERNS_1CE + void f(C&) { } +} -- 2.50.1