[clang] [Thread Analysis] Fix a bug in context update in alias-analysis (PR #178952)

Marco Elver via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 31 03:56:24 PST 2026


================
@@ -7434,6 +7434,27 @@ void testPointerAliasEscapeAndReset(Foo *f) {
   ptr->mu.Unlock();
 }
 
+// A function that may do anything to the objects referred to by the inputs.
+void escapeAliasMultiple(void *, void *, void *);
+void testPointerAliasEscapeMultiple(Foo *F)
+{
+    Foo *L;
+    F->mu.Lock(); // expected-note{{mutex acquired here}}
+    Foo *Fp = F;
+    escapeAliasMultiple(&L, &L, &Fp);
+    Fp->mu.Unlock(); // expected-warning{{releasing mutex 'Fp->mu' that was not held}}
+} // expected-warning{{mutex 'F->mu' is still held at the end of function}}
+
+void unlockFooWithEscapablePointer(Foo **Fp) __attribute__((release_capability((*Fp)->mu)));
----------------
melver wrote:

```suggestion
void unlockFooWithEscapablePointer(Foo **Fp) EXCLUSIVE_UNLOCK_FUNCTION((*Fp)->mu);
```

https://github.com/llvm/llvm-project/pull/178952


More information about the cfe-commits mailing list