Commit 8322d3ab by Chris Mihelich Committed by Copybara-Service

Demangle C++17 structured bindings, DC...E.

PiperOrigin-RevId: 640547784
Change-Id: Ib230993a358f89258367a1c10271c47be3b724e5
parent cba68bb9
......@@ -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];
......
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