[clang] Thread Safety Analysis: Support warning on taking address of guarded variables (PR #123063)
Aaron Puchert via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 25 17:32:58 PST 2025
aaronpuchert wrote:
> 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".
GCC [has such an attribute](https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-access-function-attribute), independent of Thread Safety Analysis. But I don't think we have an equivalent.
However, as I wrote above, it's probably the rule and not the exception that pointers passed into a function are dereferenced at some point. So we're probably fine if we always warn. And as @melver pointed out, the experience with reference passing in C++ has been pretty good, and it's probably transferable to pointers.
https://github.com/llvm/llvm-project/pull/123063
More information about the cfe-commits
mailing list