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

Richard Smith via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 9 20:38:33 PDT 2020


Author: Richard Smith
Date: 2020-07-09T20:38:19-07:00
New Revision: 553dbb6d7b32cc786281dea2c58a420bcbc9bb82

URL: https://github.com/llvm/llvm-project/commit/553dbb6d7b32cc786281dea2c58a420bcbc9bb82
DIFF: https://github.com/llvm/llvm-project/commit/553dbb6d7b32cc786281dea2c58a420bcbc9bb82.diff

LOG: [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.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index dcece3899213..0f81675f244d 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -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();
 

diff  --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp
index c75b6974881e..b8b2ad51a994 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -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
+    // 
diff erent 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>()"},
 

diff  --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index dcece3899213..0f81675f244d 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -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();
 


        


More information about the llvm-commits mailing list