Commit aad792d4 by Chris Mihelich Committed by Copybara-Service

Demangle throw and rethrow (tw... and tr).

PiperOrigin-RevId: 640648613
Change-Id: Ifb4c385e629e2649da61b2b49c786a320da05fc7
parent 9e72bd67
......@@ -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>
......
......@@ -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];
......
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