]> git.ipfire.org Git - thirdparty/gcc.git/commit
demangler: Templated lambda demangling
authorNathan Sidwell <nathan@acm.org>
Mon, 7 Nov 2022 16:24:14 +0000 (11:24 -0500)
committerNathan Sidwell <nathan@acm.org>
Tue, 15 Nov 2022 18:34:56 +0000 (13:34 -0500)
commit46c3d9c8e8f6becdb73bac8bcc2f0ba12d6b1d9c
treece741eb8aeff36b6556e824b5752c5ce63e0f10f
parentee08aa9ab4100b8774d149bb235b00bddebd4b89
demangler: Templated lambda demangling

Templated lambdas have a template-head, which is part of their
signature.  GCC ABI 18 mangles that into the lambda name.  This adds
support to the demangler.  We have to introduce artificial template
parameter names, as we need to refer to them from later components of
the lambda signature. We use $T:n, $N:n and $TT:n for type, non-type
and template parameters.  Non-type parameter names are not shown in
the strictly correct location -- for instance 'int (&NT) ()' would be
shown as 'int (&) $N:n'.  That's unfortunate, but an orthogonal issue.
The 'is_lambda_arg' field is now repurposed as indicating the number
of explicit template parameters (1-based).

include/
* demangle.h (enum demangle_component_type): Add
DEMANGLE_COMPONENT_TEMPLATE_HEAD,
DEMANGLE_COMPONENT_TEMPLATE_TYPE_PARM,
DEMANGLE_COMPONENT_TEMPLATE_NON_TYPE_PARM,
DEMANGLE_COMPONENT_TEMPLATE_TEMPLATE_PARM,
DEMANGLE_COMPONENT_TEMPLATE_PACK_PARM.
libiberty/
* cp-demangle.c (struct d_print_info): Rename is_lambda_arg to
lambda_tpl_parms.  Augment semantics.
(d_make_comp): Add checks for new components.
(d_template_parm, d_template_head): New.
(d_lambda): Add templated lambda support.
(d_print_init): Adjust.
(d_print_lambda_parm_name): New.
(d_print_comp_inner): Support templated lambdas,
* testsuite/demangle-expected: Add testcases.
include/demangle.h
libiberty/cp-demangle.c
libiberty/testsuite/demangle-expected