diff options
author | Chris Mihelich <cmihelic@google.com> | 2024-06-04 16:06:31 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-06-04 16:07:33 -0700 |
commit | 8777d4408904ae184593014e71ff8fc0bb3bdecd (patch) | |
tree | b4fc60bfdea6a1b1192d6a3696e3d85307633cfd | |
parent | d8e17c009185a3bb305d774aa9e41f3c5de605f6 (diff) |
Demangle sizeof...(pack captured from an alias template), sP ... E.
PiperOrigin-RevId: 640314320
Change-Id: I1020879b354c75558d3dba064bb3ea13bd667227
-rw-r--r-- | absl/debugging/internal/demangle.cc | 10 | ||||
-rw-r--r-- | absl/debugging/internal/demangle_test.cc | 16 |
2 files changed, 26 insertions, 0 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc index e9edd4f8..7ce14713 100644 --- a/absl/debugging/internal/demangle.cc +++ b/absl/debugging/internal/demangle.cc @@ -1978,6 +1978,7 @@ static bool ParseBracedExpression(State *state) { // ::= <function-param> // ::= sZ <template-param> // ::= sZ <function-param> +// ::= sP <template-arg>* E // ::= <expr-primary> // ::= dt <expression> <unresolved-name> # expr.name // ::= pt <expression> <unresolved-name> # expr->name @@ -2109,6 +2110,15 @@ static bool ParseExpression(State *state) { } state->parse_state = copy; + // sizeof...(pack) captured from an alias template + // + // <expression> ::= sP <template-arg>* E + if (ParseTwoCharToken(state, "sP") && ZeroOrMore(ParseTemplateArg, state) && + ParseOneCharToken(state, 'E')) { + return true; + } + state->parse_state = copy; + // Unary folds (... op pack) and (pack op ...). // // <expression> ::= fl <binary operator-name> <expression> diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc index cb8b36d0..052c66bb 100644 --- a/absl/debugging/internal/demangle_test.cc +++ b/absl/debugging/internal/demangle_test.cc @@ -812,6 +812,22 @@ TEST(Demangle, SizeofPacks) { EXPECT_STREQ("g<>()", tmp); } +TEST(Demangle, SizeofPackInvolvingAnAliasTemplate) { + char tmp[80]; + + // Source: + // + // template <class... T> using A = char[sizeof...(T)]; + // template <class... U> void f(const A<U..., int>&) {} + // template void f<int>(const A<int, int>&); + // + // Full LLVM demangling of the instantiation of f: + // + // void f<int>(char const (&) [sizeof... (int, int)]) + EXPECT_TRUE(Demangle("_Z1fIJiEEvRAsPDpT_iE_Kc", tmp, sizeof(tmp))); + EXPECT_STREQ("f<>()", tmp); +} + TEST(Demangle, Spaceship) { char tmp[80]; |