Commit 699fcf35 by Chris Mihelich Committed by Copybara-Service

Demangle alignof expressions, at... and az....

PiperOrigin-RevId: 640568425
Change-Id: Id63142ff2e94d7f7ee16367f34a2e4ae81c29b4e
parent 8322d3ab
......@@ -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>
......
......@@ -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];
......
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