diff options
author | Chris Mihelich <cmihelic@google.com> | 2024-06-07 17:19:09 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-06-07 17:20:02 -0700 |
commit | f875817b18cb6536d82b925305fb321e158f59cb (patch) | |
tree | 1ad708d5de0d1b3127e2c785ed1ad15de7b04b4f /absl | |
parent | 3941dc4183616821ba5909c2b6878e158a8afde0 (diff) |
Demangle fixed-width floating-point types, DF....
PiperOrigin-RevId: 641400156
Change-Id: Ib9f6e4f6c4bbd6d3234dfd322d1d14a59b08d88a
Diffstat (limited to 'absl')
-rw-r--r-- | absl/debugging/internal/demangle.cc | 31 | ||||
-rw-r--r-- | absl/debugging/internal/demangle_test.cc | 24 |
2 files changed, 54 insertions, 1 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc index 26421c0e..7ae21dcb 100644 --- a/absl/debugging/internal/demangle.cc +++ b/absl/debugging/internal/demangle.cc @@ -1455,9 +1455,14 @@ static bool ParseExtendedQualifier(State *state) { // ::= Dd, etc. # two-character builtin types // ::= DB (<number> | <expression>) _ # _BitInt(N) // ::= DU (<number> | <expression>) _ # unsigned _BitInt(N) +// ::= DF <number> _ # _FloatN (N bits) +// ::= DF <number> x # _FloatNx +// ::= DF16b # std::bfloat16_t // // Not supported: -// ::= DF <number> _ # _FloatN (N bits) +// ::= [DS] DA <fixed-point-size> +// ::= [DS] DR <fixed-point-size> +// because real implementations of N1169 fixed-point are scant. static bool ParseBuiltinType(State *state) { ComplexityGuard guard(state); if (guard.IsTooComplex()) return false; @@ -1491,6 +1496,30 @@ static bool ParseBuiltinType(State *state) { return true; } + // DF <number> _ # _FloatN + // DF <number> x # _FloatNx + // DF16b # std::bfloat16_t + if (ParseTwoCharToken(state, "DF")) { + if (ParseThreeCharToken(state, "16b")) { + MaybeAppend(state, "std::bfloat16_t"); + return true; + } + int number = 0; + if (!ParseNumber(state, &number)) { + state->parse_state = copy; + return false; + } + MaybeAppend(state, "_Float"); + MaybeAppendDecimal(state, number); + if (ParseOneCharToken(state, 'x')) { + MaybeAppend(state, "x"); + return true; + } + if (ParseOneCharToken(state, '_')) return true; + state->parse_state = copy; + return false; + } + for (const AbbrevPair *p = kBuiltinTypeList; p->abbrev != nullptr; ++p) { // Guaranteed only 1- or 2-character strings in kBuiltinTypeList. if (p->abbrev[1] == '\0') { diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc index c702e189..2b58d39b 100644 --- a/absl/debugging/internal/demangle_test.cc +++ b/absl/debugging/internal/demangle_test.cc @@ -660,6 +660,30 @@ TEST(Demangle, ComplexFloatingPointLiterals) { EXPECT_STREQ("f<>()", tmp); } +TEST(Demangle, Float128) { + char tmp[80]; + + // S::operator _Float128() const + EXPECT_TRUE(Demangle("_ZNK1ScvDF128_Ev", tmp, sizeof(tmp))); + EXPECT_STREQ("S::operator _Float128()", tmp); +} + +TEST(Demangle, Float128x) { + char tmp[80]; + + // S::operator _Float128x() const + EXPECT_TRUE(Demangle("_ZNK1ScvDF128xEv", tmp, sizeof(tmp))); + EXPECT_STREQ("S::operator _Float128x()", tmp); +} + +TEST(Demangle, Bfloat16) { + char tmp[80]; + + // S::operator std::bfloat16_t() const + EXPECT_TRUE(Demangle("_ZNK1ScvDF16bEv", tmp, sizeof(tmp))); + EXPECT_STREQ("S::operator std::bfloat16_t()", tmp); +} + TEST(Demangle, SimpleSignedBitInt) { char tmp[80]; |