forked from OSchip/llvm-project
tsan: Support constructor arguments via New
Make New<>() a variadic function template and forward any arguments to the constructor. std::forward<>() is inlined to avoid including <utility>. Differential Revision: https://reviews.llvm.org/D107147
This commit is contained in:
parent
98b5659b53
commit
4ab7665919
|
@ -51,9 +51,9 @@ void invoke_free_hook(void *ptr);
|
|||
void *Alloc(uptr sz);
|
||||
void FreeImpl(void *p);
|
||||
|
||||
template <typename T>
|
||||
T *New() {
|
||||
return new (Alloc(sizeof(T))) T();
|
||||
template <typename T, typename... Args>
|
||||
T *New(Args &&...args) {
|
||||
return new (Alloc(sizeof(T))) T(static_cast<Args &&>(args)...);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
|
@ -101,7 +101,7 @@ static ThreadContextBase *CreateThreadContext(u32 tid) {
|
|||
CHECK("unable to mprotect" && 0);
|
||||
}
|
||||
}
|
||||
return new (Alloc(sizeof(ThreadContext))) ThreadContext(tid);
|
||||
return New<ThreadContext>(tid);
|
||||
}
|
||||
|
||||
#if !SANITIZER_GO
|
||||
|
|
Loading…
Reference in New Issue