[compiler-rt] [NFC][TSan] Use in-class member initializers in tsan_report.h (PR #228780)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 3 19:07:23 PDT 2026
https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/228780
>From 9cd841a0727fa104eafec8b0e4c0443ae6845392 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Sat, 3 Oct 2026 15:32:58 -0700
Subject: [PATCH] [NFC][TSan] Use in-class member initializers in tsan_report.h
Use in-class member initializers for all structs and classes in
tsan_report.h and default constructors and destructor in
tsan_report.cpp.
Assisted-by: Gemini
Pull Request: https://github.com/llvm/llvm-project/pull/228780
---
compiler-rt/lib/tsan/rtl/tsan_report.cpp | 22 +++------
compiler-rt/lib/tsan/rtl/tsan_report.h | 57 ++++++++++++------------
2 files changed, 34 insertions(+), 45 deletions(-)
diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.cpp b/compiler-rt/lib/tsan/rtl/tsan_report.cpp
index 17fd3064fb85a14..ca04f9e1faf074d 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_report.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_report.cpp
@@ -29,25 +29,13 @@ class Decorator: public __sanitizer::SanitizerCommonDecorator {
const char *Mutex() { return Magenta(); }
};
-ReportDesc::ReportDesc()
- : tag(kExternalTagNone)
- , stacks()
- , mops()
- , locs()
- , mutexes()
- , threads()
- , unique_tids()
- , sleep()
- , count() {
-}
+ReportDesc::ReportDesc() = default;
-ReportMop::ReportMop()
- : mset() {
-}
+ReportMop::ReportMop() = default;
+ReportMop::~ReportMop() = default;
-ReportDesc::~ReportDesc() {
- // FIXME(dvyukov): it must be leaking a lot of memory.
-}
+// FIXME(dvyukov): it must be leaking a lot of memory.
+ReportDesc::~ReportDesc() = default;
#if !SANITIZER_GO
diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.h b/compiler-rt/lib/tsan/rtl/tsan_report.h
index 53bb21964dbba96..a664bc5d4933285 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_report.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_report.h
@@ -46,22 +46,23 @@ struct ReportStack {
};
struct ReportMopMutex {
- int id;
- bool write;
+ int id = 0;
+ bool write = false;
};
struct ReportMop {
- int tid;
- uptr addr;
- int size;
- bool write;
- bool atomic;
- uptr external_tag;
+ int tid = kInvalidTid;
+ uptr addr = 0;
+ int size = 0;
+ bool write = false;
+ bool atomic = false;
+ uptr external_tag = 0;
Vector<ReportMopMutex> mset;
StackTrace stack_trace;
- ReportStack *stack;
+ ReportStack* stack = nullptr;
ReportMop();
+ ~ReportMop();
};
enum ReportLocationType {
@@ -87,33 +88,33 @@ struct ReportLocation {
};
struct ReportThread {
- Tid id;
- ThreadID os_id;
- bool running;
- ThreadType thread_type;
- char *name;
- Tid parent_tid;
- StackID stack_id;
- ReportStack *stack;
- bool suppressable;
+ Tid id = kInvalidTid;
+ ThreadID os_id = 0;
+ bool running = false;
+ ThreadType thread_type = ThreadType::Regular;
+ char* name = nullptr;
+ Tid parent_tid = kInvalidTid;
+ StackID stack_id = 0;
+ ReportStack* stack = nullptr;
+ bool suppressable = false;
};
struct ReportMutex {
- int id;
- uptr addr;
- StackID stack_id;
- ReportStack *stack;
+ int id = 0;
+ uptr addr = 0;
+ StackID stack_id = 0;
+ ReportStack* stack = nullptr;
};
struct AddedLocationAddr {
- uptr addr;
- usize locs_idx;
+ uptr addr = 0;
+ usize locs_idx = 0;
};
class ReportDesc {
public:
- ReportType typ;
- uptr tag;
+ ReportType typ = ReportTypeRace;
+ uptr tag = kExternalTagNone;
Vector<ReportStack*> stacks;
Vector<ReportMop*> mops;
Vector<ReportLocation*> locs;
@@ -121,8 +122,8 @@ class ReportDesc {
Vector<ReportMutex*> mutexes;
Vector<ReportThread*> threads;
Vector<Tid> unique_tids;
- ReportStack *sleep;
- int count;
+ ReportStack* sleep = nullptr;
+ int count = 0;
int signum = 0;
ReportDesc();
More information about the llvm-commits
mailing list