[clang] [Sema] Diagnose use of if/else-if condition variable inside else-if/else branch(s) (PR #156436)

via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 2 07:35:14 PDT 2025


Alcaro wrote:

Yes, std::expected would be a false positive. But how would you tell apart std::expected, where a falsey object still contains something usable, from std::unique_ptr, where it does not?

One option would be simply ignore that - this warning applies to raw pointers only, not even integers. It can always be expanded later, if we can think of how.

> I think we should just straight-up error on it (or at least make it a warning that defaults to an error)

I wouldn't get my hopes up, not until [forgetting a return statement](https://godbolt.org/z/nKooafrGK) errors by default.

Though I do agree both _should_ error by default.

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


More information about the cfe-commits mailing list