forked from OSchip/llvm-project
tsan: remove implicit memcpy in MutexSet::Desc::operator=()
The default compiler-generated MutexSet::Desc::operator=() now contains memcpy() call since Desc become bigger. This fails in debug mode since we call interceptor from within the runtime. Define own operator=() using internal_memcpy(). This also makes copy ctor necessary, otherwise: tsan_mutexset.h:33:11: warning: definition of implicit copy constructor for 'Desc' is deprecated because it has a user-declared copy assignment operator And if we add copy ctor, we also need the default ctor since it's called by MutexSet ctor. Depends on D107911. Reviewed By: melver Differential Revision: https://reviews.llvm.org/D107959
This commit is contained in:
parent
a72cd6353c
commit
62139c5b25
|
@ -14,10 +14,7 @@
|
|||
|
||||
namespace __tsan {
|
||||
|
||||
const uptr MutexSet::kMaxSize;
|
||||
|
||||
MutexSet::MutexSet() {
|
||||
internal_memset(&descs_, 0, sizeof(descs_));
|
||||
}
|
||||
|
||||
void MutexSet::Add(u64 id, bool write, u64 epoch) {
|
||||
|
|
|
@ -21,7 +21,7 @@ class MutexSet {
|
|||
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,6 +30,13 @@ class MutexSet {
|
|||
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();
|
||||
|
@ -42,11 +49,6 @@ class MutexSet {
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue