[libcxx-commits] [libcxxabi] c22b68c - [ItaniumDemangle] Set `InConstraintExpr` to `true` when demangling a constraint expression (#107385)
via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Sep 12 00:01:57 PDT 2024
Author: Viktoriia Bakalova
Date: 2024-09-12T09:01:53+02:00
New Revision: c22b68c225a8dcdffa7b30c3acf315e308b16f7c
URL: https://github.com/llvm/llvm-project/commit/c22b68c225a8dcdffa7b30c3acf315e308b16f7c
DIFF: https://github.com/llvm/llvm-project/commit/c22b68c225a8dcdffa7b30c3acf315e308b16f7c.diff
LOG: [ItaniumDemangle] Set `InConstraintExpr` to `true` when demangling a constraint expression (#107385)
This prevents demangler failures until the TODO in the
[demangler](https://github.com/llvm/llvm-project/blob/3e070906eff720dc44aee86e533e12aafc8bb14b/llvm/include/llvm/Demangle/ItaniumDemangle.h#L5678)
is implemented.
This is a temporary fix for
[#89914](https://github.com/llvm/llvm-project/issues/89914).
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 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