Commit ed34153e by Chris Mihelich Committed by Copybara-Service

Demangle delete-expressions with the global-scope operator, gs (dl | da) ....

PiperOrigin-RevId: 640928445
Change-Id: I547f194ebb0a4482ecec627a7a03bab60e8e1c0b
parent ffa1e4a5
...@@ -46,11 +46,11 @@ typedef struct { ...@@ -46,11 +46,11 @@ typedef struct {
// List of operators from Itanium C++ ABI. // List of operators from Itanium C++ ABI.
static const AbbrevPair kOperatorList[] = { static const AbbrevPair kOperatorList[] = {
// New has special syntax (not currently supported). // New has special syntax.
{"nw", "new", 0}, {"nw", "new", 0},
{"na", "new[]", 0}, {"na", "new[]", 0},
// Works except that the 'gs' prefix is not supported. // Special-cased elsewhere to support the optional gs prefix.
{"dl", "delete", 1}, {"dl", "delete", 1},
{"da", "delete[]", 1}, {"da", "delete[]", 1},
...@@ -1998,6 +1998,8 @@ static bool ParseBracedExpression(State *state) { ...@@ -1998,6 +1998,8 @@ static bool ParseBracedExpression(State *state) {
// ::= [gs] nw <expression>* _ <type> <initializer> // ::= [gs] nw <expression>* _ <type> <initializer>
// ::= [gs] na <expression>* _ <type> E // ::= [gs] na <expression>* _ <type> E
// ::= [gs] na <expression>* _ <type> <initializer> // ::= [gs] na <expression>* _ <type> <initializer>
// ::= [gs] dl <expression>
// ::= [gs] da <expression>
// ::= dc <type> <expression> // ::= dc <type> <expression>
// ::= sc <type> <expression> // ::= sc <type> <expression>
// ::= cc <type> <expression> // ::= cc <type> <expression>
...@@ -2106,6 +2108,15 @@ static bool ParseExpression(State *state) { ...@@ -2106,6 +2108,15 @@ static bool ParseExpression(State *state) {
} }
state->parse_state = copy; state->parse_state = copy;
// <expression> ::= [gs] dl <expression>
// ::= [gs] da <expression>
if (Optional(ParseTwoCharToken(state, "gs")) &&
(ParseTwoCharToken(state, "dl") || ParseTwoCharToken(state, "da")) &&
ParseExpression(state)) {
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>
......
...@@ -1258,6 +1258,66 @@ TEST(Demangle, ArrayNewExpressionWithTwoElementsInBraces) { ...@@ -1258,6 +1258,66 @@ TEST(Demangle, ArrayNewExpressionWithTwoElementsInBraces) {
EXPECT_STREQ("f<>()", tmp); EXPECT_STREQ("f<>()", tmp);
} }
TEST(Demangle, SimpleDeleteExpression) {
char tmp[80];
// Source:
//
// template <class T> auto f(T* p) -> decltype(delete p) {}
// template auto f<int>(int* p) -> decltype(delete p);
//
// LLVM demangling:
//
// decltype(delete fp) f<int>(int*)
EXPECT_TRUE(Demangle("_Z1fIiEDTdlfp_EPT_", tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
}
TEST(Demangle, GlobalScopeDeleteExpression) {
char tmp[80];
// Source:
//
// template <class T> auto f(T* p) -> decltype(::delete p) {}
// template auto f<int>(int* p) -> decltype(::delete p);
//
// LLVM demangling:
//
// decltype(::delete fp) f<int>(int*)
EXPECT_TRUE(Demangle("_Z1fIiEDTgsdlfp_EPT_", tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
}
TEST(Demangle, SimpleArrayDeleteExpression) {
char tmp[80];
// Source:
//
// template <class T> auto f(T* a) -> decltype(delete[] a) {}
// template auto f<int>(int* a) -> decltype(delete[] a);
//
// LLVM demangling:
//
// decltype(delete[] fp) f<int>(int*)
EXPECT_TRUE(Demangle("_Z1fIiEDTdafp_EPT_", tmp, sizeof(tmp)));
EXPECT_STREQ("f<>()", tmp);
}
TEST(Demangle, GlobalScopeArrayDeleteExpression) {
char tmp[80];
// Source:
//
// template <class T> auto f(T* a) -> decltype(::delete[] a) {}
// template auto f<int>(int* a) -> decltype(::delete[] a);
//
// LLVM demangling:
//
// decltype(::delete[] fp) f<int>(int*)
EXPECT_TRUE(Demangle("_Z1fIiEDTgsdafp_EPT_", 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