Revision tags: llvmorg-21-init, llvmorg-19.1.7, llvmorg-19.1.6 |
|
#
154c7c0b |
| 04-Dec-2024 |
Younan Zhang <zyn7109@gmail.com> |
[Clang] Don't add top-level const qualifiers to captured function types (#118050)
This aligns with the logic in `TreeTransform::RebuildQualifiedType()` where we refrain from adding const qualifiers
[Clang] Don't add top-level const qualifiers to captured function types (#118050)
This aligns with the logic in `TreeTransform::RebuildQualifiedType()` where we refrain from adding const qualifiers to function types. Previously, we seemed to overlook this edge case when copy-capturing a variable that is of function type within a const-qualified lambda.
This issue also reveals other related problems as in incorrect type printout and a suspicious implementation in DeduceTemplateArguments. I decide to leave them in follow-up work.
Fixes #84961
show more ...
|
Revision tags: llvmorg-19.1.5 |
|
#
9ea993f9 |
| 03-Dec-2024 |
Younan Zhang <zyn7109@gmail.com> |
[Clang] Recover GLTemplateParameterList for generic lambdas in RebuildLambdaScopeInfo (#118176)
The NTTP argument appearing inside a trailing return type of a generic lambda would have us check for
[Clang] Recover GLTemplateParameterList for generic lambdas in RebuildLambdaScopeInfo (#118176)
The NTTP argument appearing inside a trailing return type of a generic lambda would have us check for potential lambda captures, where the function needs GLTemplateParameterList of the current LSI to tell whether the lambda is generic.
The lambda scope in this context is rebuilt by the LambdaScopeForCallOperatorInstantiationRAII when substituting the lambda operator during template argument deduction. Thus, I think the template parameter list should be preserved in the rebuilding process, as it seems otherwise innocuous to me.
Fixes #115931
show more ...
|
Revision tags: llvmorg-19.1.4, llvmorg-19.1.3, llvmorg-19.1.2 |
|
#
3733b0cf |
| 15-Oct-2024 |
Younan Zhang <zyn7109@gmail.com> |
[Clang] Fix a DeclContext mismatch when parsing nested lambda parameters (#112177)
When parsing its function parameters, we don't change the CurContext to
the lambda's function declaration. However
[Clang] Fix a DeclContext mismatch when parsing nested lambda parameters (#112177)
When parsing its function parameters, we don't change the CurContext to
the lambda's function declaration. However,
CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures() has not
yet adapted to such behavior when nested lambdas come into play.
Consider the following case,
struct Foo {};
template <int, Foo f> struct Arr {};
constexpr void foo() {
constexpr Foo F;
[&]<int I>() {
[&](Arr<I, F>) {};
}.template operator()<42>();
}
As per [basic.def.odr]p5.2, the use of F constitutes an ODR-use. And
per [basic.def.odr]p10, F should be ODR-usable in that interleaving
scope.
We failed to accept the case because the call to tryCaptureVariable()
in getStackIndexOfNearestEnclosingCaptureCapableLambda() suggested
that F is needlessly captureable. That was due to a missed handling
for AfterParameterList in FunctionScopeIndexToStopAt, where it still
presumed DC and LSI matched.
Fixes #47400
Fixes #90896
show more ...
|
Revision tags: llvmorg-19.1.1, llvmorg-19.1.0, llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init, llvmorg-18.1.8, llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4 |
|
#
3ed9e9e3 |
| 29-Aug-2023 |
Corentin Jabot <corentinjabot@gmail.com> |
[Clang] Add captures to the instantiation scope of lambda call operators
Like concepts checking, a trailing return type of a lambda in a dependent context may refer to captures in which case they ma
[Clang] Add captures to the instantiation scope of lambda call operators
Like concepts checking, a trailing return type of a lambda in a dependent context may refer to captures in which case they may need to be rebuilt, so the map of local decl should include captures.
This patch reveal a pre-existing issue. `this` is always recomputed by TreeTransform.
`*this` (like all captures) only become `const` after the parameter list.
However, if try to recompute the value of `this` (in a parameter) during template instantiation while determining the type of the call operator, we will determine it to be const (unless the lambda is mutable).
There is no good way to know at that point that we are in a parameter or not, the easiest/best solution is to transform the type of this.
Note that doing so break a handful of HLSL tests. So this is a prototype at this point.
Fixes #65067 Fixes #63675
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D159126
show more ...
|
#
98062d8f |
| 07-Sep-2023 |
Corentin Jabot <corentinjabot@gmail.com> |
Revert "[Clang] Add captures to the instantiation scope of lambda call operators"
The change causes some libcxx regressions
This reverts commit eaf725bc9371a6699902d67d97662caaa3332799.
|
#
eaf725bc |
| 29-Aug-2023 |
Corentin Jabot <corentinjabot@gmail.com> |
[Clang] Add captures to the instantiation scope of lambda call operators
Like concepts checking, a trailing return type of a lambda in a dependent context may refer to captures in which case they ma
[Clang] Add captures to the instantiation scope of lambda call operators
Like concepts checking, a trailing return type of a lambda in a dependent context may refer to captures in which case they may need to be rebuilt, so the map of local decl should include captures.
This patch reveal a pre-existing issue. `this` is always recomputed by TreeTransform.
`*this` (like all captures) only become `const` after the parameter list.
However, if try to recompute the value of `this` (in a parameter) during template instantiation while determining the type of the call operator, we will determine it to be const (unless the lambda is mutable).
There is no good way to know at that point that we are in a parameter or not, the easiest/best solution is to transform the type of this.
Note that doing so break a handful of HLSL tests. So this is a prototype at this point.
Fixes #65067 Fixes #63675
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D159126
show more ...
|
Revision tags: llvmorg-17.0.0-rc3 |
|
#
158f4f30 |
| 21-Aug-2023 |
Corentin Jabot <corentinjabot@gmail.com> |
[Clang] Do not change the type of captured vars when checking lambda constraints
When checking the constraint of a lambda, we need to respect the constness of the call operator when establishing the
[Clang] Do not change the type of captured vars when checking lambda constraints
When checking the constraint of a lambda, we need to respect the constness of the call operator when establishing the type of capture variables.
In D124351, this was done by adding const to the captured variable... However, that would change the type of the variable outside of the scope of the lambda, which is clearly not the desired outcome.
Instead, to ensure const-correctness, we need to populate a LambdaScopeInfo with the capture variables before checking the constraints of a generic lambda.
There is no changelog as I'd like to tentatively propose we backport this change to RC3 as it is a regression introduced in the Clang 17 cycle.
Fixes #61267
Reviewed By: aaron.ballman, #clang-language-wg
Differential Revision: https://reviews.llvm.org/D158433
show more ...
|
Revision tags: llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init, llvmorg-16.0.6, llvmorg-16.0.5, llvmorg-16.0.4, llvmorg-16.0.3 |
|
#
ba15d186 |
| 30-Apr-2023 |
Mark de Wever <koraq@xs4all.nl> |
[clang] Use -std=c++23 instead of -std=c++2b
During the ISO C++ Committee meeting plenary session the C++23 Standard has been voted as technical complete.
This updates the reference to c++2b to c++
[clang] Use -std=c++23 instead of -std=c++2b
During the ISO C++ Committee meeting plenary session the C++23 Standard has been voted as technical complete.
This updates the reference to c++2b to c++23 and updates the __cplusplus macro.
Drive-by fixes c++1z -> c++17 and c++2a -> c++20 when seen.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D149553
show more ...
|
Revision tags: llvmorg-16.0.2, llvmorg-16.0.1 |
|
#
4444eeb7 |
| 28-Mar-2023 |
Erich Keane <erich.keane@intel.com> |
Improve requirement clause limitation on non templated function
The current implementation 6da3d66f03f9162ef341cc67218be40e22fe9808 got a few things wrong, particularly that a template, or definiti
Improve requirement clause limitation on non templated function
The current implementation 6da3d66f03f9162ef341cc67218be40e22fe9808 got a few things wrong, particularly that a template, or definition or member in a templated entity is required to be allowed to have a trailing requires clause.
This patch corrects this, as reproted by #61748
Fixes: #61748
Differential Revision: https://reviews.llvm.org/D147070
show more ...
|
Revision tags: llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2, llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7, llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, working, llvmorg-15.0.2, llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3, llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init, llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4, llvmorg-14.0.3, llvmorg-14.0.2, llvmorg-14.0.1, llvmorg-14.0.0, llvmorg-14.0.0-rc4, llvmorg-14.0.0-rc3, llvmorg-14.0.0-rc2, llvmorg-14.0.0-rc1 |
|
#
93d7002d |
| 06-Feb-2022 |
Corentin Jabot <corentinjabot@gmail.com> |
[Clang] Implement Change scope of lambda trailing-return-type
This implements P2036R3 and P2579R0. That is, explicit, int, and implicit capture become visible at the start of the parameter head.
Re
[Clang] Implement Change scope of lambda trailing-return-type
This implements P2036R3 and P2579R0. That is, explicit, int, and implicit capture become visible at the start of the parameter head.
Reviewed By: aaron.ballman, rupprecht, shafik
Differential Revision: https://reviews.llvm.org/D124351
show more ...
|
#
d708a186 |
| 06-Feb-2022 |
Corentin Jabot <corentinjabot@gmail.com> |
[Clang] Implement Change scope of lambda trailing-return-type
This implements P2036R3 and P2579R0. That is, explicit, int, and implicit capture become visible at the start of the parameter head.
Re
[Clang] Implement Change scope of lambda trailing-return-type
This implements P2036R3 and P2579R0. That is, explicit, int, and implicit capture become visible at the start of the parameter head.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D124351
show more ...
|
#
0f5dbfd2 |
| 20-Apr-2022 |
Fangrui Song <i@maskray.me> |
Revert D123909 "[Clang] Use of decltype(capture) in parameter-declaration-clause"
This reverts commit daa6d7b250edb81ffef7770a71049d7af211698b.
It breaks valid code like https://reviews.llvm.org/D1
Revert D123909 "[Clang] Use of decltype(capture) in parameter-declaration-clause"
This reverts commit daa6d7b250edb81ffef7770a71049d7af211698b.
It breaks valid code like https://reviews.llvm.org/D123909#3461716
show more ...
|
#
69dd89fd |
| 19-Apr-2022 |
Corentin Jabot <corentinjabot@gmail.com> |
[Clang] Fix references to captured variables in dependant context.
D119136 changed how captures are handled in a lambda call operator declaration, but did not properly handled dependant context, whi
[Clang] Fix references to captured variables in dependant context.
D119136 changed how captures are handled in a lambda call operator declaration, but did not properly handled dependant context, which led to crash when refering to init-captures in a trailing return type.
We fix that bug by making transformations more symetric with parsing, ie. we first create the call operator, then transform the capture, then compute the type of the lambda call operaror.
This ensures captures exist and have the right type when we parse a trailing requires-clause / return type.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D124012
show more ...
|
#
daa6d7b2 |
| 17-Apr-2022 |
Corentin Jabot <corentinjabot@gmail.com> |
[Clang] Use of decltype(capture) in parameter-declaration-clause
Partially implement the proposed resolution to CWG2569.
D119136 broke some libstdc++ code, as P2036R3, implemented as a DR to C++11
[Clang] Use of decltype(capture) in parameter-declaration-clause
Partially implement the proposed resolution to CWG2569.
D119136 broke some libstdc++ code, as P2036R3, implemented as a DR to C++11 made ill-formed some previously valid and innocuous code.
We resolve this issue to allow decltype(x) - but not decltype((x) to appear in the parameter list of a lambda that capture x by copy.
Unlike CWG2569, we do not extend that special treatment to sizeof/noexcept yet, as the resolution has not been approved yet and keeping the review small allows a quicker fix of impacted code.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D123909
show more ...
|
#
04000c2f |
| 06-Feb-2022 |
Corentin Jabot <corentinjabot@gmail.com> |
[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 mu
[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 capture 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).
Reviewed By: aaron.ballman, #clang-language-wg, ChuanqiXu
Differential Revision: https://reviews.llvm.org/D119136
show more ...
|
#
c729d5be |
| 06-Feb-2022 |
Corentin Jabot <corentinjabot@gmail.com> |
[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 mu
[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
show more ...
|
#
adff142d |
| 06-Feb-2022 |
Corentin Jabot <corentinjabot@gmail.com> |
[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 mu
[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 capture 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).
Reviewed By: aaron.ballman, #clang-language-wg, ChuanqiXu
Differential Revision: https://reviews.llvm.org/D119136
show more ...
|