[compiler-rt] 15eb431 - tsan: modernize MaybeReportThreadLeak
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 5 07:52:45 PDT 2021
Author: Dmitry Vyukov
Date: 2021-08-05T16:52:41+02:00
New Revision: 15eb431537dc88d1e4fe4d276ecaa453647b9802
URL: https://github.com/llvm/llvm-project/commit/15eb431537dc88d1e4fe4d276ecaa453647b9802
DIFF: https://github.com/llvm/llvm-project/commit/15eb431537dc88d1e4fe4d276ecaa453647b9802.diff
LOG: 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
Added:
Modified:
compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp
index 874a0ab22e211..aefbda2f83720 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cpp
@@ -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);
More information about the llvm-commits
mailing list