diff --git a/compiler-rt/lib/tsan/rtl/tsan_mutexset.h b/compiler-rt/lib/tsan/rtl/tsan_mutexset.h --- a/compiler-rt/lib/tsan/rtl/tsan_mutexset.h +++ b/compiler-rt/lib/tsan/rtl/tsan_mutexset.h @@ -21,7 +21,7 @@ public: // Holds limited number of mutexes. // The oldest mutexes are discarded on overflow. - static const uptr kMaxSize = 16; + static constexpr uptr kMaxSize = 16; struct Desc { uptr addr; StackID stack_id; @@ -30,9 +30,15 @@ u32 seq; u32 count; bool write; + + Desc() { internal_memset(this, 0, sizeof(*this)); } + Desc(const Desc& other) { *this = other; } + Desc& operator=(const MutexSet::Desc& other) { + internal_memcpy(this, &other, sizeof(*this)); + return *this; + } }; - MutexSet(); // The 'id' is obtained from SyncVar::GetId(). void Add(u64 id, bool write, u64 epoch); void Del(u64 id, bool write); @@ -42,11 +48,6 @@ uptr Size() const; Desc Get(uptr i) const; - MutexSet(const MutexSet& other) { *this = other; } - void operator=(const MutexSet &other) { - internal_memcpy(this, &other, sizeof(*this)); - } - private: #if !SANITIZER_GO u32 seq_ = 0; @@ -61,7 +62,6 @@ // (Go sync.Mutex is actually a semaphore -- can be unlocked // in different goroutine). #if SANITIZER_GO -MutexSet::MutexSet() {} void MutexSet::Add(u64 id, bool write, u64 epoch) {} void MutexSet::Del(u64 id, bool write) {} void MutexSet::Remove(u64 id) {} diff --git a/compiler-rt/lib/tsan/rtl/tsan_mutexset.cpp b/compiler-rt/lib/tsan/rtl/tsan_mutexset.cpp --- a/compiler-rt/lib/tsan/rtl/tsan_mutexset.cpp +++ b/compiler-rt/lib/tsan/rtl/tsan_mutexset.cpp @@ -14,12 +14,6 @@ namespace __tsan { -const uptr MutexSet::kMaxSize; - -MutexSet::MutexSet() { - internal_memset(&descs_, 0, sizeof(descs_)); -} - void MutexSet::Add(u64 id, bool write, u64 epoch) { // Look up existing mutex with the same id. for (uptr i = 0; i < size_; i++) {