[clang] [Thread Safety Analysis] Fix a bug of context saving in alias-analysis (PR #178825)
Marco Elver via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 30 11:49:36 PST 2026
================
@@ -7675,4 +7675,25 @@ void testLoopConditionalReassignment(Foo *f1, Foo *f2, bool cond) {
f1->data = 42;
ptr->mu.Unlock(); // expected-warning{{releasing mutex 'ptr->mu' that was not held}}
} // expected-warning{{mutex 'f1->mu' is still held at the end of function}}
+
+
+void unlock_Foo(Foo **Fp) __attribute__((release_capability((*Fp)->mu)));
+// A function that may do anything to the objects referred to by the inputs:
+void f(void *, void *, void *);
+
+void saveContexBug(Foo *F)
+{
+ Foo *L;
+ L = F;
+ L->mu.Lock(); // expected-note{{mutex acquired here}}
+ Foo ** Fp = &L;
+ // Previously, a local-variable-definition-context was created and
----------------
melver wrote:
This comment seems pointless once the bug is fixed. The commit message should contain it, or the actual analysis code in ThreadSafety.cpp that you've changed should have a brief comment of why it does what it does. But don't refer to "previously", because we describe the current state of the code. The commit message contains the history.
https://github.com/llvm/llvm-project/pull/178825
More information about the cfe-commits
mailing list