martong added a comment.

In D66348#1636564 <https://reviews.llvm.org/D66348#1636564>, @shafik wrote:

> I am not enthusiastic about this solution but I need to think about it some 
> more.
>
> We can see that p0624r2 
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0624r2.pdf> added 
> copy assignable lambdas:
>
>   bool f1() {
>       auto x = []{} = {}; auto x2 = x;
>  
>       return x == x2;
>   }
>  
>   bool f2() {
>       auto x = []{} = {};
>       auto xb = []{} = {};
>  
>       return x == xb;
>   }
>
>
> see godbolt <https://godbolt.org/z/e2a9dV>
>
> So I don't think this is a long-term solution, although I don't know what 
> clang is doing to make this work yet.


Hi Shafik, thank you for looking into this and for the links.
I have added two test cases, which demonstrates that the solution will work 
even with copy assignable lambdas.

The reason why this works is that when we import "x2" then there is a 
DeclRefExpr node which points the the lambda class CXXRecordDecl.
And that had been already imported when we imported "x", so it is mapped by 
`MapImported`. This means we just return with the mapped definition of the 
lambda class before the code would reach the part when we skip the lookup.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66348



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to