[PATCH] D124351: [Clang][WIP] Implement Change scope of lambda trailing-return-type - Take 2

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 5 06:17:19 PST 2022


erichkeane added a comment.

In D124351#3950805 <https://reviews.llvm.org/D124351#3950805>, @cor3ntin wrote:

> Rebase. This is still a bit rough, I have a few tests to fix
> and some dead code to remove.
>
> ---
>
> @erichkeane  I wouldn't mind picking your brain on this.
> Consider:
>
>   template <typename T>
>   void dependent_init_capture(T x = 0) {
>     [y = x] () requires (decltype(y){1}) {
>       return y;
>     }();
>   }
>   
>   void test_dependent() {
>     dependent_init_capture(0);
>   }
>
> This used to ""work"" in the previous iteration of the patch,
> but with the late concept checking it seems more involved.
>
> My understanding so far is that in `CheckFunctionConstraints` 
> we can't find an instanciated declaration of `y` (so it asserts in `LocalInstantiationScope::findInstantiationOf`).
>
> I'm not 100% sure of what's the correct approach here would be. 
> My guess is that we might need to retransform the captures  in the instanciation scope used 
> for constraint checking? 
> I'm not actually sure whether an instanciation of the lambda does exist at that point in some other scope, 
> though. Ideally we would not instannciate lambdas more times than needed.
>
> Another issue is that there is no way to walk back from a call expression to a lambda expression,
> so we might need to add that.

We shouldnn't -re-transform' the capture, but we need to make sure we get it into the current scope.  I haven't looked at lambda instantiation much, so I don't know where that 'y' usually ends up?  Can you do a run of it when it WORKS and see where it finds that when calling `FindInstantiatedDecl`.  I'm guessing we are currently counting on that coming from a PARENT of the `CurrentInstantiationScope` (one of the `Outer`s), which we can no longer count on.

`FindInstantiatedDecl` needs some unfortunate amount of work around lambdas, I found similar issues when working on https://reviews.llvm.org/D138148 which I need to get back to when I re-start work next year.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124351/new/

https://reviews.llvm.org/D124351



More information about the cfe-commits mailing list