Commit 586a541d by Chris Mihelich Committed by Copybara-Service

Demangle elaborated type names, (Ts | Tu | Te) <name>.

PiperOrigin-RevId: 640972027
Change-Id: I810aaa10e7761686d03854abab3198be8b2868cf
parent 66ef711d
...@@ -1544,10 +1544,23 @@ static bool ParseOverloadAttribute(State *state) { ...@@ -1544,10 +1544,23 @@ static bool ParseOverloadAttribute(State *state) {
} }
// <class-enum-type> ::= <name> // <class-enum-type> ::= <name>
// ::= Ts <name> # struct Name or class Name
// ::= Tu <name> # union Name
// ::= Te <name> # enum Name
//
// See http://shortn/_W3YrltiEd0.
static bool ParseClassEnumType(State *state) { static bool ParseClassEnumType(State *state) {
ComplexityGuard guard(state); ComplexityGuard guard(state);
if (guard.IsTooComplex()) return false; if (guard.IsTooComplex()) return false;
return ParseName(state); ParseState copy = state->parse_state;
if (Optional(ParseTwoCharToken(state, "Ts") ||
ParseTwoCharToken(state, "Tu") ||
ParseTwoCharToken(state, "Te")) &&
ParseName(state)) {
return true;
}
state->parse_state = copy;
return false;
} }
// <array-type> ::= A <(positive dimension) number> _ <(element) type> // <array-type> ::= A <(positive dimension) number> _ <(element) type>
......
...@@ -739,6 +739,30 @@ TEST(Demangle, TypeNestedUnderDecltype) { ...@@ -739,6 +739,30 @@ TEST(Demangle, TypeNestedUnderDecltype) {
EXPECT_STREQ("f<>()", tmp); EXPECT_STREQ("f<>()", tmp);
} }
TEST(Demangle, ElaboratedTypes) {
char tmp[80];
// Source:
//
// template <class T> struct S { class C {}; };
// template <class T> void f(class S<T>::C) {}
// template void f<int>(class S<int>::C);
//
// LLVM demangling:
//
// void f<int>(struct S<int>::C)
EXPECT_TRUE(Demangle("_Z1fIiEvTsN1SIT_E1CE", tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
// The like for unions.
EXPECT_TRUE(Demangle("_Z1fIiEvTuN1SIT_E1CE", tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
// The like for enums.
EXPECT_TRUE(Demangle("_Z1fIiEvTeN1SIT_E1CE", tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
}
// Test subobject-address template parameters. // Test subobject-address template parameters.
TEST(Demangle, SubobjectAddresses) { TEST(Demangle, SubobjectAddresses) {
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