Commit 8777d440 by Chris Mihelich Committed by Copybara-Service

Demangle sizeof...(pack captured from an alias template), sP ... E.

PiperOrigin-RevId: 640314320
Change-Id: I1020879b354c75558d3dba064bb3ea13bd667227
parent d8e17c00
...@@ -1978,6 +1978,7 @@ static bool ParseBracedExpression(State *state) { ...@@ -1978,6 +1978,7 @@ static bool ParseBracedExpression(State *state) {
// ::= <function-param> // ::= <function-param>
// ::= sZ <template-param> // ::= sZ <template-param>
// ::= sZ <function-param> // ::= sZ <function-param>
// ::= sP <template-arg>* E
// ::= <expr-primary> // ::= <expr-primary>
// ::= dt <expression> <unresolved-name> # expr.name // ::= dt <expression> <unresolved-name> # expr.name
// ::= pt <expression> <unresolved-name> # expr->name // ::= pt <expression> <unresolved-name> # expr->name
...@@ -2109,6 +2110,15 @@ static bool ParseExpression(State *state) { ...@@ -2109,6 +2110,15 @@ static bool ParseExpression(State *state) {
} }
state->parse_state = copy; 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 ...). // Unary folds (... op pack) and (pack op ...).
// //
// <expression> ::= fl <binary operator-name> <expression> // <expression> ::= fl <binary operator-name> <expression>
......
...@@ -812,6 +812,22 @@ TEST(Demangle, SizeofPacks) { ...@@ -812,6 +812,22 @@ TEST(Demangle, SizeofPacks) {
EXPECT_STREQ("g<>()", tmp); 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) { TEST(Demangle, Spaceship) {
char tmp[80]; char tmp[80];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment