mirror of git://gcc.gnu.org/git/gcc.git
demangler: Structured Bindings
C++ Structured bindings have a mangling that has yet to be formally documented. However, it's been around for a while and shows up for module support. include/ * demangle.h (enum demangle_component_type): Add DEMANGLE_COMPONENT_STRUCTURED_BINDING. libiberty/ * cp-demangle.c (d_make_comp): Adjust. (d_unqualified_name): Add 'DC' support. (d_count_template_scopes): Adjust. (d_print_comp_inner): Add structured binding. * testsuite/demangle-expected: Add testcases.
This commit is contained in:
parent
7a3f38a966
commit
451894cadc
|
@ -449,7 +449,9 @@ enum demangle_component_type
|
||||||
/* A cloned function. */
|
/* A cloned function. */
|
||||||
DEMANGLE_COMPONENT_CLONE,
|
DEMANGLE_COMPONENT_CLONE,
|
||||||
DEMANGLE_COMPONENT_NOEXCEPT,
|
DEMANGLE_COMPONENT_NOEXCEPT,
|
||||||
DEMANGLE_COMPONENT_THROW_SPEC
|
DEMANGLE_COMPONENT_THROW_SPEC,
|
||||||
|
|
||||||
|
DEMANGLE_COMPONENT_STRUCTURED_BINDING
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Types which are only used internally. */
|
/* Types which are only used internally. */
|
||||||
|
|
|
@ -1020,6 +1020,7 @@ d_make_comp (struct d_info *di, enum demangle_component_type type,
|
||||||
case DEMANGLE_COMPONENT_NULLARY:
|
case DEMANGLE_COMPONENT_NULLARY:
|
||||||
case DEMANGLE_COMPONENT_TRINARY_ARG2:
|
case DEMANGLE_COMPONENT_TRINARY_ARG2:
|
||||||
case DEMANGLE_COMPONENT_TPARM_OBJ:
|
case DEMANGLE_COMPONENT_TPARM_OBJ:
|
||||||
|
case DEMANGLE_COMPONENT_STRUCTURED_BINDING:
|
||||||
if (left == NULL)
|
if (left == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
break;
|
break;
|
||||||
|
@ -1619,12 +1620,12 @@ d_prefix (struct d_info *di, int subst)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* <unqualified-name> ::= <operator-name>
|
/* <unqualified-name> ::= <operator-name> [<abi-tags>]
|
||||||
::= <ctor-dtor-name>
|
::= <ctor-dtor-name> [<abi-tags>]
|
||||||
::= <source-name>
|
::= <source-name> [<abi-tags>]
|
||||||
::= <local-source-name>
|
::= <local-source-name> [<abi-tags>]
|
||||||
|
::= DC <source-name>+ E [<abi-tags>]
|
||||||
<local-source-name> ::= L <source-name> <discriminator>
|
<local-source-name> ::= L <source-name> <discriminator> [<abi-tags>]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static struct demangle_component *
|
static struct demangle_component *
|
||||||
|
@ -1655,6 +1656,28 @@ d_unqualified_name (struct d_info *di)
|
||||||
d_source_name (di));
|
d_source_name (di));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (peek == 'D' && d_peek_next_char (di) == 'C')
|
||||||
|
{
|
||||||
|
// structured binding
|
||||||
|
d_advance (di, 2);
|
||||||
|
struct demangle_component *prev = NULL;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
struct demangle_component *next =
|
||||||
|
d_make_comp (di, DEMANGLE_COMPONENT_STRUCTURED_BINDING,
|
||||||
|
d_source_name (di), NULL);
|
||||||
|
if (prev)
|
||||||
|
d_right (prev) = next;
|
||||||
|
else
|
||||||
|
ret = next;
|
||||||
|
prev = next;
|
||||||
|
}
|
||||||
|
while (prev && d_peek_char (di) != 'E');
|
||||||
|
if (prev)
|
||||||
|
d_advance (di, 1);
|
||||||
|
else
|
||||||
|
ret = NULL;
|
||||||
|
}
|
||||||
else if (peek == 'C' || peek == 'D')
|
else if (peek == 'C' || peek == 'D')
|
||||||
ret = d_ctor_dtor_name (di);
|
ret = d_ctor_dtor_name (di);
|
||||||
else if (peek == 'L')
|
else if (peek == 'L')
|
||||||
|
@ -4179,6 +4202,7 @@ d_count_templates_scopes (struct d_print_info *dpi,
|
||||||
case DEMANGLE_COMPONENT_CHARACTER:
|
case DEMANGLE_COMPONENT_CHARACTER:
|
||||||
case DEMANGLE_COMPONENT_NUMBER:
|
case DEMANGLE_COMPONENT_NUMBER:
|
||||||
case DEMANGLE_COMPONENT_UNNAMED_TYPE:
|
case DEMANGLE_COMPONENT_UNNAMED_TYPE:
|
||||||
|
case DEMANGLE_COMPONENT_STRUCTURED_BINDING:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DEMANGLE_COMPONENT_TEMPLATE:
|
case DEMANGLE_COMPONENT_TEMPLATE:
|
||||||
|
@ -4850,6 +4874,19 @@ d_print_comp_inner (struct d_print_info *dpi, int options,
|
||||||
d_append_char (dpi, ']');
|
d_append_char (dpi, ']');
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
case DEMANGLE_COMPONENT_STRUCTURED_BINDING:
|
||||||
|
d_append_char (dpi, '[');
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
d_print_comp (dpi, options, d_left (dc));
|
||||||
|
dc = d_right (dc);
|
||||||
|
if (!dc)
|
||||||
|
break;
|
||||||
|
d_append_string (dpi, ", ");
|
||||||
|
}
|
||||||
|
d_append_char (dpi, ']');
|
||||||
|
return;
|
||||||
|
|
||||||
case DEMANGLE_COMPONENT_QUAL_NAME:
|
case DEMANGLE_COMPONENT_QUAL_NAME:
|
||||||
case DEMANGLE_COMPONENT_LOCAL_NAME:
|
case DEMANGLE_COMPONENT_LOCAL_NAME:
|
||||||
d_print_comp (dpi, options, d_left (dc));
|
d_print_comp (dpi, options, d_left (dc));
|
||||||
|
|
|
@ -1493,3 +1493,13 @@ decltype ({parm#1}.A::x) f<A>(A)
|
||||||
|
|
||||||
_Z2f6IP1AEDtptfp_gssr1A1BE1xET_
|
_Z2f6IP1AEDtptfp_gssr1A1BE1xET_
|
||||||
decltype ({parm#1}->(::A::B::x)) f6<A*>(A*)
|
decltype ({parm#1}->(::A::B::x)) f6<A*>(A*)
|
||||||
|
|
||||||
|
# Structured Bindings
|
||||||
|
_ZDC1a1bE
|
||||||
|
[a, b]
|
||||||
|
|
||||||
|
_ZNStDC1aEE
|
||||||
|
std::[a]
|
||||||
|
|
||||||
|
_ZN3NMSDC1aEE
|
||||||
|
NMS::[a]
|
||||||
|
|
Loading…
Reference in New Issue