diff options
author | Chris Mihelich <cmihelic@google.com> | 2024-05-23 13:05:10 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-05-23 13:06:15 -0700 |
commit | 9e095d746f915339579798677a141a384543403e (patch) | |
tree | d67e2e0b97dfaf7923d10970d593403f76f8d9dc /absl/debugging/internal/demangle.cc | |
parent | cfac0a350617776cf461ba8b9f743378eb4ae355 (diff) | |
download | abseil-9e095d746f915339579798677a141a384543403e.tar.gz abseil-9e095d746f915339579798677a141a384543403e.tar.bz2 abseil-9e095d746f915339579798677a141a384543403e.zip |
Demangle C++ direct-list-initialization (T{1, 2, 3}, tl ... E).
PiperOrigin-RevId: 636649618
Change-Id: I73a0be3defa438daf0e9db5c34c0e2feb0e52b69
Diffstat (limited to 'absl/debugging/internal/demangle.cc')
-rw-r--r-- | absl/debugging/internal/demangle.cc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc index ff89f8d8..e9c8d176 100644 --- a/absl/debugging/internal/demangle.cc +++ b/absl/debugging/internal/demangle.cc @@ -582,6 +582,7 @@ static bool ParseBaseUnresolvedName(State *state); static bool ParseUnresolvedName(State *state); static bool ParseUnionSelector(State* state); static bool ParseFunctionParam(State* state); +static bool ParseBracedExpression(State *state); static bool ParseExpression(State *state); static bool ParseExprPrimary(State *state); static bool ParseExprCastValue(State *state); @@ -1782,6 +1783,38 @@ static bool ParseFunctionParam(State *state) { return false; } +// <braced-expression> ::= <expression> +// ::= di <field source-name> <braced-expression> +// ::= dx <index expression> <braced-expression> +// ::= dX <expression> <expression> <braced-expression> +static bool ParseBracedExpression(State *state) { + ComplexityGuard guard(state); + if (guard.IsTooComplex()) return false; + + ParseState copy = state->parse_state; + + if (ParseTwoCharToken(state, "di") && ParseSourceName(state) && + ParseBracedExpression(state)) { + return true; + } + state->parse_state = copy; + + if (ParseTwoCharToken(state, "dx") && ParseExpression(state) && + ParseBracedExpression(state)) { + return true; + } + state->parse_state = copy; + + if (ParseTwoCharToken(state, "dX") && + ParseExpression(state) && ParseExpression(state) && + ParseBracedExpression(state)) { + return true; + } + state->parse_state = copy; + + return ParseExpression(state); +} + // <expression> ::= <1-ary operator-name> <expression> // ::= <2-ary operator-name> <expression> <expression> // ::= <3-ary operator-name> <expression> <expression> <expression> @@ -1790,6 +1823,7 @@ static bool ParseFunctionParam(State *state) { // ::= so <type> <expression> [<number>] <union-selector>* [p] E // ::= cv <type> <expression> # type (expression) // ::= cv <type> _ <expression>* E # type (expr-list) +// ::= tl <type> <braced-expression>* E // ::= st <type> // ::= <template-param> // ::= <function-param> @@ -1841,6 +1875,14 @@ static bool ParseExpression(State *state) { if (ParseFunctionParam(state)) return true; state->parse_state = copy; + // <expression> ::= tl <type> <braced-expression>* E + if (ParseTwoCharToken(state, "tl") && ParseType(state) && + ZeroOrMore(ParseBracedExpression, state) && + ParseOneCharToken(state, 'E')) { + return true; + } + state->parse_state = copy; + // Parse the conversion expressions jointly to avoid re-parsing the <type> in // their common prefix. Parsed as: // <expression> ::= cv <type> <conversion-args> |