[clang] [Clang] Extend lifetime bound analysis to support assignments (PR #96475)

Haojian Wu via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 11 04:55:05 PDT 2024


hokein wrote:

> We're seeing some -Wdangling-assignment warnings after this change, and they all seem to be false positives so far: https://crbug.com/350808950 It's not a huge deal if there are just a few, but figured it's worth mentioning.

Thanks for the report. That's interesting. Technically it is a dangling assignment. The tricky bit is that the pointer being assigned is in a system header (implementation details of the system macro `A2CW`). 
Clang by default [suppresses diagnostics](https://clang.llvm.org/docs/UsersManual.html#controlling-diagnostics-in-system-headers) in system headers, but we emit this diagnostic on the temporary object (which is in user code), so it is not suppressed.

I ran the diagnostic on the Google internal codebase, and I haven't found false positives so far. The only interesting case is [this issue](https://github.com/llvm/llvm-project/issues/97471), but that is a rare case where we should adjust the code. So, I believe there should not be many cases like this.



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


More information about the cfe-commits mailing list