File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,12 @@ class LOCKABLE AnnotatedMixin : public PARENT
103103 }
104104
105105 using UniqueLock = std::unique_lock<PARENT>;
106+ #ifdef __clang__
107+ // ! For negative capabilities in the Clang Thread Safety Analysis.
108+ // ! A negative requirement uses the EXCLUSIVE_LOCKS_REQUIRED attribute, in conjunction
109+ // ! with the ! operator, to indicate that a mutex should not be held.
110+ const AnnotatedMixin& operator !() const { return *this ; }
111+ #endif // __clang__
106112};
107113
108114/* *
Original file line number Diff line number Diff line change 6060// and should only be used when sync.h Mutex/LOCK/etc are not usable.
6161class LOCKABLE StdMutex : public std::mutex
6262{
63+ public:
64+ #ifdef __clang__
65+ // ! For negative capabilities in the Clang Thread Safety Analysis.
66+ // ! A negative requirement uses the EXCLUSIVE_LOCKS_REQUIRED attribute, in conjunction
67+ // ! with the ! operator, to indicate that a mutex should not be held.
68+ const StdMutex& operator !() const { return *this ; }
69+ #endif // __clang__
6370};
6471
6572// StdLockGuard provides an annotated version of std::lock_guard for us,
You can’t perform that action at this time.
0 commit comments