forked from OSchip/llvm-project
tsan: modernize MaybeReportThreadLeak
Use C++ casts and auto. Rename to CollectThreadLeaks b/c it's only collecting, not reporting. Reviewed By: melver Differential Revision: https://reviews.llvm.org/D107568
This commit is contained in:
parent
d99e9461b0
commit
15eb431537
|
@ -148,9 +148,9 @@ struct ThreadLeak {
|
|||
int count;
|
||||
};
|
||||
|
||||
static void MaybeReportThreadLeak(ThreadContextBase *tctx_base, void *arg) {
|
||||
Vector<ThreadLeak> &leaks = *(Vector<ThreadLeak>*)arg;
|
||||
ThreadContext *tctx = static_cast<ThreadContext*>(tctx_base);
|
||||
static void CollectThreadLeaks(ThreadContextBase *tctx_base, void *arg) {
|
||||
auto &leaks = *static_cast<Vector<ThreadLeak> *>(arg);
|
||||
auto *tctx = static_cast<ThreadContext *>(tctx_base);
|
||||
if (tctx->detached || tctx->status != ThreadStatusFinished)
|
||||
return;
|
||||
for (uptr i = 0; i < leaks.Size(); i++) {
|
||||
|
@ -159,8 +159,7 @@ static void MaybeReportThreadLeak(ThreadContextBase *tctx_base, void *arg) {
|
|||
return;
|
||||
}
|
||||
}
|
||||
ThreadLeak leak = {tctx, 1};
|
||||
leaks.PushBack(leak);
|
||||
leaks.PushBack({tctx, 1});
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -201,7 +200,7 @@ void ThreadFinalize(ThreadState *thr) {
|
|||
return;
|
||||
ThreadRegistryLock l(&ctx->thread_registry);
|
||||
Vector<ThreadLeak> leaks;
|
||||
ctx->thread_registry.RunCallbackForEachThreadLocked(MaybeReportThreadLeak,
|
||||
ctx->thread_registry.RunCallbackForEachThreadLocked(CollectThreadLeaks,
|
||||
&leaks);
|
||||
for (uptr i = 0; i < leaks.Size(); i++) {
|
||||
ScopedReport rep(ReportTypeThreadLeak);
|
||||
|
|
Loading…
Reference in New Issue