================
@@ -7675,4 +7675,36 @@ 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
+    // pushed for each of the argument below, resulting context
+    // mismatch. The analyzer missed the fact that 'Fp' may no
+    // longer point to the lock. So it does not report an issue at the
+    // 'unlock_Foo' call.
+    f(&L, &L, &Fp);
+    unlock_Foo(Fp); // expected-warning{{releasing mutex 'Fp->mu' that was not 
held}}
+} // expected-warning{{mutex 'F->mu' is still held at the end of function}}
+
+void useContextImmediatelyBeforeStmt(Foo* F)
+{
+    Foo* L;
+    L = F;
+    L->mu.Lock();
+    // Previously, the local-variable-definition-context used for
----------------
melver wrote:

Again, this comment is odd. Describe the issue in the commit message, and move 
a brief comment to the implementation code. But describing the code, or its 
changes, in tests is wrong. The test should simply state "test that X holds" or 
something.

https://github.com/llvm/llvm-project/pull/178952
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to