mirror of
https://github.com/abseil/abseil-cpp.git
synced 2026-06-04 20:14:23 +08:00
Demangle C++17 structured bindings, DC...E.
PiperOrigin-RevId: 640547784 Change-Id: Ib230993a358f89258367a1c10271c47be3b724e5
This commit is contained in:
committed by
Copybara-Service
parent
cba68bb93b
commit
8322d3abcc
@@ -821,6 +821,7 @@ static bool ParsePrefix(State *state) {
|
||||
// ::= <source-name> [<abi-tags>]
|
||||
// ::= <local-source-name> [<abi-tags>]
|
||||
// ::= <unnamed-type-name> [<abi-tags>]
|
||||
// ::= DC <source-name>+ E # C++17 structured binding
|
||||
//
|
||||
// <local-source-name> is a GCC extension; see below.
|
||||
static bool ParseUnqualifiedName(State *state) {
|
||||
@@ -831,6 +832,14 @@ static bool ParseUnqualifiedName(State *state) {
|
||||
ParseUnnamedTypeName(state)) {
|
||||
return ParseAbiTags(state);
|
||||
}
|
||||
|
||||
// DC <source-name>+ E
|
||||
ParseState copy = state->parse_state;
|
||||
if (ParseTwoCharToken(state, "DC") && OneOrMore(ParseSourceName, state) &&
|
||||
ParseOneCharToken(state, 'E')) {
|
||||
return true;
|
||||
}
|
||||
state->parse_state = copy;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -632,6 +632,21 @@ TEST(Demangle, GlobalInitializers) {
|
||||
EXPECT_STREQ("reference temporary for v", tmp);
|
||||
}
|
||||
|
||||
TEST(Demangle, StructuredBindings) {
|
||||
char tmp[80];
|
||||
|
||||
// Source:
|
||||
//
|
||||
// struct S { int a, b; };
|
||||
// const auto& [x, y] = S{1, 2};
|
||||
|
||||
// [x, y]
|
||||
EXPECT_TRUE(Demangle("_ZDC1x1yE", tmp, sizeof(tmp)));
|
||||
|
||||
// reference temporary for [x, y]
|
||||
EXPECT_TRUE(Demangle("_ZGRDC1x1yE_", tmp, sizeof(tmp)));
|
||||
}
|
||||
|
||||
// Test the GNU abi_tag extension.
|
||||
TEST(Demangle, AbiTags) {
|
||||
char tmp[80];
|
||||
|
||||
Reference in New Issue
Block a user