Skip to content

Commit 30fad6a

Browse files
committed
Thread safety analysis: Implement MutexLocker factory functions in documentation
We skipped adding definitions in 54bfd04 because we'd emit false positive warnings on the closing braces. But these have been fixed in commit e64ef63.
1 parent 4859195 commit 30fad6a

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

clang/docs/ThreadSafetyAnalysis.rst

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -933,11 +933,25 @@ implementation.
933933
MutexLocker(Mutex *mu, defer_lock_t) EXCLUDES(mu) : mut(mu), locked(false) {}
934934
935935
// Same as constructors, but without tag types. (Requires C++17 copy elision.)
936-
static MutexLocker Lock(Mutex *mu) ACQUIRE(mu);
937-
static MutexLocker Adopt(Mutex *mu) REQUIRES(mu);
938-
static MutexLocker ReaderLock(Mutex *mu) ACQUIRE_SHARED(mu);
939-
static MutexLocker AdoptReaderLock(Mutex *mu) REQUIRES_SHARED(mu);
940-
static MutexLocker DeferLock(Mutex *mu) EXCLUDES(mu);
936+
static MutexLocker Lock(Mutex *mu) ACQUIRE(mu) {
937+
return MutexLocker(mu);
938+
}
939+
940+
static MutexLocker Adopt(Mutex *mu) REQUIRES(mu) {
941+
return MutexLocker(mu, adopt_lock);
942+
}
943+
944+
static MutexLocker ReaderLock(Mutex *mu) ACQUIRE_SHARED(mu) {
945+
return MutexLocker(mu, shared_lock);
946+
}
947+
948+
static MutexLocker AdoptReaderLock(Mutex *mu) REQUIRES_SHARED(mu) {
949+
return MutexLocker(mu, adopt_lock, shared_lock);
950+
}
951+
952+
static MutexLocker DeferLock(Mutex *mu) EXCLUDES(mu) {
953+
return MutexLocker(mu, defer_lock);
954+
}
941955
942956
// Release *this and all associated mutexes, if they are still held.
943957
// There is no warning if the scope was already unlocked before.

0 commit comments

Comments
 (0)