[libcxx-commits] [libcxxabi] 2612316 - [ItaniumDemangle] Add template name to the substitutions list during demangling (#108538)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Sep 23 02:49:46 PDT 2024
Author: Viktoriia Bakalova
Date: 2024-09-23T11:49:41+02:00
New Revision: 2612316f72b92d7905717c358aeab8b8141738a1
URL: https://github.com/llvm/llvm-project/commit/2612316f72b92d7905717c358aeab8b8141738a1
DIFF: https://github.com/llvm/llvm-project/commit/2612316f72b92d7905717c358aeab8b8141738a1.diff
LOG: [ItaniumDemangle] Add template name to the substitutions list during demangling (#108538)
When demangling a template template parameter (`method<bool,
Bar>(Bar<bool> b)`), the current demangler version first enters the
template argument (`bool`) into the substitutions list, then the whole
template specialization (`Bar<bool>`). The template name (`Bar`) never
becomes a substitution candidate on its own.
This is different when mangling. Mangling `method<bool, Bar>(Bar<bool>
b, Bar<int> i)` substitutes the `Bar` in the second parameter with the
substitution for `TemplateTemplateParmDecl`.
This leads to a discrepancy between mangler and demangler, see
https://github.com/llvm/llvm-project/issues/108009.
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 6b3f228fba926e..723bdfe324b140 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -4450,6 +4450,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
// parse them, take the second production.
if (TryToParseTemplateArgs && look() == 'I') {
+ Subs.push_back(Result);
Node *TA = getDerived().parseTemplateArgs();
if (TA == nullptr)
return nullptr;
diff --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp
index c8d4ca8637e8da..17786a3a486fcd 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -30024,6 +30024,9 @@ const char* cases[][2] =
// See https://github.com/itanium-cxx-abi/cxx-abi/issues/165.
{"_ZN1C1fIiEEvDTtlNS_UlT_TL0__E_EEE", "void C::f<int>(decltype(C::'lambda'(int, auto){}))"},
+ // See https://github.com/llvm/llvm-project/issues/108009.
+ {"_ZN3FooIiE6methodIb3BarEEvT0_IT_ES3_IiE", "void Foo<int>::method<bool, Bar>(Bar<bool>, Bar<int>)"},
+
// C++20 class type non-type template parameters:
{"_Z1fIXtl1BLPi0ELi1EEEEvv", "void f<B{(int*)0, 1}>()"},
{"_Z1fIXtl1BLPi32EEEEvv", "void f<B{(int*)32}>()"},
diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index 31af04276ca306..9ada4d747b1ce9 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -4450,6 +4450,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
// parse them, take the second production.
if (TryToParseTemplateArgs && look() == 'I') {
+ Subs.push_back(Result);
Node *TA = getDerived().parseTemplateArgs();
if (TA == nullptr)
return nullptr;
More information about the libcxx-commits
mailing list