[clang] 30fad6a - Thread safety analysis: Implement MutexLocker factory functions in documentation
Aaron Puchert via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 19 08:20:10 PST 2024
Author: Aaron Puchert
Date: 2024-11-19T17:19:35+01:00
New Revision: 30fad6a97611ac397bdaa429730851f53752d013
URL: https://github.com/llvm/llvm-project/commit/30fad6a97611ac397bdaa429730851f53752d013
DIFF: https://github.com/llvm/llvm-project/commit/30fad6a97611ac397bdaa429730851f53752d013.diff
LOG: Thread safety analysis: Implement MutexLocker factory functions in documentation
We skipped adding definitions in 54bfd0484615 because we'd emit false
positive warnings on the closing braces. But these have been fixed in
commit e64ef634bbd9.
Added:
Modified:
clang/docs/ThreadSafetyAnalysis.rst
Removed:
################################################################################
diff --git a/clang/docs/ThreadSafetyAnalysis.rst b/clang/docs/ThreadSafetyAnalysis.rst
index cc4089b97b4923..f6517afc3bfc2a 100644
--- a/clang/docs/ThreadSafetyAnalysis.rst
+++ b/clang/docs/ThreadSafetyAnalysis.rst
@@ -933,11 +933,25 @@ implementation.
MutexLocker(Mutex *mu, defer_lock_t) EXCLUDES(mu) : mut(mu), locked(false) {}
// Same as constructors, but without tag types. (Requires C++17 copy elision.)
- static MutexLocker Lock(Mutex *mu) ACQUIRE(mu);
- static MutexLocker Adopt(Mutex *mu) REQUIRES(mu);
- static MutexLocker ReaderLock(Mutex *mu) ACQUIRE_SHARED(mu);
- static MutexLocker AdoptReaderLock(Mutex *mu) REQUIRES_SHARED(mu);
- static MutexLocker DeferLock(Mutex *mu) EXCLUDES(mu);
+ static MutexLocker Lock(Mutex *mu) ACQUIRE(mu) {
+ return MutexLocker(mu);
+ }
+
+ static MutexLocker Adopt(Mutex *mu) REQUIRES(mu) {
+ return MutexLocker(mu, adopt_lock);
+ }
+
+ static MutexLocker ReaderLock(Mutex *mu) ACQUIRE_SHARED(mu) {
+ return MutexLocker(mu, shared_lock);
+ }
+
+ static MutexLocker AdoptReaderLock(Mutex *mu) REQUIRES_SHARED(mu) {
+ return MutexLocker(mu, adopt_lock, shared_lock);
+ }
+
+ static MutexLocker DeferLock(Mutex *mu) EXCLUDES(mu) {
+ return MutexLocker(mu, defer_lock);
+ }
// Release *this and all associated mutexes, if they are still held.
// There is no warning if the scope was already unlocked before.
More information about the cfe-commits
mailing list