From 49232b9f428ec806befc2debb62609f4d72a43a4 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sat, 26 Sep 2009 20:13:56 +0000 Subject: [PATCH] Don't crash when trying to mangle function templates. llvm-svn: 82872 --- clang/lib/CodeGen/Mangle.cpp | 4 ++-- clang/test/CodeGenCXX/mangle.cpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/Mangle.cpp b/clang/lib/CodeGen/Mangle.cpp index 69e73e78c0fb..e07c38fd11b7 100644 --- a/clang/lib/CodeGen/Mangle.cpp +++ b/clang/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/clang/test/CodeGenCXX/mangle.cpp b/clang/test/CodeGenCXX/mangle.cpp index b61f1d00df80..eb6267bb6e0a 100644 --- a/clang/test/CodeGenCXX/mangle.cpp +++ b/clang/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&); +