[libcxx-commits] [libcxxabi] [llvm] [ItaniumDemangle] Set `InConstraintExpr` to `true` when demangling a constraint expression (PR #107385)
Viktoriia Bakalova via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Sep 11 09:14:48 PDT 2024
https://github.com/VitaNuo updated https://github.com/llvm/llvm-project/pull/107385
>From 522ed387403834402d32c7d9324f61d4586024cb Mon Sep 17 00:00:00 2001
From: Viktoriia Bakalova <bakalova at google.com>
Date: Wed, 11 Sep 2024 16:11:31 +0000
Subject: [PATCH] [ItaniumDemangle] Set InConstraintExpr to true when
demangling a constraint expression
---
libcxxabi/src/demangle/ItaniumDemangle.h | 13 ++++++++++---
libcxxabi/test/test_demangle.pass.cpp | 1 +
llvm/include/llvm/Demangle/ItaniumDemangle.h | 13 ++++++++++---
3 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h
index 88de234a6e0b92..3b041efe3aac00 100644
--- a/libcxxabi/src/demangle/ItaniumDemangle.h
+++ b/libcxxabi/src/demangle/ItaniumDemangle.h
@@ -2677,7 +2677,7 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
bool TryToParseTemplateArgs = true;
bool PermitForwardTemplateReferences = false;
- bool InConstraintExpr = false;
+ bool HasIncompleteTemplateParameterTracking = false;
size_t ParsingLambdaParamsAtLevel = (size_t)-1;
unsigned NumSyntheticTemplateParameters[3] = {};
@@ -4818,7 +4818,8 @@ template <typename Derived, typename Alloc>
Node *AbstractManglingParser<Derived, Alloc>::parseConstraintExpr() {
// Within this expression, all enclosing template parameter lists are in
// scope.
- ScopedOverride<bool> SaveInConstraintExpr(InConstraintExpr, true);
+ ScopedOverride<bool> SaveIncompleteTemplateParameterTracking(
+ HasIncompleteTemplateParameterTracking, true);
return getDerived().parseExpr();
}
@@ -5676,7 +5677,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseTemplateParam() {
// substitute them all within a <constraint-expression>, so print the
// parameter numbering instead for now.
// TODO: Track all enclosing template parameters and substitute them here.
- if (InConstraintExpr) {
+ if (HasIncompleteTemplateParameterTracking) {
return make<NameType>(std::string_view(Begin, First - 1 - Begin));
}
@@ -5737,6 +5738,12 @@ Node *AbstractManglingParser<Derived, Alloc>::parseTemplateParamDecl(
}
if (consumeIf("Tk")) {
+ // We don't track enclosing template parameter levels well enough to
+ // reliably demangle template parameter substitutions, so print an arbitrary
+ // string in place of a parameter for now.
+ // TODO: Track all enclosing template parameters and demangle substitutions.
+ ScopedOverride<bool> SaveIncompleteTemplateParameterTrackingExpr(
+ HasIncompleteTemplateParameterTracking, true);
Node *Constraint = getDerived().parseName();
if (!Constraint)
return nullptr;
diff --git a/libcxxabi/test/test_demangle.pass.cpp b/libcxxabi/test/test_demangle.pass.cpp
index ab783cf9d96f22..77f79e0d40e84f 100644
--- a/libcxxabi/test/test_demangle.pass.cpp
+++ b/libcxxabi/test/test_demangle.pass.cpp
@@ -30137,6 +30137,7 @@ const char* cases[][2] =
{"_ZZN5test71fIiEEvvENKUlTyQaa1CIT_E1CITL0__ET0_E0_clIiiEEDaS3_Qaa1CIDtfp_EELb1E", "auto void test7::f<int>()::'lambda0'<typename $T> requires C<T> && C<TL0_> (auto)::operator()<int, int>(auto) const requires C<decltype(fp)> && true"},
{"_ZZN5test71fIiEEvvENKUlTyQaa1CIT_E1CITL0__ET0_E1_clIiiEEDaS3_Q1CIDtfp_EE", "auto void test7::f<int>()::'lambda1'<typename $T> requires C<T> && C<TL0_> (auto)::operator()<int, int>(auto) const requires C<decltype(fp)>"},
{"_ZZN5test71fIiEEvvENKUlTyT0_E_clIiiEEDaS1_", "auto void test7::f<int>()::'lambda'<typename $T>(auto)::operator()<int, int>(auto) const"},
+ {"_ZN3FooIiE6methodITk4TrueIT_EiEEvS3_", "void Foo<int>::method<int>(T)"},
// C++20 requires expressions, see https://github.com/itanium-cxx-abi/cxx-abi/issues/24.
{"_Z1fIiEviQrqXcvT__EXfp_Xeqfp_cvS0__EXplcvS0__ELi1ER5SmallXmicvS0__ELi1ENXmlcvS0__ELi2ENR11SmallerThanILi1234EETS0_T1XIS0_ETNS3_4typeETS2_IiEQ11SmallerThanIS0_Li256EEE", "void f<int>(int) requires requires { (T)(); fp; fp == (T)(); {(T)() + 1} -> Small; {(T)() - 1} noexcept; {(T)() * 2} noexcept -> SmallerThan<1234>; typename T; typename X<T>; typename X<T>::type; typename X<int>; requires SmallerThan<T, 256>; }"},
diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h
index fb2060fa07f724..0af0224bc83fa8 100644
--- a/llvm/include/llvm/Demangle/ItaniumDemangle.h
+++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h
@@ -2677,7 +2677,7 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
bool TryToParseTemplateArgs = true;
bool PermitForwardTemplateReferences = false;
- bool InConstraintExpr = false;
+ bool HasIncompleteTemplateParameterTracking = false;
size_t ParsingLambdaParamsAtLevel = (size_t)-1;
unsigned NumSyntheticTemplateParameters[3] = {};
@@ -4818,7 +4818,8 @@ template <typename Derived, typename Alloc>
Node *AbstractManglingParser<Derived, Alloc>::parseConstraintExpr() {
// Within this expression, all enclosing template parameter lists are in
// scope.
- ScopedOverride<bool> SaveInConstraintExpr(InConstraintExpr, true);
+ ScopedOverride<bool> SaveIncompleteTemplateParameterTracking(
+ HasIncompleteTemplateParameterTracking, true);
return getDerived().parseExpr();
}
@@ -5676,7 +5677,7 @@ Node *AbstractManglingParser<Derived, Alloc>::parseTemplateParam() {
// substitute them all within a <constraint-expression>, so print the
// parameter numbering instead for now.
// TODO: Track all enclosing template parameters and substitute them here.
- if (InConstraintExpr) {
+ if (HasIncompleteTemplateParameterTracking) {
return make<NameType>(std::string_view(Begin, First - 1 - Begin));
}
@@ -5737,6 +5738,12 @@ Node *AbstractManglingParser<Derived, Alloc>::parseTemplateParamDecl(
}
if (consumeIf("Tk")) {
+ // We don't track enclosing template parameter levels well enough to
+ // reliably demangle template parameter substitutions, so print an arbitrary
+ // string in place of a parameter for now.
+ // TODO: Track all enclosing template parameters and demangle substitutions.
+ ScopedOverride<bool> SaveIncompleteTemplateParameterTrackingExpr(
+ HasIncompleteTemplateParameterTracking, true);
Node *Constraint = getDerived().parseName();
if (!Constraint)
return nullptr;
More information about the libcxx-commits
mailing list