Page MenuHomePhabricator

[Clang][WIP] Implement Change scope of lambda trailing-return-type - Take 2
Needs ReviewPublic

Authored by cor3ntin on Apr 24 2022, 2:16 PM.

Details

Summary

This implements P2036R3 with the changes proposed by D2579R0 applied.
That is, explicit, int, and implicit capture become visible
at the start of the parameter head.

This approach is meant to address breakages observed in

https://reviews.llvm.org/D119136.

It is based on D119136 and D124012.

Most of the code is similar, except that Clang
will do a tentative parse action to try to find a mutable keyword
after the parameter list, and inject the explicit captures in the call
operator context before parsing the template parameter list.

If the code is not-well balanced, there is no degadation in diagnostics,
as we simply fallback to assuming the lambda is not mutable.

In lambda template parameters, naming a capture is still ill-formed.

Diff Detail

Event Timeline

cor3ntin created this revision.Apr 24 2022, 2:16 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 24 2022, 2:16 PM
cor3ntin requested review of this revision.Apr 24 2022, 2:16 PM
Herald added a project: Restricted Project. · View Herald Transcript
cor3ntin retitled this revision from [Clang][WIP] Implement Change scope of lambda trailing-return-type to [Clang][WIP] Implement Change scope of lambda trailing-return-type - Take 2.Apr 24 2022, 2:18 PM
cor3ntin edited reviewers, added: rsmith, aaron.ballman, erichkeane, MaskRay; removed: jdoerfert.

Hey folks.
I do not intend this to be merge but if there is anyway this can be battle tested against internal codebases, i think it could be helpful to help guide how WG21 proceed with this feature.
Here is a paper listing the failures encountered when we merged the previous attempt, and offers a more holistic mitigation - by looking a head for the mutable keyword https://isocpp.org/files/papers/D2579R0.pdf

Sorry again for the troubles the previous attempt caused but I'm glad we caught this problem sooner rather than later...

note to self.
@aaron.ballman noticed this patch doesn't handle leading attributes correctly

constexpr int asp = 5;
[=] [[gnu::regparm(asp)]] () {};