diff options
author | Chris Mihelich <cmihelic@google.com> | 2024-06-07 12:27:00 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-06-07 12:28:06 -0700 |
commit | 9140cc7b19ee1eddde576ff18d486b6e7a3f6170 (patch) | |
tree | 841065f305592ae8621a03870c737aaa46ea1c82 /absl/debugging | |
parent | c6000317f1cef3069315de81f918e1ac556e2ace (diff) |
Demangle complex floating-point literals.
PiperOrigin-RevId: 641324572
Change-Id: Ie266da9c8c702e62b89352d64870fb41d2ea76c3
Diffstat (limited to 'absl/debugging')
-rw-r--r-- | absl/debugging/internal/demangle.cc | 11 | ||||
-rw-r--r-- | absl/debugging/internal/demangle_test.cc | 19 |
2 files changed, 28 insertions, 2 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc index 6507afb5..184d89fb 100644 --- a/absl/debugging/internal/demangle.cc +++ b/absl/debugging/internal/demangle.cc @@ -2476,8 +2476,15 @@ static bool ParseExprCastValueAndTrailingE(State *state) { } state->parse_state = copy; - if (ParseFloatNumber(state) && ParseOneCharToken(state, 'E')) { - return true; + if (ParseFloatNumber(state)) { + // <float> for ordinary floating-point types + if (ParseOneCharToken(state, 'E')) return true; + + // <float> _ <float> for complex floating-point types + if (ParseOneCharToken(state, '_') && ParseFloatNumber(state) && + ParseOneCharToken(state, 'E')) { + return true; + } } state->parse_state = copy; diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc index 9100d5f1..111e895c 100644 --- a/absl/debugging/internal/demangle_test.cc +++ b/absl/debugging/internal/demangle_test.cc @@ -641,6 +641,25 @@ TEST(Demangle, StringLiterals) { EXPECT_STREQ("f<>()", tmp); } +TEST(Demangle, ComplexFloatingPointLiterals) { + char tmp[80]; + + // Source (use g++ -fext-numeric-literals to compile): + // + // using C = double _Complex; + // template <class T> void f(char (&)[sizeof(C{sizeof(T)} + 4.0j)]) {} + // template void f<int>(char (&)[sizeof(C{sizeof(int)} + 4.0j)]); + // + // GNU demangling: + // + // void f<int>(char (&) [sizeof (double _Complex{sizeof (int)}+ + // ((double _Complex)0000000000000000_4010000000000000))]) + EXPECT_TRUE(Demangle( + "_Z1fIiEvRAszpltlCdstT_ELS0_0000000000000000_4010000000000000E_c", + tmp, sizeof(tmp))); + EXPECT_STREQ("f<>()", tmp); +} + TEST(Demangle, GlobalInitializers) { char tmp[80]; |