aboutsummaryrefslogtreecommitdiff
path: root/clang/www
diff options
context:
space:
mode:
authorCorentin Jabot <corentinjabot@gmail.com>2022-02-06 22:58:43 +0100
committerCorentin Jabot <corentinjabot@gmail.com>2022-04-13 23:07:39 +0200
commitc729d5be781a8e80137c11ab28aa14d9ace148db (patch)
treeaa11bfd9a14c2fc5a803e132974733f247cf5a6b /clang/www
parent03b807d3f2999888bbe395945987af06f201c142 (diff)
downloadllvm-c729d5be781a8e80137c11ab28aa14d9ace148db.zip
llvm-c729d5be781a8e80137c11ab28aa14d9ace148db.tar.gz
llvm-c729d5be781a8e80137c11ab28aa14d9ace148db.tar.bz2
[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 d8d793f29b4 Reviewed By: aaron.ballman, #clang-language-wg, ChuanqiXu Differential Revision: https://reviews.llvm.org/D119136
Diffstat (limited to 'clang/www')
-rwxr-xr-xclang/www/cxx_status.html2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 5501d07..44dfcbe 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -1356,7 +1356,7 @@ C++20, informally referred to as C++2b.</p>
<tr>
<td>Change scope of lambda trailing-return-type</td>
<td><a href="https://wg21.link/P2036R3">P2036R3</a></td>
- <td class="none" align="center">No</td>
+ <td class="unreleased" align="center">Clang 15</td>
</tr>
<tr>
<td>Multidimensional subscript operator</td>