llvm-project/clang/www
Corentin Jabot c729d5be78 [clang] Implement Change scope of lambda trailing-return-type
Implement P2036R3.

Captured variables by copy (explicitely or not), are deduced
correctly at the point we know whether the lambda is mutable,
and ill-formed before that.

Up until now, the entire lambda declaration up to the start
of the body would  be parsed in the parent scope, such that
captures would not be available to look up.

The scoping is changed to have an outer lambda scope,
followed by the lambda prototype and body.

The lambda scope is necessary because there may be a template scope
between the start of the lambda (to which we want to attach
the captured variable) and the prototype scope.

We also need to introduce a declaration context to attach the captured
variable to (and several parts of clang assume captures are handled from
the call operator context), before we know the type of the call operator.

The order of operations is as follow:

* Parse the init capture in the lambda's parent scope
* Introduce a lambda scope
* Create the lambda class and call operator
* Add the init captures to the call operator context and the lambda scope.
  But the variables are not capured yet (because we don't know their type).
  Instead, explicit  captures are stored in a temporary map that
  conserves the order of capture (for the purpose of having a stable order in the ast dumps).

* A flag is set on LambdaScopeInfo to indicate that we have not yet injected the captures.

* The parameters are parsed (in the parent context, as lambda mangling recurses in the parent context,
  we couldn't mangle a lambda that is attached to the context of a lambda whose type is not yet known).

* The lambda qualifiers are parsed, at this point,
  we can switch (for the second time) inside the lambda context,
  unset the flag indicating that we have not parsed the lambda qualifiers,
  record the lambda is mutable and capture the explicit variables.

* We can parse the rest of the lambda type, transform the lambda and call operator's types and also
  transform the call operator to a template function decl where necessary.

At this point, both captures and parameters can be injected in the body's scope.
When trying to capture an implicit variable, if we are before the qualifiers of a lambda,
we need to remember that the variables are still in the parent's context (rather than in the call operator's).

This is a recommit of adff142dc2 after a fix in d8d793f29b

Reviewed By: aaron.ballman, #clang-language-wg, ChuanqiXu

Differential Revision: https://reviews.llvm.org/D119136
2022-04-13 23:07:39 +02:00
..
analyzer resolve typo in the manual. 2022-04-01 03:15:17 +05:30
demo Replace links to archived mailing lists by links to Discourse forums 2022-03-23 10:10:20 -04:00
OpenProjects.html
UniversalDriver.html
builtins.py
c_status.html Update the C and C++ status pages now that Clang 14 is out 2022-03-23 07:59:52 -04:00
carbon-compile.png
clang_video-05-25-2007.html
clang_video-07-25-2007.html
compatibility.html clang: Switch C compilations to C17 by default. 2020-03-02 09:39:26 -08:00
content.css
cxx_compatibility.html
cxx_dr_status.html [Clang] CWG 1394: Incomplete types as parameters of deleted functions 2022-04-12 11:10:10 +08:00
cxx_status.html [clang] Implement Change scope of lambda trailing-return-type 2022-04-13 23:07:39 +02:00
diagnostics.html
favicon.ico
feature-compile1.png
feature-compile2.png
feature-memory1.png
features.html remove outdated comparison with other open-source c++ compilers 2020-02-11 00:05:16 -07:00
get_involved.html Update Bug report URL to Github Issues 2022-01-06 17:33:25 +08:00
get_started.html Update Bug report URL to Github Issues 2022-01-06 17:33:25 +08:00
hacking.html [Branch-Rename] Fix some links 2021-02-01 16:43:21 +05:30
index.html remove outdated comparison with other open-source c++ compilers 2020-02-11 00:05:16 -07:00
libstdc++4.4-clang0x.patch
libstdc++4.6-clang11.patch
libstdc++4.7-clang11.patch
make_cxx_dr_status [clang][www] Port make_cxx_dr_status script to Python3 2022-02-22 15:47:43 +01:00
menu.css
menu.html.incl Replace links to archived mailing lists by links to Discourse forums 2022-03-23 10:10:20 -04:00
related.html [NFC] Inclusive language: Remove instances of master in URLs 2021-11-05 08:48:41 -05:00
robots.txt