[clang] Thread Safety Analysis: Improved pointer handling (PR #127396)
Aaron Puchert via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 25 16:56:48 PST 2025
================
@@ -142,9 +145,19 @@ int main(void) {
(void)(get_value(b_) == 1);
mutex_unlock(foo_.mu_);
+ a_ = 0; // expected-warning{{writing variable 'a_' requires holding mutex 'foo_.mu_'}}
+ __WRITE_ONCE(a_, 0); // expected-warning{{writing variable 'a_' requires holding mutex 'foo_.mu_'}}
+ (void)(a_ == 0); // expected-warning{{reading variable 'a_' requires holding mutex 'foo_.mu_'}}
+ (void)(__READ_ONCE(a_) == 0); // expected-warning{{reading variable 'a_' requires holding mutex 'foo_.mu_'}}
+ (void)(*b_ == 0); // expected-warning{{reading the value pointed to by 'b_' requires holding mutex 'foo_.mu_'}}
----------------
aaronpuchert wrote:
For completeness, maybe also write `b_`?
https://github.com/llvm/llvm-project/pull/127396
More information about the cfe-commits
mailing list