Itanium ABI: Template template parameters are usable as substitutions

Template template parameters weren't added to the list of substitutions.
This would make the substitution map contain inaccurate mappings,
leading to Clang violating the Itanium ABI and breaking compatibility
with GCC.

This fixes PR21351.

Differential Revision: http://reviews.llvm.org/D5959

llvm-svn: 220588
This commit is contained in:
David Majnemer 2014-10-24 20:22:57 +00:00
parent 8925dc0ae0
commit 90a3b19e64
2 changed files with 29 additions and 10 deletions

View File

@ -637,13 +637,11 @@ void CXXNameMangler::mangleUnscopedTemplateName(const TemplateDecl *ND) {
return;
// <template-template-param> ::= <template-param>
if (const TemplateTemplateParmDecl *TTP
= dyn_cast<TemplateTemplateParmDecl>(ND)) {
if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND))
mangleTemplateParameter(TTP->getIndex());
return;
}
else
mangleUnscopedName(ND->getTemplatedDecl());
mangleUnscopedName(ND->getTemplatedDecl());
addSubstitution(ND);
}
@ -1563,14 +1561,13 @@ void CXXNameMangler::mangleTemplatePrefix(const TemplateDecl *ND,
return;
// <template-template-param> ::= <template-param>
if (const TemplateTemplateParmDecl *TTP
= dyn_cast<TemplateTemplateParmDecl>(ND)) {
if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(ND)) {
mangleTemplateParameter(TTP->getIndex());
return;
} else {
manglePrefix(getEffectiveDeclContext(ND), NoFunction);
mangleUnqualifiedName(ND->getTemplatedDecl());
}
manglePrefix(getEffectiveDeclContext(ND), NoFunction);
mangleUnqualifiedName(ND->getTemplatedDecl());
addSubstitution(ND);
}

View File

@ -991,3 +991,25 @@ namespace test48 {
template void f<S>(S::u *);
// CHECK-LABEL: define weak_odr void @_ZN6test481fINS_1SEEEvPTuNT_1uE(%"union.test48::S::u"*)
}
namespace test49 {
template <int>
struct S {};
template <template <int> class T>
T<3> fin(T<3>);
auto v = fin<S>;
// CHECK-LABEL: declare void @_ZN6test493finINS_1SEEET_ILi3EES3_()
}
namespace test50 {
template <int>
struct S {};
template <template <int> class T>
T<3> fin(T<4>);
auto v = fin<S>;
// CHECK-LABEL: declare void @_ZN6test503finINS_1SEEET_ILi3EES2_ILi4EE()
}