-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[ItaniumDemangle] Add template name to the substitutions list during demangling #108538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…emangling. 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 llvm#108009.
@llvm/pr-subscribers-libcxxabi Author: Viktoriia Bakalova (VitaNuo) Changes…emangling. When demangling a template template parameter ( This is different when mangling. Mangling This leads to a discrepancy between mangler and demangler, see #108009. Full diff: https://github.com/llvm/llvm-project/pull/108538.diff 3 Files Affected:
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index 3b041efe3aac00..d1f8da9d6b57b1 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -4336,6 +4336,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 77f79e0d40e84f..44af7e041cbcf4 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 0af0224bc83fa8..21144bd8c07060 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -4336,6 +4336,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;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me, thanks!
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 theBar
in the second parameter with the substitution forTemplateTemplateParmDecl
.This leads to a discrepancy between mangler and demangler, see #108009.