Commit 49e0099a by Chris Mihelich Committed by Copybara-Service

Demangle ti... and te... expressions (typeid).

PiperOrigin-RevId: 640616282
Change-Id: I2aa94673283d89458886f0634adec87bbf0e57de
parent 8ece6dc4
......@@ -1995,6 +1995,8 @@ static bool ParseBracedExpression(State *state) {
// ::= sc <type> <expression>
// ::= cc <type> <expression>
// ::= rc <type> <expression>
// ::= ti <type>
// ::= te <expression>
// ::= st <type>
// ::= at <type>
// ::= az <expression>
......@@ -2119,6 +2121,18 @@ static bool ParseExpression(State *state) {
}
state->parse_state = copy;
// typeid(type)
if (ParseTwoCharToken(state, "ti") && ParseType(state)) {
return true;
}
state->parse_state = copy;
// typeid(expression)
if (ParseTwoCharToken(state, "te") && ParseExpression(state)) {
return true;
}
state->parse_state = copy;
// sizeof type
if (ParseTwoCharToken(state, "st") && ParseType(state)) {
return true;
......
......@@ -1098,6 +1098,40 @@ TEST(Demangle, ReinterpretCast) {
EXPECT_STREQ("f<>()", tmp);
}
TEST(Demangle, TypeidType) {
char tmp[80];
// Source:
//
// #include <typeinfo>
//
// template <class T> decltype(typeid(T).name()) f(T) { return nullptr; }
// template decltype(typeid(int).name()) f<int>(int);
//
// Full LLVM demangling of the instantiation of f:
//
// decltype(typeid (int).name()) f<int>(int)
EXPECT_TRUE(Demangle("_Z1fIiEDTcldttiT_4nameEES0_", tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
}
TEST(Demangle, TypeidExpression) {
char tmp[80];
// Source:
//
// #include <typeinfo>
//
// template <class T> decltype(typeid(T{}).name()) f(T) { return nullptr; }
// template decltype(typeid(int{}).name()) f<int>(int);
//
// Full LLVM demangling of the instantiation of f:
//
// decltype(typeid (int{}).name()) f<int>(int)
EXPECT_TRUE(Demangle("_Z1fIiEDTcldttetlT_E4nameEES0_", tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
}
TEST(Demangle, AlignofType) {
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