[demangler] Don't allow the template parameters from the <encoding> in a
authorRichard Smith <richard@metafoo.co.uk>
Fri, 10 Jul 2020 03:36:04 +0000 (20:36 -0700)
committerRichard Smith <richard@metafoo.co.uk>
Fri, 10 Jul 2020 03:38:19 +0000 (20:38 -0700)
<local-name> to leak out into later parts of the name.

This caused us to fail to demangle certain constructs involving generic
lambdas.

libcxxabi/src/demangle/ItaniumDemangle.h
libcxxabi/test/test_demangle.pass.cpp
llvm/include/llvm/Demangle/ItaniumDemangle.h

index dcece38..0f81675 100644 (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();
 
index c75b697..b8b2ad5 100644 (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>()"},
 
index dcece38..0f81675 100644 (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();