[clang] [clang][analyzer] Correctly handle lambda-converted function pointers (PR #144906)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 19 17:31:50 PDT 2025


flovent wrote:

> The same occurs with assigning to `auto`: https://godbolt.org/z/nofG6cehf
> 
> Will this also be handled by this change?

If you mean directly calling this lambda, analyzer can already analyze `operator()` correctly before this patch, because neither `CXXConversionDecl` and `__invoke` is used here.

This patch fix the situation like this: https://godbolt.org/z/4YWPP6939
```
void f()
{
    auto f = []() { return 0; };
    int (*ptr)() = f;
    1 / ptr();
}
```
lambda `f` should be called and produce divzero.

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


More information about the cfe-commits mailing list