diff options
author | Chris Mihelich <cmihelic@google.com> | 2024-05-29 05:05:20 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2024-05-29 05:06:18 -0700 |
commit | abc0f8d1096a66c087365327c217963eab15839c (patch) | |
tree | 4a7f5706035a4f4eba84dedbd354f21d29857d28 /absl/debugging/internal/demangle.cc | |
parent | 1f5a9cdc4354faccda4227235ea1acb77d9a4466 (diff) | |
download | abseil-abc0f8d1096a66c087365327c217963eab15839c.tar.gz abseil-abc0f8d1096a66c087365327c217963eab15839c.tar.bz2 abseil-abc0f8d1096a66c087365327c217963eab15839c.zip |
Demangle Clang's encoding of __attribute__((enable_if(condition, "message"))).
PiperOrigin-RevId: 638244694
Change-Id: I80393c6c00f1554057a915e0d71f88b7d899818c
Diffstat (limited to 'absl/debugging/internal/demangle.cc')
-rw-r--r-- | absl/debugging/internal/demangle.cc | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/absl/debugging/internal/demangle.cc b/absl/debugging/internal/demangle.cc index f04e4dbc..606ff4e7 100644 --- a/absl/debugging/internal/demangle.cc +++ b/absl/debugging/internal/demangle.cc @@ -585,6 +585,7 @@ static bool ParseCVQualifiers(State *state); static bool ParseBuiltinType(State *state); static bool ParseFunctionType(State *state); static bool ParseBareFunctionType(State *state); +static bool ParseOverloadAttribute(State *state); static bool ParseClassEnumType(State *state); static bool ParseArrayType(State *state); static bool ParsePointerToMemberType(State *state); @@ -1437,13 +1438,17 @@ static bool ParseFunctionType(State *state) { return true; } -// <bare-function-type> ::= <(signature) type>+ +// <bare-function-type> ::= <overload-attribute>* <(signature) type>+ +// +// The <overload-attribute>* prefix is nonstandard; see the comment on +// ParseOverloadAttribute. static bool ParseBareFunctionType(State *state) { ComplexityGuard guard(state); if (guard.IsTooComplex()) return false; ParseState copy = state->parse_state; DisableAppend(state); - if (OneOrMore(ParseType, state)) { + if (ZeroOrMore(ParseOverloadAttribute, state) && + OneOrMore(ParseType, state)) { RestoreAppend(state, copy.append); MaybeAppend(state, "()"); return true; @@ -1452,6 +1457,25 @@ static bool ParseBareFunctionType(State *state) { return false; } +// <overload-attribute> ::= Ua <name> +// +// The nonstandard <overload-attribute> production is sufficient to accept the +// current implementation of __attribute__((enable_if(condition, "message"))) +// and future attributes of a similar shape. See +// https://clang.llvm.org/docs/AttributeReference.html#enable-if and the +// definition of CXXNameMangler::mangleFunctionEncodingBareType in Clang's +// source code. +static bool ParseOverloadAttribute(State *state) { + ComplexityGuard guard(state); + if (guard.IsTooComplex()) return false; + ParseState copy = state->parse_state; + if (ParseTwoCharToken(state, "Ua") && ParseName(state)) { + return true; + } + state->parse_state = copy; + return false; +} + // <class-enum-type> ::= <name> static bool ParseClassEnumType(State *state) { ComplexityGuard guard(state); |