[clang] Thread Safety Analysis: Support warning on obtaining address of guarded variables (PR #123063)
Marco Elver via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 15 07:18:12 PST 2025
melver wrote:
For additional background: I'm trying to work out how to bring -Wthread-safety to the Linux kernel. Since -fexperimental-late-parse-attributes made the feature practical for complex C structs, I started to look at a strategy to enable the feature.
The current strategy is to create an opt-in mechanism (per subsystem), and since the constraints imposed by Wthread-safety already require subtly restructuring most code that would opt-in, I think having Wthread-safety-addressof part of the initial constraints imposed by Wthread-safety would be very helpful.
In converting one subsystem I maintain, I was disappointed that things like `list_add(¬e, &guarded_list)` aren't caught. In general, I believe that the situation is analogous to C++ reference passing, and thus -Wthread-safety-addressof would be the right choice for new C projects.
https://github.com/llvm/llvm-project/pull/123063
More information about the cfe-commits
mailing list