Skip to content

Commit 209d8c8

Browse files
authored
[clang] fix unresolved dependent template specialization mangling (#136201)
This fixes a regression introduced in #133610 which was reported here #133610 (comment) and in #136119 This redoes previous attempt in #135111 When mangling a DTST which appears in the prefix, the template name is not actually relevant, as its prefix is part of the nested name anyway, and a substitution is not allowed at that position in any case. Fixes #136119
1 parent 94aa4bf commit 209d8c8

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

clang/lib/AST/ItaniumMangle.cpp

+2-11
Original file line numberDiff line numberDiff line change
@@ -1405,16 +1405,6 @@ void CXXNameMangler::mangleUnresolvedPrefix(NestedNameSpecifier *qualifier,
14051405
// - a template template parameter with arguments
14061406
// In all of these cases, we should have no prefix.
14071407
if (NestedNameSpecifier *Prefix = qualifier->getPrefix()) {
1408-
if (const auto *DTST =
1409-
dyn_cast<DependentTemplateSpecializationType>(type)) {
1410-
Out << "srN";
1411-
TemplateName Template = getASTContext().getDependentTemplateName(
1412-
{Prefix, DTST->getDependentTemplateName().getName(),
1413-
/*HasTemplateKeyword=*/true});
1414-
mangleTemplatePrefix(Template);
1415-
mangleTemplateArgs(Template, DTST->template_arguments());
1416-
break;
1417-
}
14181408
mangleUnresolvedPrefix(Prefix,
14191409
/*recursive=*/true);
14201410
} else {
@@ -2618,7 +2608,8 @@ bool CXXNameMangler::mangleUnresolvedTypeOrSimpleId(QualType Ty,
26182608
cast<DependentTemplateSpecializationType>(Ty);
26192609
TemplateName Template = getASTContext().getDependentTemplateName(
26202610
DTST->getDependentTemplateName());
2621-
mangleTemplatePrefix(Template);
2611+
const DependentTemplateStorage &S = DTST->getDependentTemplateName();
2612+
mangleSourceName(S.getName().getIdentifier());
26222613
mangleTemplateArgs(Template, DTST->template_arguments());
26232614
break;
26242615
}

clang/test/CodeGenCXX/mangle-template.cpp

+17
Original file line numberDiff line numberDiff line change
@@ -416,3 +416,20 @@ namespace unresolved_template_specialization_type {
416416
template enable_if<true> raw_hash_set<int>::AbslHashValue<HashStateBase>();
417417
// CHECH: @_ZN39unresolved_template_specialization_type12raw_hash_setIiE13AbslHashValueINS_13HashStateBaseEEENS_9enable_ifIXsrNT_11is_hashableIiEE5valueEEEv
418418
} // namespace unresolved_template_specialization_type
419+
420+
namespace GH133610 {
421+
template <class T> struct A {
422+
template <class V> struct B { int MEM; };
423+
};
424+
425+
struct D {};
426+
struct C: public A<int>::B<D> {};
427+
428+
template <class T, class U, class V>
429+
auto k(T t, U u, V v) -> decltype (t.U::template B<V>::MEM) { return {}; }
430+
431+
void t() {
432+
k( C(), A<int>(), D() );
433+
}
434+
// CHECK: @_ZN8GH1336101kINS_1CENS_1AIiEENS_1DEEEDtdtfp_sr1U1BIT1_EE3MEMET_T0_S5_
435+
} // namespace GH133610

0 commit comments

Comments
 (0)