From 5195c35dc4361618d89733e63fd53a717d54c7a2 Mon Sep 17 00:00:00 2001 From: Chris Mihelich Date: Mon, 10 Jun 2024 07:25:53 -0700 Subject: Demangle template parameter object names, TA . PiperOrigin-RevId: 641893938 Change-Id: I8a21e322c9cf1d5dab7477af5367aad134fbf2ab --- absl/debugging/internal/demangle.cc | 15 +++++++++++++++ absl/debugging/internal/demangle_test.cc | 23 +++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc index f9dff5d8..26163416 100644 --- a/absl/debugging/internal/demangle.cc +++ b/absl/debugging/internal/demangle.cc @@ -1176,6 +1176,7 @@ static bool ParseConversionOperatorType(State *state) { // ::= GR <(object) name> [] _ // ::= T <(base) encoding> // ::= GTt # transaction-safe entry point +// ::= TA # nontype template parameter object // G++ extensions: // ::= TC <(offset) number> _ <(base) type> // ::= TF @@ -1190,6 +1191,8 @@ static bool ParseConversionOperatorType(State *state) { // thread_local feature. For these see: // // https://maskray.me/blog/2021-02-14-all-about-thread-local-storage +// +// For TA see https://github.com/itanium-cxx-abi/cxx-abi/issues/63. static bool ParseSpecialName(State *state) { ComplexityGuard guard(state); if (guard.IsTooComplex()) return false; @@ -1280,6 +1283,18 @@ static bool ParseSpecialName(State *state) { return true; } state->parse_state = copy; + + if (ParseTwoCharToken(state, "TA")) { + bool append = state->parse_state.append; + DisableAppend(state); + if (ParseTemplateArg(state)) { + RestoreAppend(state, append); + MaybeAppend(state, "template parameter object"); + return true; + } + } + state->parse_state = copy; + return false; } diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc index 68a759c1..55686814 100644 --- a/absl/debugging/internal/demangle_test.cc +++ b/absl/debugging/internal/demangle_test.cc @@ -943,6 +943,29 @@ TEST(Demangle, TransactionSafeFunctionType) { EXPECT_STREQ("f()", tmp); } +TEST(Demangle, TemplateParameterObject) { + char tmp[80]; + + // Source: + // + // struct S { int x, y; }; + // template void f() {} + // template void f(); + // + // LLVM demangling: + // + // void f() + EXPECT_TRUE(Demangle("_Z1fIXtl1SLi1ELi2EEEXadL_ZTAXtlS0_Li1ELi2EEEEEEvv", + tmp, sizeof(tmp))); + EXPECT_STREQ("f<>()", tmp); + + // The name of the object standing alone. + // + // LLVM demangling: template parameter object for S{1, 2} + EXPECT_TRUE(Demangle("_ZTAXtl1SLi1ELi2EEE", tmp, sizeof(tmp))); + EXPECT_STREQ("template parameter object", tmp); +} + TEST(Demangle, EnableIfAttributeOnGlobalFunction) { char tmp[80]; -- cgit v1.2.3