[clang] [Clang] FunctionEffect analysis was missing a CXXBindTemporaryExpr's implicit call to a destructor. (PR #166110)

via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 3 04:52:35 PST 2025


Sirraide wrote:

> TODO: Consider `auto x = []() { /* lambda body */ };` which becomes `VarDecl` holding `ExprWithCleanups` holding `CXXBindTemporaryExpr`.

Visiting `CXXBindTemporaryExpr` looks like the right approach. Speaking of lambdas, while looking into this, I also found some more issues with lambda captures I think:

```c++
struct S { ~S(); };
void f() {
    S s;
    [&]() [[clang::nonblocking]] {
        [s]{ auto x = &s; }();
        [=]{ auto x = &s; }();
    }();
}
```
These are all by-value captures, meaning that we need to call `~S()` after evaluating the two inner lambdas, but we don't seem to diagnose that at the moment (https://godbolt.org/z/815hj1bKM). This might well be a different issue though.

> We currently look for a destructor on a VarDecl but I suspect that becomes a redundant check with this change. Need to verify.

That might no longer be necessary yeah.

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


More information about the cfe-commits mailing list