glandium wrote:

Before this change the following (reduced) code didn't emit a warning, but now 
does:
```
class __attribute__((capability("mutex"))) StaticMutex {
 public:
  void Lock() __attribute__((exclusive_lock_function()))  { /* unimplemented */ 
}

  void Unlock() __attribute__((unlock_function())) { /* unimplemented */ }

  void AssertCurrentThreadOwns() __attribute__((assert_capability(this))) {
  }
};

class __attribute__((scoped_lockable)) StaticMutexAutoLock {
 public:
  explicit StaticMutexAutoLock(StaticMutex& aLock) 
__attribute__((exclusive_lock_function(aLock))) { /* unimplemented */ }

  ~StaticMutexAutoLock(void) __attribute__((unlock_function())) { /* 
unimplemented */ }
};

class __attribute__((scoped_lockable)) StaticMutexAutoUnlock {
 public:
  explicit StaticMutexAutoUnlock(StaticMutex& aLock) 
__attribute__((release_capability(aLock))) { /* unimplemented */ }

  ~StaticMutexAutoUnlock() __attribute__((release_capability())) { /* 
unimplemented */ }
};

StaticMutex sMutex;

bool InitPreferredSampleRate() {
  sMutex.AssertCurrentThreadOwns();
  {
    StaticMutexAutoUnlock unlock(sMutex);
  }
  return true;
}
```

Now it says `warning: mutex 'sMutex' is still held at the end of function 
[-Wthread-safety-analysis]` because apparently it's not "propagating" from the 
attribute on AssertCurrentThreadOwns?

https://github.com/llvm/llvm-project/pull/105526
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to