Commit e7a5d7ac by Chris Mihelich Committed by Copybara-Service

Demangle array new-expressions, [gs] na ....

PiperOrigin-RevId: 640891321
Change-Id: I2bc0f6b907d8af88446375409fb523158ae0e001
parent 54e1f14c
...@@ -1996,6 +1996,8 @@ static bool ParseBracedExpression(State *state) { ...@@ -1996,6 +1996,8 @@ static bool ParseBracedExpression(State *state) {
// ::= il <braced-expression>* E // ::= il <braced-expression>* E
// ::= [gs] nw <expression>* _ <type> E // ::= [gs] nw <expression>* _ <type> E
// ::= [gs] nw <expression>* _ <type> <initializer> // ::= [gs] nw <expression>* _ <type> <initializer>
// ::= [gs] na <expression>* _ <type> E
// ::= [gs] na <expression>* _ <type> <initializer>
// ::= dc <type> <expression> // ::= dc <type> <expression>
// ::= sc <type> <expression> // ::= sc <type> <expression>
// ::= cc <type> <expression> // ::= cc <type> <expression>
...@@ -2093,8 +2095,10 @@ static bool ParseExpression(State *state) { ...@@ -2093,8 +2095,10 @@ static bool ParseExpression(State *state) {
// <expression> ::= [gs] nw <expression>* _ <type> E // <expression> ::= [gs] nw <expression>* _ <type> E
// ::= [gs] nw <expression>* _ <type> <initializer> // ::= [gs] nw <expression>* _ <type> <initializer>
// ::= [gs] na <expression>* _ <type> E
// ::= [gs] na <expression>* _ <type> <initializer>
if (Optional(ParseTwoCharToken(state, "gs")) && if (Optional(ParseTwoCharToken(state, "gs")) &&
ParseTwoCharToken(state, "nw") && (ParseTwoCharToken(state, "nw") || ParseTwoCharToken(state, "na")) &&
ZeroOrMore(ParseExpression, state) && ParseOneCharToken(state, '_') && ZeroOrMore(ParseExpression, state) && ParseOneCharToken(state, '_') &&
ParseType(state) && ParseType(state) &&
(ParseOneCharToken(state, 'E') || ParseInitializer(state))) { (ParseOneCharToken(state, 'E') || ParseInitializer(state))) {
......
...@@ -1148,6 +1148,70 @@ TEST(Demangle, GlobalScopeNewExpression) { ...@@ -1148,6 +1148,70 @@ TEST(Demangle, GlobalScopeNewExpression) {
EXPECT_STREQ("f<>()", tmp); EXPECT_STREQ("f<>()", tmp);
} }
TEST(Demangle, SimpleArrayNewExpression) {
char tmp[80];
// Source:
//
// template <class T> decltype(T{*new T[1]}) f() { return T{}; }
// template decltype(int{*new int[1]}) f<int>();
//
// Full LLVM demangling of the instantiation of f:
//
// decltype(int{*(new[] int)}) f<int>()
EXPECT_TRUE(Demangle("_Z1fIiEDTtlT_dena_S0_EEEv", tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
}
TEST(Demangle, ArrayNewExpressionWithEmptyParentheses) {
char tmp[80];
// Source:
//
// template <class T> decltype(T{*new T[1]()}) f() { return T{}; }
// template decltype(int{*new int[1]()}) f<int>();
//
// Full LLVM demangling of the instantiation of f:
//
// decltype(int{*(new[] int)}) f<int>()
EXPECT_TRUE(Demangle("_Z1fIiEDTtlT_dena_S0_piEEEv", tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
}
TEST(Demangle, ArrayPlacementNewExpression) {
char tmp[80];
// Source:
//
// #include <new>
//
// template <class T> auto f(T t) -> decltype(T{*new (&t) T[1]}) {
// return T{};
// }
// template auto f<int>(int t) -> decltype(int{*new (&t) int[1]});
//
// Full LLVM demangling of the instantiation of f:
//
// decltype(int{*(new[](&fp) int)}) f<int>(int)
EXPECT_TRUE(Demangle("_Z1fIiEDTtlT_denaadfp__S0_EEES0_", tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
}
TEST(Demangle, GlobalScopeArrayNewExpression) {
char tmp[80];
// Source:
//
// template <class T> decltype(T{*::new T[1]}) f() { return T{}; }
// template decltype(int{*::new int[1]}) f<int>();
//
// Full LLVM demangling of the instantiation of f:
//
// decltype(int{*(::new[] int)}) f<int>()
EXPECT_TRUE(Demangle("_Z1fIiEDTtlT_degsna_S0_EEEv", 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