Skip to content

Commit

Permalink
[scudo] Add missing thread-safety analysis annotations.
Browse files Browse the repository at this point in the history
This avoids new warnings from `-Wthread-safety` after llvm#67776, see
llvm#67795.

Note that this are not really useful since thread safety analysis is disabled anyway here:
llvm-project/compiler-rt/lib/scudo/standalone/tsd_exclusive.h:172
  • Loading branch information
legrosbuffle committed Oct 3, 2023
1 parent 853e126 commit 91f057e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions compiler-rt/lib/scudo/standalone/tsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ template <class Allocator> struct alignas(SCUDO_CACHE_LINE_SIZE) TSD {
inline void unlock() NO_THREAD_SAFETY_ANALYSIS { Mutex.unlock(); }
inline uptr getPrecedence() { return atomic_load_relaxed(&Precedence); }

void commitBack(Allocator *Instance) ASSERT_CAPABILITY(Mutex) {
void commitBack(Allocator *Instance) ASSERT_CAPABILITY(Mutex)
REQUIRES(Mutex) {
Instance->commitBack(this);
}

Expand All @@ -66,11 +67,12 @@ template <class Allocator> struct alignas(SCUDO_CACHE_LINE_SIZE) TSD {
// TODO(chiahungduan): Ideally, we want to do `Mutex.assertHeld` but acquiring
// TSD doesn't always require holding the lock. Add this assertion while the
// lock is always acquired.
typename Allocator::CacheT &getCache() ASSERT_CAPABILITY(Mutex) {
typename Allocator::CacheT &getCache() ASSERT_CAPABILITY(Mutex)
REQUIRES(Mutex) {
return Cache;
}
typename Allocator::QuarantineCacheT &getQuarantineCache()
ASSERT_CAPABILITY(Mutex) {
ASSERT_CAPABILITY(Mutex) REQUIRES(Mutex) {
return QuarantineCache;
}

Expand Down

0 comments on commit 91f057e

Please sign in to comment.