aboutsummaryrefslogtreecommitdiff
path: root/absl/debugging/internal/demangle.cc
diff options
context:
space:
mode:
authorChris Mihelich <cmihelic@google.com>2024-05-24 15:33:25 -0700
committerCopybara-Service <copybara-worker@google.com>2024-05-24 15:34:23 -0700
commitbaf07b1f6201e4a6b3f16d87131a558693197c6f (patch)
tree4587a71cec7a762e1e419ba3452d9d04b802350c /absl/debugging/internal/demangle.cc
parent49c1f36ec50b3f812f9031d1cf35f1f514eb2a21 (diff)
downloadabseil-baf07b1f6201e4a6b3f16d87131a558693197c6f.tar.gz
abseil-baf07b1f6201e4a6b3f16d87131a558693197c6f.tar.bz2
abseil-baf07b1f6201e4a6b3f16d87131a558693197c6f.zip
Demangle C++ requires-expressions without parameters (rq ... E).
PiperOrigin-RevId: 637052089 Change-Id: I8e22c2479749c05d8ca5f9e8eeba480a93da2d18
Diffstat (limited to 'absl/debugging/internal/demangle.cc')
-rw-r--r--absl/debugging/internal/demangle.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc
index 6012a59a..cfcd64b6 100644
--- a/absl/debugging/internal/demangle.cc
+++ b/absl/debugging/internal/demangle.cc
@@ -602,6 +602,7 @@ static bool ParseExpression(State *state);
static bool ParseExprPrimary(State *state);
static bool ParseExprCastValueAndTrailingE(State *state);
static bool ParseQRequiresClauseExpr(State *state);
+static bool ParseRequirement(State *state);
static bool ParseLocalName(State *state);
static bool ParseLocalNameSuffix(State *state);
static bool ParseDiscriminator(State *state);
@@ -1852,6 +1853,7 @@ static bool ParseBracedExpression(State *state) {
// ::= sr <type> <unqualified-name> <template-args>
// ::= sr <type> <unqualified-name>
// ::= u <source-name> <template-arg>* E # vendor extension
+// ::= rq <requirement>+ E
static bool ParseExpression(State *state) {
ComplexityGuard guard(state);
if (guard.IsTooComplex()) return false;
@@ -1982,6 +1984,15 @@ static bool ParseExpression(State *state) {
}
state->parse_state = copy;
+ // <expression> ::= rq <requirement>+ E
+ //
+ // https://github.com/itanium-cxx-abi/cxx-abi/issues/24
+ if (ParseTwoCharToken(state, "rq") && OneOrMore(ParseRequirement, state) &&
+ ParseOneCharToken(state, 'E')) {
+ return true;
+ }
+ state->parse_state = copy;
+
return ParseUnresolvedName(state);
}
@@ -2098,6 +2109,39 @@ static bool ParseQRequiresClauseExpr(State *state) {
return false;
}
+// <requirement> ::= X <expression> [N] [R <type-constraint>]
+// <requirement> ::= T <type>
+// <requirement> ::= Q <constraint-expression>
+//
+// <type-constraint> ::= <name>
+//
+// <constraint-expression> ::= <expression>
+//
+// https://github.com/itanium-cxx-abi/cxx-abi/issues/24
+static bool ParseRequirement(State *state) {
+ ComplexityGuard guard(state);
+ if (guard.IsTooComplex()) return false;
+
+ ParseState copy = state->parse_state;
+
+ if (ParseOneCharToken(state, 'X') && ParseExpression(state) &&
+ Optional(ParseOneCharToken(state, 'N')) &&
+ // This logic backtracks cleanly if we eat an R but a valid type doesn't
+ // follow it.
+ (!ParseOneCharToken(state, 'R') || ParseName(state))) {
+ return true;
+ }
+ state->parse_state = copy;
+
+ if (ParseOneCharToken(state, 'T') && ParseType(state)) return true;
+ state->parse_state = copy;
+
+ if (ParseOneCharToken(state, 'Q') && ParseExpression(state)) return true;
+ state->parse_state = copy;
+
+ return false;
+}
+
// <local-name> ::= Z <(function) encoding> E <(entity) name> [<discriminator>]
// ::= Z <(function) encoding> E s [<discriminator>]
//