[clang] [ThreadSafety] Add heuristic for not invalidating out parameters of annotated functions (PR #183640)

Ziqing Luo via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 16 11:18:57 PDT 2026


ziqingluo-90 wrote:

>The alias analysis made it possible to actually start applying -Wthread-safety to more complex code, like the Linux kernel (it's [upstream](https://www.phoronix.com/news/Linux-7.0-Locking) now!).

We have similar internal efforts ongoing!

>False positives due to alias analysis are rare

If I understand correctly, the alias analysis in TSA is essentially to establish equivalence of variables in a definition-chain, which I think is precise. So FP is indeed rare.  Lazy-expansion is correct but not needed IMHO.

>we're locking *C in the context { C = 0 } (a bit strange, as you pointed out, but let's just go with it), then accessing x with *C locked in the context { C = ? }, then unlocking *C in the same context.

This reasoning is correct, but TSA does not behave as we expected. This is because of the pre-state/post-state bug that I'm going to elaborate on in the follow-up PR:https://github.com/llvm/llvm-project/pull/190154.

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


More information about the cfe-commits mailing list