Commit 36d1644b by Chris Mihelich Committed by Copybara-Service

Demangle il ... E syntax (braced list other than direct-list-initialization).

PiperOrigin-RevId: 640242497
Change-Id: I5574281110ddb27a6ee8d902dae90be6be6c0886
parent b0e72168
...@@ -1951,6 +1951,7 @@ static bool ParseBracedExpression(State *state) { ...@@ -1951,6 +1951,7 @@ static bool ParseBracedExpression(State *state) {
// ::= cv <type> <expression> # type (expression) // ::= cv <type> <expression> # type (expression)
// ::= cv <type> _ <expression>* E # type (expr-list) // ::= cv <type> _ <expression>* E # type (expr-list)
// ::= tl <type> <braced-expression>* E // ::= tl <type> <braced-expression>* E
// ::= il <braced-expression>* E
// ::= dc <type> <expression> // ::= dc <type> <expression>
// ::= sc <type> <expression> // ::= sc <type> <expression>
// ::= cc <type> <expression> // ::= cc <type> <expression>
...@@ -2021,6 +2022,14 @@ static bool ParseExpression(State *state) { ...@@ -2021,6 +2022,14 @@ static bool ParseExpression(State *state) {
} }
state->parse_state = copy; state->parse_state = copy;
// <expression> ::= il <braced-expression>* E
if (ParseTwoCharToken(state, "il") &&
ZeroOrMore(ParseBracedExpression, state) &&
ParseOneCharToken(state, 'E')) {
return true;
}
state->parse_state = copy;
// dynamic_cast, static_cast, const_cast, reinterpret_cast. // dynamic_cast, static_cast, const_cast, reinterpret_cast.
// //
// <expression> ::= (dc | sc | cc | rc) <type> <expression> // <expression> ::= (dc | sc | cc | rc) <type> <expression>
......
...@@ -876,6 +876,66 @@ TEST(Demangle, DirectListInitialization) { ...@@ -876,6 +876,66 @@ TEST(Demangle, DirectListInitialization) {
EXPECT_STREQ("j<>()", tmp); EXPECT_STREQ("j<>()", tmp);
} }
TEST(Demangle, SimpleInitializerLists) {
char tmp[80];
// Common preamble of source-code examples in this test function:
//
// #include <initializer_list>
//
// template <class T> void g(std::initializer_list<T>) {}
// Source:
//
// template <class T> auto f() -> decltype(g<T>({})) {}
// template auto f<int>() -> decltype(g<int>({}));
//
// Full LLVM demangling of the instantiation of f:
//
// decltype(g<int>({})) f<int>()
EXPECT_TRUE(Demangle("_Z1fIiEDTcl1gIT_EilEEEv", tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
// Source:
//
// template <class T> auto f(T x) -> decltype(g({x})) {}
// template auto f<int>(int x) -> decltype(g({x}));
//
// Full LLVM demangling of the instantiation of f:
//
// decltype(g({fp})) f<int>(int)
EXPECT_TRUE(Demangle("_Z1fIiEDTcl1gilfp_EEET_", tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
// Source:
//
// template <class T> auto f(T x, T y) -> decltype(g({x, y})) {}
// template auto f<int>(int x, int y) -> decltype(g({x, y}));
//
// Full LLVM demangling of the instantiation of f:
//
// decltype(g({fp, fp0})) f<int>(int, int)
EXPECT_TRUE(Demangle("_Z1fIiEDTcl1gilfp_fp0_EEET_S1_", tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
}
TEST(Demangle, BracedListImplicitlyConstructingAClassObject) {
char tmp[80];
// Source:
//
// struct S { int v; };
// void g(S) {}
// template <class T> auto f(T x) -> decltype(g({.v = x})) {}
// template auto f<int>(int x) -> decltype(g({.v = x}));
//
// Full LLVM demangling of the instantiation of f:
//
// decltype(g({.v = fp})) f<int>(int)
EXPECT_TRUE(Demangle("_Z1fIiEDTcl1gildi1vfp_EEET_", tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
}
TEST(Demangle, ReferenceQualifiedFunctionTypes) { TEST(Demangle, ReferenceQualifiedFunctionTypes) {
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