Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ABI updates for C++20 lambda-expression features: #85

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

zygoloid
Copy link
Contributor

@zygoloid zygoloid commented Sep 5, 2019

  • include declarations for explicitly-specified template parameters in
    the lambda-sig mangling

  • add mangling for template parameters at different depths (possible
    via generic lambdas in unevaluated operands and via template template
    parameters in lambda-sigs)

Fixes #31, #157, #165.

 * include declarations for explicitly-specified template parameters in
   the lambda-sig mangling

 * add mangling for template parameters at different depths (possible
   via generic lambdas in unevaluated operands and via template template
   parameters in lambda-sigs)

Fixes itanium-cxx-abi#31.
@zygoloid zygoloid force-pushed the template-param-depth-and-lambda-sig branch from 84616bc to 3ebf3e6 Compare September 6, 2019 00:06
llvm-git-migration pushed a commit to llvm/llvm-project that referenced this pull request Sep 6, 2019
This implements demangling support for the mangling extensions specified
in itanium-cxx-abi/cxx-abi#85, much of which is
implemented in Clang r359967 and r371004.

Specifically, this provides demangling for:

 * <template-param-decl> in <lambda-sig>
 * <template-param> with non-zero level
 * lambda-expression literals (not emitted by Clang yet)
 * nullptr literals
 * string literals

(The final two seem unrelated, but handling them was necessary in order
to disambiguate between lambda expressions and the other forms of
literal for which we have a type but no value.)

When demangling a <lambda-sig>, we form template parameters with no
corresponding argument, so we cannot substitute in the argument in the
demangling. Instead we invent synthetic names for the template
parameters (eg, '[]<typename $T>($T *x)').

llvm-svn: 371273
dtzWill pushed a commit to llvm-mirror/libcxxabi that referenced this pull request Sep 6, 2019
This implements demangling support for the mangling extensions specified
in itanium-cxx-abi/cxx-abi#85, much of which is
implemented in Clang r359967 and r371004.

Specifically, this provides demangling for:

 * <template-param-decl> in <lambda-sig>
 * <template-param> with non-zero level
 * lambda-expression literals (not emitted by Clang yet)
 * nullptr literals
 * string literals

(The final two seem unrelated, but handling them was necessary in order
to disambiguate between lambda expressions and the other forms of
literal for which we have a type but no value.)

When demangling a <lambda-sig>, we form template parameters with no
corresponding argument, so we cannot substitute in the argument in the
demangling. Instead we invent synthetic names for the template
parameters (eg, '[]<typename $T>($T *x)').

git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@371273 91177308-0d34-0410-b5e6-96231b3b80d8
unevaluated operands and therefore in function signatures).
@zygoloid zygoloid force-pushed the template-param-depth-and-lambda-sig branch 2 times, most recently from 9aba465 to 1a6ce4e Compare September 9, 2019 21:31
arguments and default member initializers.
@zygoloid zygoloid force-pushed the template-param-depth-and-lambda-sig branch from 1a6ce4e to 9618b59 Compare September 9, 2019 22:13
jrtc27 pushed a commit to CTSRD-CHERI/llvm-project that referenced this pull request Oct 5, 2019
This implements demangling support for the mangling extensions specified
in itanium-cxx-abi/cxx-abi#85, much of which is
implemented in Clang r359967 and r371004.

Specifically, this provides demangling for:

 * <template-param-decl> in <lambda-sig>
 * <template-param> with non-zero level
 * lambda-expression literals (not emitted by Clang yet)
 * nullptr literals
 * string literals

(The final two seem unrelated, but handling them was necessary in order
to disambiguate between lambda expressions and the other forms of
literal for which we have a type but no value.)

When demangling a <lambda-sig>, we form template parameters with no
corresponding argument, so we cannot substitute in the argument in the
demangling. Instead we invent synthetic names for the template
parameters (eg, '[]<typename $T>($T *x)').

llvm-svn: 371273
phanikishoreg pushed a commit to gwsystems/wasmception-libcxxabi that referenced this pull request Apr 1, 2020
This implements demangling support for the mangling extensions specified
in itanium-cxx-abi/cxx-abi#85, much of which is
implemented in Clang r359967 and r371004.

Specifically, this provides demangling for:

 * <template-param-decl> in <lambda-sig>
 * <template-param> with non-zero level
 * lambda-expression literals (not emitted by Clang yet)
 * nullptr literals
 * string literals

(The final two seem unrelated, but handling them was necessary in order
to disambiguate between lambda expressions and the other forms of
literal for which we have a type but no value.)

When demangling a <lambda-sig>, we form template parameters with no
corresponding argument, so we cannot substitute in the argument in the
demangling. Instead we invent synthetic names for the template
parameters (eg, '[]<typename $T>($T *x)').

git-svn-id: http://llvm.org/svn/llvm-project/libcxxabi/trunk@371273 91177308-0d34-0410-b5e6-96231b3b80d8
ianlancetaylor added a commit to ianlancetaylor/demangle that referenced this pull request Mar 31, 2021
conr2d pushed a commit to haderech/libcxxabi that referenced this pull request Aug 27, 2021
This implements demangling support for the mangling extensions specified
in itanium-cxx-abi/cxx-abi#85, much of which is
implemented in Clang r359967 and r371004.

