[libcxx-commits] [libcxxabi] [llvm] [ItaniumDemangle] Fix conversion operators failing to demangle types … (PR #197420)
Iris Shi via libcxx-commits
libcxx-commits at lists.llvm.org
Tue May 26 22:51:20 PDT 2026
https://github.com/el-ev updated https://github.com/llvm/llvm-project/pull/197420
>From 67844b41e8e19124b1dcbcda01a85ce4a58765a9 Mon Sep 17 00:00:00 2001
From: Iris Shi <0.0 at owo.li>
Date: Wed, 13 May 2026 19:20:02 +0800
Subject: [PATCH] [ItaniumDemangle] Fix conversion operators failing to
demangle types with substitutions
---
libcxxabi/src/demangle/ItaniumDemangle.h | 4 ++++
llvm/include/llvm/Demangle/ItaniumDemangle.h | 4 ++++
llvm/unittests/Demangle/DemangleTest.cpp | 9 +++++++++
3 files changed, 17 insertions(+)
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index c001a8d33f227..4137c9bbcb3b0 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -6108,6 +6108,10 @@ AbstractManglingParser<Derived, Alloc>::parseTemplateArgs(bool TagTemplates) {
if (!consumeIf('I'))
return nullptr;
+ // Subtypes within template args are complete, so they can always parse their
+ // own template args.
+ ScopedOverride<bool> SaveTryToParseTemplateArgs(TryToParseTemplateArgs, true);
+
// <template-params> refer to the innermost <template-args>. Clear out any
// outer args that we may have inserted into TemplateParams.
if (TagTemplates) {
diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index 6d7f189a6e44c..b7f844df33c50 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -6108,6 +6108,10 @@ AbstractManglingParser<Derived, Alloc>::parseTemplateArgs(bool TagTemplates) {
if (!consumeIf('I'))
return nullptr;
+ // Subtypes within template args are complete, so they can always parse their
+ // own template args.
+ ScopedOverride<bool> SaveTryToParseTemplateArgs(TryToParseTemplateArgs, true);
+
// <template-params> refer to the innermost <template-args>. Clear out any
// outer args that we may have inserted into TemplateParams.
if (TagTemplates) {
diff --git a/llvm/unittests/Demangle/DemangleTest.cpp b/llvm/unittests/Demangle/DemangleTest.cpp
index e60a75ecd76da..d3b3099bbbb1c 100644
--- a/llvm/unittests/Demangle/DemangleTest.cpp
+++ b/llvm/unittests/Demangle/DemangleTest.cpp
@@ -29,4 +29,13 @@ TEST(Demangle, demangleTest) {
// extended type qualifier (https://bugs.llvm.org/show_bug.cgi?id=48009)
EXPECT_EQ(demangle("_Z3fooILi79EEbU7_ExtIntIXT_EEi"),
"bool foo<79>(int _ExtInt<79>)");
+
+ // Conversion operators with substitutions that have template args
+ // (https://github.com/llvm/llvm-project/issues/109130)
+ EXPECT_EQ(demangle("_ZN3foocvNSt7__cxx1112basic_stringIcSt11char_"
+ "traitsIcESaIcEEEEv"),
+ "foo::operator std::__cxx11::basic_string<char, "
+ "std::char_traits<char>, std::allocator<char>>()");
+ EXPECT_EQ(demangle("_ZN1XcvSt6vectorIiSaIiEEEv"),
+ "X::operator std::vector<int, std::allocator<int>>()");
}
More information about the libcxx-commits
mailing list