Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13115807
D9937.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
D9937.diff
View Options
diff --git a/src/sync.h b/src/sync.h
--- a/src/sync.h
+++ b/src/sync.h
@@ -105,6 +105,13 @@
}
using UniqueLock = std::unique_lock<PARENT>;
+#ifdef __clang__
+ //! For negative capabilities in the Clang Thread Safety Analysis.
+ //! A negative requirement uses the EXCLUSIVE_LOCKS_REQUIRED attribute, in
+ //! conjunction with the ! operator, to indicate that a mutex should not be
+ //! held.
+ const AnnotatedMixin &operator!() const { return *this; }
+#endif // __clang__
};
/**
diff --git a/src/threadsafety.h b/src/threadsafety.h
--- a/src/threadsafety.h
+++ b/src/threadsafety.h
@@ -61,7 +61,16 @@
// StdMutex provides an annotated version of std::mutex for us,
// and should only be used when sync.h Mutex/LOCK/etc are not usable.
-class LOCKABLE StdMutex : public std::mutex {};
+class LOCKABLE StdMutex : public std::mutex {
+public:
+#ifdef __clang__
+ //! For negative capabilities in the Clang Thread Safety Analysis.
+ //! A negative requirement uses the EXCLUSIVE_LOCKS_REQUIRED attribute, in
+ //! conjunction with the ! operator, to indicate that a mutex should not be
+ //! held.
+ const StdMutex &operator!() const { return *this; }
+#endif // __clang__
+};
// StdLockGuard provides an annotated version of std::lock_guard for us,
// and should only be used when sync.h Mutex/LOCK/etc are not usable.
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 1, 12:09 (4 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5184507
Default Alt Text
D9937.diff (1 KB)
Attached To
D9937: Add means to handle negative capabilities in thread safety annotations
Event Timeline
Log In to Comment