[clang] [Clang][Sema] Fix a crash in lambda instantiation (PR #85565)

via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 18 06:22:07 PDT 2024


================
@@ -13714,6 +13714,12 @@ TreeTransform<Derived>::TransformLambdaExpr(LambdaExpr *E) {
 
     // Capturing 'this' is trivial.
     if (C->capturesThis()) {
+      // We need ThisType when build capture in CheckCXXThisCapture.
----------------
Sirraide wrote:

```suggestion
      // If this is a lambda that is part of a default member initialiser
      // and which we're instantiating outside the class that 'this' is 
      // supposed to refer to, adjust the type of 'this' accordingly.
      //
      // Otherwise, leave the type of 'this' as-is.
```
This still only describes *what* we’re doing below, not *why*; what I meant was that we should point out that the reason why we’re pushing a `this` scope here is because we may not be inside the class that `this` is supposed to refer to here; I’d suggest something like this perhaps.

https://github.com/llvm/llvm-project/pull/85565


More information about the cfe-commits mailing list