From 59d0a7d141084dbec666b6f05ffa8c4210d61956 Mon Sep 17 00:00:00 2001 From: Chris Mihelich Date: Fri, 7 Jun 2024 07:51:38 -0700 Subject: Demangle transaction-safety notations GTt and Dx. PiperOrigin-RevId: 641249074 Change-Id: Id410ce6c3b7a9a2b10aedf9c70ec65d3e37af06d --- absl/debugging/internal/demangle.cc | 10 +++++++++- absl/debugging/internal/demangle_test.cc | 15 +++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc index 8b76ce01..9f4a8352 100644 --- a/absl/debugging/internal/demangle.cc +++ b/absl/debugging/internal/demangle.cc @@ -1112,6 +1112,7 @@ static bool ParseOperatorName(State *state, int *arity) { // ::= GV <(object) name> // ::= GR <(object) name> [] _ // ::= T <(base) encoding> +// ::= GTt # transaction-safe entry point // G++ extensions: // ::= TC <(offset) number> _ <(base) type> // ::= TF @@ -1205,6 +1206,12 @@ static bool ParseSpecialName(State *state) { } state->parse_state = copy; + if (ParseThreeCharToken(state, "GTt") && + MaybeAppend(state, "transaction clone for ") && ParseEncoding(state)) { + return true; + } + state->parse_state = copy; + if (ParseOneCharToken(state, 'T') && ParseCharClass(state, "hv") && ParseCallOffset(state) && ParseEncoding(state)) { return true; @@ -1509,7 +1516,7 @@ static bool ParseExceptionSpec(State *state) { } // ::= -// [exception-spec] F [Y] [] E +// [exception-spec] [Dx] F [Y] [] E // // ::= R | O static bool ParseFunctionType(State *state) { @@ -1517,6 +1524,7 @@ static bool ParseFunctionType(State *state) { if (guard.IsTooComplex()) return false; ParseState copy = state->parse_state; Optional(ParseExceptionSpec(state)); + Optional(ParseTwoCharToken(state, "Dx")); if (!ParseOneCharToken(state, 'F')) { state->parse_state = copy; return false; diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc index 108642a8..974b15f0 100644 --- a/absl/debugging/internal/demangle_test.cc +++ b/absl/debugging/internal/demangle_test.cc @@ -759,6 +759,21 @@ TEST(Demangle, GnuVectorSizeIsADependentOperatorExpression) { EXPECT_STREQ("f<>()", tmp); } +TEST(Demangle, TransactionSafeEntryPoint) { + char tmp[80]; + + EXPECT_TRUE(Demangle("_ZGTt1fv", tmp, sizeof(tmp))); + EXPECT_STREQ("transaction clone for f()", tmp); +} + +TEST(Demangle, TransactionSafeFunctionType) { + char tmp[80]; + + // GNU demangling: f(void (*)() transaction_safe) + EXPECT_TRUE(Demangle("_Z1fPDxFvvE", tmp, sizeof(tmp))); + EXPECT_STREQ("f()", tmp); +} + TEST(Demangle, EnableIfAttributeOnGlobalFunction) { char tmp[80]; -- cgit v1.2.3