-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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
- Loading branch information
Showing
9 changed files
with
158 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
|
||
// This test case came up in the review of | ||
// https://reviews.llvm.org/D159126 | ||
// when transforming `this` within a | ||
// requires expression, we need to make sure | ||
// the type of this (and its qualifiers) is respected. | ||
namespace D159126 { | ||
|
||
template <class _Tp> | ||
concept __member_begin = requires(_Tp __t) { | ||
__t.begin(); | ||
}; | ||
|
||
struct { | ||
template <class _Tp> | ||
requires __member_begin<_Tp> | ||
auto operator()(_Tp &&) {} | ||
} inline begin; | ||
|
||
template <class> | ||
concept range = requires { | ||
begin; | ||
}; | ||
|
||
template <class _Tp> | ||
concept __can_compare_begin = requires(_Tp __t) { | ||
begin(__t); | ||
}; | ||
|
||
struct { | ||
template <__can_compare_begin _Tp> void operator()(_Tp &&); | ||
} empty; | ||
|
||
template <range _Rp> struct owning_view { | ||
_Rp __r_; | ||
public: | ||
void empty() const requires requires { empty(__r_); }; | ||
}; | ||
|
||
template <class T> | ||
concept HasEmpty = requires(T t) { | ||
t.empty(); | ||
}; | ||
|
||
struct ComparableIters { | ||
void begin(); | ||
}; | ||
|
||
static_assert(HasEmpty<owning_view<ComparableIters&>>); | ||
static_assert(HasEmpty<owning_view<ComparableIters&&>>); | ||
static_assert(!HasEmpty<owning_view<const ComparableIters&>>); | ||
static_assert(!HasEmpty<owning_view<const ComparableIters&&>>); | ||
|
||
} |