[clang] [Clang][Sema]: Diagnose lambda to bool implicit casts (PR #83152)

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 29 17:39:42 PST 2024


MaskRay wrote:

Created #83497 as a follow-up to suppress the diagnostic for certain template instantiation uses.

I made one change to unblock our internal users
```
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpointer-bool-conversion"
#endif
    // functor_ may be a lambda, which is convertible to bool, leading to a
    // -Wpointer-bool-conversion warning because the value is always true.
    return functor_ == nullptr;
#ifdef __clang__
#pragma clang diagnostic pop
#endif
```

and then (when I saw another instance of wrapping a callable object) realized we probably should suppress the diagnostic for instantiation. This is similar to how we suppress the diagnostic for instantiations for -Wtautological-compare

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


More information about the cfe-commits mailing list