[demangler] Don't allow the template parameters from the <encoding> in a

<local-name> to leak out into later parts of the name.

This caused us to fail to demangle certain constructs involving generic
lambdas.
This commit is contained in:
Richard Smith 2020-07-09 20:36:04 -07:00
parent 00c9a504ae
commit 553dbb6d7b
3 changed files with 14 additions and 0 deletions

View File

@ -5096,6 +5096,8 @@ Node *AbstractManglingParser<Derived, Alloc>::parseSpecialName() {
// ::= <special-name>
template <typename Derived, typename Alloc>
Node *AbstractManglingParser<Derived, Alloc>::parseEncoding() {
ScopedTemplateParamList EncodingTemplateParams(this);
if (look() == 'G' || look() == 'T')
return getDerived().parseSpecialName();

View File

@ -29792,6 +29792,16 @@ const char* cases[][2] =
// "auto inline_func()::'lambda'<int, int>(int, int) const"
{"_ZZ11inline_funcvENKUlTyTyT_T0_E_clIiiEEDaS_S0_", "auto inline_func()::'lambda'<typename $T, typename $T0>($T, $T0)::operator()<int, int>($T, $T0) const"},
{"_ZZ11inline_funcvENKUlTyTyT_T1_T0_E_clIiiiEEDaS_S0_S1_", "auto inline_func()::'lambda'<typename $T, typename $T0>($T, auto, $T0)::operator()<int, int, int>($T, auto, $T0) const"},
{"_ZN1XIZ1fIiEvOT_EUlOT_DpT0_E_EclIJEEEvDpT_", "void X<void f<int>(int&&)::'lambda'(auto&&, auto...)>::operator()<>()"},
// FIXME: This is wrong, should demangle to the same as the previous entry.
// See https://github.com/itanium-cxx-abi/cxx-abi/issues/106.
{"_ZN1XIZ1fIiEvOT_EUlS2_DpT0_E_EclIJEEEvDpT_", "void X<void f<int>(int&&)::'lambda'(int&&, auto...)>::operator()<>()"},
// FIXME: This is wrong; the S2_ backref should expand to OT_ and then to
// "double&&". But we can't cope with a substitution that represents a
// different type the node it is a substitute for.
// See https://github.com/itanium-cxx-abi/cxx-abi/issues/106.
{"_Z1h1XIJZ1fIiEDaOT_E1AZ1gIdEDaS2_E1BEE", "h(X<auto f<int>(int&&)::A, auto g<double>(int&&)::B>)"},
{"_Z1fIL4Enumn1EEvv", "void f<(Enum)-1>()"},

View File

@ -5096,6 +5096,8 @@ Node *AbstractManglingParser<Derived, Alloc>::parseSpecialName() {
// ::= <special-name>
template <typename Derived, typename Alloc>
Node *AbstractManglingParser<Derived, Alloc>::parseEncoding() {
ScopedTemplateParamList EncodingTemplateParams(this);
if (look() == 'G' || look() == 'T')
return getDerived().parseSpecialName();