From: Anders Carlsson Date: Sat, 26 Sep 2009 20:13:56 +0000 (+0000) Subject: Don't crash when trying to mangle function templates. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1668f2062b237ddb137f5d16388b3dea49651f85;p=clang Don't crash when trying to mangle function templates. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82872 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index 69e73e78c0..e07c38fd11 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -335,7 +335,7 @@ void CXXNameMangler::mangleUnscopedTemplateName(const TemplateDecl *ND) { if (mangleSubstitution(ND)) return; - mangleUnscopedName(ND); + mangleUnscopedName(ND->getTemplatedDecl()); addSubstitution(ND); } @@ -532,7 +532,7 @@ void CXXNameMangler::mangleTemplatePrefix(const TemplateDecl *ND) { // FIXME: and manglePrefix(ND->getDeclContext()); - mangleUnqualifiedName(ND); + mangleUnqualifiedName(ND->getTemplatedDecl()); } void diff --git a/test/CodeGenCXX/mangle.cpp b/test/CodeGenCXX/mangle.cpp index b61f1d00df..eb6267bb6e 100644 --- a/test/CodeGenCXX/mangle.cpp +++ b/test/CodeGenCXX/mangle.cpp @@ -155,3 +155,21 @@ template struct S6 { template void ft5(typename S6::B) { } // CHECK: @_Z3ft5IiEvN2S6IT_E1BE template void ft5(int); + +template class A {}; + +namespace NS { +template bool operator==(const A&, const A&) { return true; } +} + +// FIXME: This should be _ZN2NSeqIcEEbRK1AIT_ES5_ +// CHECK: @_ZN2NSeqIcEEbRK1AIT_ES4_ +template bool NS::operator==(const ::A&, const ::A&); + +namespace std { +template bool operator==(const A&, const A&) { return true; } +} + +// CHECK: @_ZSteqIcEbRK1AIT_ES4_ +template bool std::operator==(const ::A&, const ::A&); +