Skip to content

Commit b5ca4bc

Browse files
[ItaniumDemangle] Unconditionally parse substitution template arguments
With the current mangled name parser, when we try to parse a type name inside the template argument of an operator, we end up not parsing any template arguments of substitutions, which ends up causing things to fail in certain cases. This is compliant with the Itanium ABI documentation as far as I can tell. I tried to look through the git history to find out why the limitation on parsing template arguments for substitutions inside of operators existed, but I only ended up at the import commit, so I suspect the original motivation is lost to time. A regression test from LLVM has been added.
1 parent af7c8c4 commit b5ca4bc

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

libcxxabi/src/demangle/ItaniumDemangle.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4626,10 +4626,10 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
46264626
// <template-template-param> ::= <template-param>
46274627
// ::= <substitution>
46284628
//
4629-
// If this is followed by some <template-args>, and we're permitted to
4630-
// parse them, take the second production.
4629+
// If this is followed by some <template-args>, take the second
4630+
// production.
46314631

4632-
if (look() == 'I' && (!IsSubst || TryToParseTemplateArgs)) {
4632+
if (look() == 'I') {
46334633
if (!IsSubst)
46344634
Subs.push_back(Result);
46354635
Node *TA = getDerived().parseTemplateArgs();

libcxxabi/test/test_demangle.pass.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30247,6 +30247,7 @@ const char* cases[][2] = {
3024730247
{"_Z1fDSDRm", "f(_Sat unsigned long _Fract)"},
3024830248

3024930249
{"_Z11bfloat16addDF16bDF16b", "bfloat16add(std::bfloat16_t, std::bfloat16_t)"},
30250+
{"_ZNK4llvm11SmallStringILj16EEcvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEv", "llvm::SmallString<16u>::operator std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>() const"},
3025030251
// clang-format on
3025130252
};
3025230253

llvm/include/llvm/Demangle/ItaniumDemangle.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4626,10 +4626,10 @@ Node *AbstractManglingParser<Derived, Alloc>::parseType() {
46264626
// <template-template-param> ::= <template-param>
46274627
// ::= <substitution>
46284628
//
4629-
// If this is followed by some <template-args>, and we're permitted to
4630-
// parse them, take the second production.
4629+
// If this is followed by some <template-args>, take the second
4630+
// production.
46314631

4632-
if (look() == 'I' && (!IsSubst || TryToParseTemplateArgs)) {
4632+
if (look() == 'I') {
46334633
if (!IsSubst)
46344634
Subs.push_back(Result);
46354635
Node *TA = getDerived().parseTemplateArgs();

0 commit comments

Comments
 (0)