summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Mihelich <cmihelic@google.com>2024-06-05 14:22:59 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2024-06-05 14:23:44 -0700
commitaad792d4cf8cb64d6edec7a3399a4444639bddd2 (patch)
treed21422f6e9783efc59d7c0e2b8d5a6b154c1b1e5
parent9e72bd674675db044ef1de81ff542539d26fcb1b (diff)
Demangle throw and rethrow (tw... and tr).
PiperOrigin-RevId: 640648613 Change-Id: Ifb4c385e629e2649da61b2b49c786a320da05fc7
-rw-r--r--absl/debugging/internal/demangle.cc11
-rw-r--r--absl/debugging/internal/demangle_test.cc30
2 files changed, 41 insertions, 0 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc
index 1d14ac6c..8887ee47 100644
--- a/absl/debugging/internal/demangle.cc
+++ b/absl/debugging/internal/demangle.cc
@@ -2014,6 +2014,8 @@ static bool ParseBracedExpression(State *state) {
// ::= fr <binary operator-name> <expression>
// ::= fL <binary operator-name> <expression> <expression>
// ::= fR <binary operator-name> <expression> <expression>
+// ::= tw <expression>
+// ::= tr
// ::= sr <type> <unqualified-name> <template-args>
// ::= sr <type> <unqualified-name>
// ::= u <source-name> <template-arg>* E # vendor extension
@@ -2197,6 +2199,15 @@ static bool ParseExpression(State *state) {
}
state->parse_state = copy;
+ // tw <expression>: throw e
+ if (ParseTwoCharToken(state, "tw") && ParseExpression(state)) {
+ return true;
+ }
+ state->parse_state = copy;
+
+ // tr: throw (rethrows an exception from the handler that caught it)
+ if (ParseTwoCharToken(state, "tr")) return true;
+
// Object and pointer member access expressions.
//
// <expression> ::= (dt | pt) <expression> <unresolved-name>
diff --git a/absl/debugging/internal/demangle_test.cc b/absl/debugging/internal/demangle_test.cc
index 9050e96e..85a20f0a 100644
--- a/absl/debugging/internal/demangle_test.cc
+++ b/absl/debugging/internal/demangle_test.cc
@@ -1177,6 +1177,36 @@ TEST(Demangle, NoexceptExpression) {
EXPECT_STREQ("f<>()", tmp);
}
+TEST(Demangle, UnaryThrow) {
+ char tmp[80];
+
+ // Source:
+ //
+ // template <bool b> decltype(b ? throw b : 0) f() { return 0; }
+ // template decltype(false ? throw false : 0) f<false>();
+ //
+ // Full LLVM demangling of the instantiation of f:
+ //
+ // decltype(false ? throw false : 0) f<false>()
+ EXPECT_TRUE(Demangle("_Z1fILb0EEDTquT_twT_Li0EEv", tmp, sizeof(tmp)));
+ EXPECT_STREQ("f<>()", tmp);
+}
+
+TEST(Demangle, NullaryThrow) {
+ char tmp[80];
+
+ // Source:
+ //
+ // template <bool b> decltype(b ? throw : 0) f() { return 0; }
+ // template decltype(false ? throw : 0) f<false>();
+ //
+ // Full LLVM demangling of the instantiation of f:
+ //
+ // decltype(false ? throw : 0) f<false>()
+ EXPECT_TRUE(Demangle("_Z1fILb0EEDTquT_trLi0EEv", tmp, sizeof(tmp)));
+ EXPECT_STREQ("f<>()", tmp);
+}
+
TEST(Demangle, ThreadLocalWrappers) {
char tmp[80];