From 88599176d106453935a8fa984f690362cc48b470 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Sun, 27 Sep 2009 01:06:07 +0000 Subject: [PATCH] Look for substitutions when mangling TypenameTypes. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82885 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/Mangle.cpp | 9 ++++++--- test/CodeGenCXX/mangle-subst.cpp | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/Mangle.cpp b/lib/CodeGen/Mangle.cpp index 447255c668..660a36bce0 100644 --- a/lib/CodeGen/Mangle.cpp +++ b/lib/CodeGen/Mangle.cpp @@ -920,10 +920,13 @@ void CXXNameMangler::mangleType(const TypenameType *T) { const Type *QTy = T->getQualifier()->getAsType(); if (const TemplateSpecializationType *TST = dyn_cast(QTy)) { - TemplateDecl *TD = TST->getTemplateName().getAsTemplateDecl(); + if (!mangleSubstitution(QualType(TST, 0))) { + TemplateDecl *TD = TST->getTemplateName().getAsTemplateDecl(); - mangleTemplatePrefix(TD); - mangleTemplateArgs(TST->getArgs(), TST->getNumArgs()); + mangleTemplatePrefix(TD); + mangleTemplateArgs(TST->getArgs(), TST->getNumArgs()); + addSubstitution(QualType(TST, 0)); + } } else if (const TemplateTypeParmType *TTPT = dyn_cast(QTy)) { // We use the QualType mangle type variant here because it handles diff --git a/test/CodeGenCXX/mangle-subst.cpp b/test/CodeGenCXX/mangle-subst.cpp index 2ff375e711..cda6df58ea 100644 --- a/test/CodeGenCXX/mangle-subst.cpp +++ b/test/CodeGenCXX/mangle-subst.cpp @@ -31,3 +31,18 @@ struct C { // CHECK: define void @_Z1fN1C1DERS_PS_S1_( void f(C::D, C&, C*, C&) { } + +template +struct V { + typedef int U; +}; + +template void f1(typename V::U, V) { } + +// CHECK: @_Z2f1IiEvN1VIT_E1UES2_ +template void f1(int, V); + +template void f2(V, typename V::U) { } + +// CHECK: @_Z2f2IiEv1VIT_ENS2_1UE +template void f2(V, int); -- 2.40.0