[clang] Thread Safety Analysis: Support warning on taking address of guarded variables (PR #123063)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 19 12:00:52 PST 2025
aoates wrote:
I'm very excited about this, as I have wanted it for many years for my C codebase, and TSA is not super useful in C without this!
One thought --- you could consider an attribute that could be put on pointer arguments to functions that says "yes, I dereference this and read or write it". In a codebase that otherwise would have many false positives, you could annotate at least core data structures without having to turn it on for all address-of operations.
E.g
```void hashtable_insert(htbl_t* WRITES_POINTER table, ...)```
In the C codebase I desperately want this for, an annotation like that sprinkled in a couple key places would get you 80% of the benefit with much lower risk of false positives.
https://github.com/llvm/llvm-project/pull/123063
More information about the cfe-commits
mailing list