diff options
author | Chris Mihelich <cmihelic@google.com> | 2024-06-05 10:23:44 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-06-05 10:24:42 -0700 |
commit | 699fcf35d2f0234e57fc83e3ed625952c3e919b3 (patch) | |
tree | afeabd78ec5beca168c5d2c433f7a3c264745306 /absl/debugging | |
parent | 8322d3abcc155dcb8b18e4a702ecf1f1e19dafe0 (diff) | |
download | abseil-699fcf35d2f0234e57fc83e3ed625952c3e919b3.tar.gz abseil-699fcf35d2f0234e57fc83e3ed625952c3e919b3.tar.bz2 abseil-699fcf35d2f0234e57fc83e3ed625952c3e919b3.zip |
Demangle alignof expressions, at... and az....
PiperOrigin-RevId: 640568425
Change-Id: Id63142ff2e94d7f7ee16367f34a2e4ae81c29b4e
Diffstat (limited to 'absl/debugging')
-rw-r--r-- | absl/debugging/internal/demangle.cc | 14 | ||||
-rw-r--r-- | absl/debugging/internal/demangle_test.cc | 30 |
2 files changed, 44 insertions, 0 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc index 99cc324b..79246e9b 100644 --- a/absl/debugging/internal/demangle.cc +++ b/absl/debugging/internal/demangle.cc @@ -1996,6 +1996,8 @@ static bool ParseBracedExpression(State *state) { // ::= cc <type> <expression> // ::= rc <type> <expression> // ::= st <type> +// ::= at <type> +// ::= az <expression> // ::= <template-param> // ::= <function-param> // ::= sZ <template-param> @@ -2122,6 +2124,18 @@ static bool ParseExpression(State *state) { } state->parse_state = copy; + // alignof(type) + if (ParseTwoCharToken(state, "at") && ParseType(state)) { + return true; + } + state->parse_state = copy; + + // alignof(expression), a GNU extension + if (ParseTwoCharToken(state, "az") && ParseExpression(state)) { + return true; + } + state->parse_state = copy; + // sizeof...(pack) // // <expression> ::= sZ <template-param> diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc index 2f2a48a6..a91935f4 100644 --- a/absl/debugging/internal/demangle_test.cc +++ b/absl/debugging/internal/demangle_test.cc @@ -1098,6 +1098,36 @@ TEST(Demangle, ReinterpretCast) { EXPECT_STREQ("f<>()", tmp); } +TEST(Demangle, AlignofType) { + char tmp[80]; + + // Source: + // + // template <class T> T f(T (&a)[alignof(T)]) { return a[0]; } + // template int f<int>(int (&)[alignof(int)]); + // + // Full LLVM demangling of the instantiation of f: + // + // int f<int>(int (&) [alignof (int)]) + EXPECT_TRUE(Demangle("_Z1fIiET_RAatS0__S0_", tmp, sizeof(tmp))); + EXPECT_STREQ("f<>()", tmp); +} + +TEST(Demangle, AlignofExpression) { + char tmp[80]; + + // Source (note that this uses a GNU extension; it is not standard C++): + // + // template <class T> T f(T (&a)[alignof(T{})]) { return a[0]; } + // template int f<int>(int (&)[alignof(int{})]); + // + // Full LLVM demangling of the instantiation of f: + // + // int f<int>(int (&) [alignof (int{})]) + EXPECT_TRUE(Demangle("_Z1fIiET_RAaztlS0_E_S0_", tmp, sizeof(tmp))); + EXPECT_STREQ("f<>()", tmp); +} + TEST(Demangle, ThreadLocalWrappers) { char tmp[80]; |