summaryrefslogtreecommitdiff
path: root/absl/debugging
diff options
context:
space:
mode:
authorGravatar Chris Mihelich <cmihelic@google.com>2024-06-06 09:42:39 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2024-06-06 09:43:54 -0700
commited34153e0d9cd15f9b9eb45e86b457e0a495aeea (patch)
treea633a9073deb925de694f06a082d05d1166633b6 /absl/debugging
parentffa1e4a52a35c49e52352674d3099692a3958625 (diff)
Demangle delete-expressions with the global-scope operator, gs (dl | da) ....
PiperOrigin-RevId: 640928445 Change-Id: I547f194ebb0a4482ecec627a7a03bab60e8e1c0b
Diffstat (limited to 'absl/debugging')
-rw-r--r--absl/debugging/internal/demangle.cc15
-rw-r--r--absl/debugging/internal/demangle_test.cc60
2 files changed, 73 insertions, 2 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc
index 72cc887b..58749478 100644
--- a/absl/debugging/internal/demangle.cc
+++ b/absl/debugging/internal/demangle.cc
@@ -46,11 +46,11 @@ typedef struct {
// List of operators from Itanium C++ ABI.
static const AbbrevPair kOperatorList[] = {
- // New has special syntax (not currently supported).
+ // New has special syntax.
{"nw", "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},
{"da", "delete[]", 1},
@@ -1998,6 +1998,8 @@ static bool ParseBracedExpression(State *state) {
// ::= [gs] nw <expression>* _ <type> <initializer>
// ::= [gs] na <expression>* _ <type> E
// ::= [gs] na <expression>* _ <type> <initializer>
+// ::= [gs] dl <expression>
+// ::= [gs] da <expression>
// ::= dc <type> <expression>
// ::= sc <type> <expression>
// ::= cc <type> <expression>
@@ -2106,6 +2108,15 @@ static bool ParseExpression(State *state) {
}
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.
//
// <expression> ::= (dc | sc | cc | rc) <type> <expression>
diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc
index 317e8494..c1308de9 100644
--- a/absl/debugging/internal/demangle_test.cc
+++ b/absl/debugging/internal/demangle_test.cc
@@ -1258,6 +1258,66 @@ TEST(Demangle, ArrayNewExpressionWithTwoElementsInBraces) {
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) {
char tmp[80];