Implement lambda capture of *this.
struct A {
int d = 10;
auto foo() { return [*this] (auto a) mutable { d+=a; return d; }; }};
auto L = A{}.foo(); // A{}'s lifetime is gone.
// Below is still ok, because *this was captured by value.
assert(L(10) == 20);
assert(L(100) == 120);
I'm not a fan of this representation. Please use Capture_ByCopy to indicate a by-copy capture of *this. It's probably time to clean up DeclAndBits a little. Something like this should work:
struct LLVM_ALIGNAS(4) OpaqueCapturedEntity {}; llvm::PointerIntPair<void*, 2> CapturedEntityAndBits; static OpaqueCapturedEntity StarThis; static OpaqueCapturedEntity VLAType;where the void* is either a Decl* or points to StarThis or VLAType.