Specifically, this provides demangling for:

 * <template-param-decl> in <lambda-sig>
 * <template-param> with non-zero level
 * lambda-expression literals (not emitted by Clang yet)
 * nullptr literals
 * string literals

(The final two seem unrelated, but handling them was necessary in order
to disambiguate between lambda expressions and the other forms of
literal for which we have a type but no value.)

When demangling a <lambda-sig>, we form template parameters with no
corresponding argument, so we cannot substitute in the argument in the
demangling. Instead we invent synthetic names for the template
parameters (eg, '[]<typename $T>($T *x)').

llvm-svn: 371273
rjmccall added a commit to rjmccall/cxx-abi that referenced this pull request May 15, 2023
This includes the material from itanium-cxx-abi#47 (non-type template
arguments), itanium-cxx-abi#63 (class constants), and the template-param-decl
portions of itanium-cxx-abi#85 (C++20 lambda-expressions).

@zygoloid gets credit for most of this, although I've made a few
substantive changes from his suggestions.
abi.html Outdated Show resolved Hide resolved
@zygoloid
Copy link
Contributor Author

I've removed the introduction of template-param-decl here, on the assumption that it will be provided by #166.

@rjmccall Please can you take a look? This has been pending for a while.

abi.html Outdated Show resolved Hide resolved
…ears in the signature of a function template.
rjmccall added a commit to rjmccall/cxx-abi that referenced this pull request Nov 2, 2023
This includes the material from itanium-cxx-abi#47 (non-type template
arguments), itanium-cxx-abi#63 (class constants), and the template-param-decl
portions of itanium-cxx-abi#85 (C++20 lambda-expressions).

@zygoloid gets credit for most of this, although I've made a few
substantive changes from his suggestions.
@dinord
Copy link

dinord commented Feb 15, 2024

Is it possible to merge this pull request? LLVM already implements the mangling grammar documented here.

copybara-service bot pushed a commit to abseil/abseil-cpp that referenced this pull request Feb 16, 2024
…ubstitutions

These were described in itanium-cxx-abi/cxx-abi#85 and implemented by LLVM.

PiperOrigin-RevId: 607555558
Change-Id: I9991ac88c1fcf63b25b93d93977a83ca343cdb5d
@dinord
Copy link

dinord commented Mar 29, 2024

Ping.

netkex pushed a commit to netkex/abseil-cpp that referenced this pull request Apr 3, 2024
…ubstitutions

These were described in itanium-cxx-abi/cxx-abi#85 and implemented by LLVM.

PiperOrigin-RevId: 607555558
Change-Id: I9991ac88c1fcf63b25b93d93977a83ca343cdb5d
hubot pushed a commit to gcc-mirror/gcc that referenced this pull request Jan 23, 2025
itanium-cxx-abi/cxx-abi#85 clarifies that
mangling a lambda expression should use 'L' rather than "tl".

gcc/cp/ChangeLog:

	* mangle.cc (write_expression): Update mangling for lambdas.

gcc/testsuite/ChangeLog:

	* g++.dg/cpp2a/lambda-generic-mangle1.C: Update mangling.
	* g++.dg/cpp2a/lambda-generic-mangle1a.C: Likewise.

Signed-off-by: Nathaniel Shead <[email protected]>
hubot pushed a commit to gcc-mirror/gcc that referenced this pull request Jan 25, 2025
This is a step closer to implementing the suggested changes for
itanium-cxx-abi/cxx-abi#85.  Most lambdas
defined within a class should have an extra scope of that class so that
uses across different TUs are properly merged by the linker.  This also
needs to happen during template instantiation.

While I was working on this I found some other cases where the mangling
of lambdas was incorrect and causing issues, notably the testcase
lambda-ctx3.C which currently emits the same mangling for the base class
and member lambdas, causing mysterious assembler errors since r14-9232.

One notable case not handled either here or in the ABI is what is
supposed to happen with such unattached lambdas declared in member
templates; see lambda-uneval22.  I believe that by the C++ standard,
such lambdas should also dedup across TUs, but this isn't currently
implemented, and it's not clear exactly how such lambdas should mangle.

Since this should only affect usage of lambdas in unevaluated contexts
(a C++20 feature) this patch does not add an ABI flag to control this
behaviour.

	PR c++/118245

gcc/cp/ChangeLog:

	* cp-tree.h (LAMBDA_EXPR_EXTRA_SCOPE): Adjust comment.
	* parser.cc (cp_parser_class_head): Start (and do not finish)
	lambda scope for all valid types.
	(cp_parser_class_specifier): Finish lambda scope after parsing
	members instead.
	* pt.cc (instantiate_class_template): Add lambda scoping.

gcc/testsuite/ChangeLog:

	* g++.dg/abi/lambda-ctx3.C: New test.
	* g++.dg/cpp2a/lambda-uneval22.C: New test.
	* g++.dg/cpp2a/lambda-uneval23.C: New test.

Signed-off-by: Nathaniel Shead <[email protected]>
Reviewed-by: Jason Merrill <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mangling updates for lambdas with explicit template parameter lists
3 participants