From 77d0ac71e41bb35c6415d38f20b5cd8faadec35a Mon Sep 17 00:00:00 2001 From: Chris Mihelich Date: Wed, 29 May 2024 06:42:14 -0700 Subject: Demangle C++ requires-expressions with parameters (rQ ... E). PiperOrigin-RevId: 638266358 Change-Id: I8a750a53d5e98bc3ad3b6d36661789d97d6efb0a --- absl/debugging/internal/demangle.cc | 11 +++++++++++ absl/debugging/internal/demangle_test.cc | 8 ++++++++ 2 files changed, 19 insertions(+) (limited to 'absl/debugging') diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc index 606ff4e7..2e692d38 100644 --- a/absl/debugging/internal/demangle.cc +++ b/absl/debugging/internal/demangle.cc @@ -1922,6 +1922,7 @@ static bool ParseBracedExpression(State *state) { // ::= sr // ::= u * E # vendor extension // ::= rq + E +// ::= rQ _ + E static bool ParseExpression(State *state) { ComplexityGuard guard(state); if (guard.IsTooComplex()) return false; @@ -2093,6 +2094,16 @@ static bool ParseExpression(State *state) { } state->parse_state = copy; + // ::= rQ _ + E + // + // https://github.com/itanium-cxx-abi/cxx-abi/issues/24 + if (ParseTwoCharToken(state, "rQ") && ParseBareFunctionType(state) && + ParseOneCharToken(state, '_') && OneOrMore(ParseRequirement, state) && + ParseOneCharToken(state, 'E')) { + return true; + } + state->parse_state = copy; + return ParseUnresolvedName(state); } diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc index 998d34bb..5ecb33c2 100644 --- a/absl/debugging/internal/demangle_test.cc +++ b/absl/debugging/internal/demangle_test.cc @@ -303,6 +303,14 @@ TEST(Demangle, LambdaRequiresRequiresExpressionContainingTwoRequirements) { EXPECT_STREQ(tmp, "$_0::operator()<>()"); } +TEST(Demangle, RequiresExpressionWithItsOwnParameter) { + char tmp[100]; + + // S f(int) + ASSERT_TRUE(Demangle("_Z1fIiE1SIXrQT__XplfL0p_fp_EEES1_", tmp, sizeof(tmp))); + EXPECT_STREQ(tmp, "f<>()"); +} + TEST(Demangle, LambdaWithExplicitTypeArgument) { char tmp[100]; -- cgit v1.2.3