[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 17:18:21 PDT 2026


https://github.com/vitalybuka updated https://github.com/llvm/llvm-project/pull/228780

>From aa951dc11a041956ed4c7afef3fbea156ae2590a Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Sat, 3 Oct 2026 15:34:40 -0700
Subject: [PATCH 1/4] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.7
---
 compiler-rt/lib/tsan/rtl/tsan_report.cpp | 16 ----------------
 compiler-rt/lib/tsan/rtl/tsan_report.h   | 10 ++++------
 2 files changed, 4 insertions(+), 22 deletions(-)

diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.cpp b/compiler-rt/lib/tsan/rtl/tsan_report.cpp
index 17fd3064fb85a14..82ca89705f8d1b8 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_report.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_report.cpp
@@ -29,22 +29,6 @@ class Decorator: public __sanitizer::SanitizerCommonDecorator {
   const char *Mutex()   { return Magenta(); }
 };
 
-ReportDesc::ReportDesc()
-    : tag(kExternalTagNone)
-    , stacks()
-    , mops()
-    , locs()
-    , mutexes()
-    , threads()
-    , unique_tids()
-    , sleep()
-    , count() {
-}
-
-ReportMop::ReportMop()
-    : mset() {
-}
-
 ReportDesc::~ReportDesc() {
   // FIXME(dvyukov): it must be leaking a lot of memory.
 }
diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.h b/compiler-rt/lib/tsan/rtl/tsan_report.h
index 53bb21964dbba96..e444f4204d36c76 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_report.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_report.h
@@ -60,8 +60,6 @@ struct ReportMop {
   Vector<ReportMopMutex> mset;
   StackTrace stack_trace;
   ReportStack *stack;
-
-  ReportMop();
 };
 
 enum ReportLocationType {
@@ -113,7 +111,7 @@ struct AddedLocationAddr {
 class ReportDesc {
  public:
   ReportType typ;
-  uptr tag;
+  uptr tag = kExternalTagNone;
   Vector<ReportStack*> stacks;
   Vector<ReportMop*> mops;
   Vector<ReportLocation*> locs;
@@ -121,11 +119,11 @@ 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();
+  ReportDesc() = default;
   ~ReportDesc();
 
  private:

>From c1014e1ca45d713c759b6d8f336f14e6ad2694e8 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Sat, 3 Oct 2026 16:58:07 -0700
Subject: [PATCH 2/4] Keep ReportDesc::ReportDesc() = default in
 tsan_report.cpp

Created using spr 1.3.7
---
 compiler-rt/lib/tsan/rtl/tsan_report.cpp | 2 ++
 compiler-rt/lib/tsan/rtl/tsan_report.h   | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.cpp b/compiler-rt/lib/tsan/rtl/tsan_report.cpp
index 82ca89705f8d1b8..56db6a826fa4f88 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_report.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_report.cpp
@@ -29,6 +29,8 @@ class Decorator: public __sanitizer::SanitizerCommonDecorator {
   const char *Mutex()   { return Magenta(); }
 };
 
+ReportDesc::ReportDesc() = default;
+
 ReportDesc::~ReportDesc() {
   // FIXME(dvyukov): it must be leaking a lot of memory.
 }
diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.h b/compiler-rt/lib/tsan/rtl/tsan_report.h
index e444f4204d36c76..2a6209aea0b7b8c 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_report.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_report.h
@@ -123,7 +123,7 @@ class ReportDesc {
   int count = 0;
   int signum = 0;
 
-  ReportDesc() = default;
+  ReportDesc();
   ~ReportDesc();
 
  private:

>From 82910d7bab83cfaf9ab7e4db8011c13a094eb07c Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Sat, 3 Oct 2026 17:01:31 -0700
Subject: [PATCH 3/4] Revert ReportMop changes

Created using spr 1.3.7
---
 compiler-rt/lib/tsan/rtl/tsan_report.cpp | 4 ++++
 compiler-rt/lib/tsan/rtl/tsan_report.h   | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.cpp b/compiler-rt/lib/tsan/rtl/tsan_report.cpp
index 56db6a826fa4f88..11e0ccf396984dd 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_report.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_report.cpp
@@ -31,6 +31,10 @@ class Decorator: public __sanitizer::SanitizerCommonDecorator {
 
 ReportDesc::ReportDesc() = default;
 
+ReportMop::ReportMop()
+    : mset() {
+}
+
 ReportDesc::~ReportDesc() {
   // FIXME(dvyukov): it must be leaking a lot of memory.
 }
diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.h b/compiler-rt/lib/tsan/rtl/tsan_report.h
index 2a6209aea0b7b8c..e847b119c603915 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_report.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_report.h
@@ -60,6 +60,8 @@ struct ReportMop {
   Vector<ReportMopMutex> mset;
   StackTrace stack_trace;
   ReportStack *stack;
+
+  ReportMop();
 };
 
 enum ReportLocationType {

>From 18a4ec814ed87199813e21b1deda9da533854277 Mon Sep 17 00:00:00 2001
From: Vitaly Buka <vitalybuka at google.com>
Date: Sat, 3 Oct 2026 17:18:07 -0700
Subject: [PATCH 4/4] Update

Created using spr 1.3.7
---
 compiler-rt/lib/tsan/rtl/tsan_report.cpp | 10 ++---
 compiler-rt/lib/tsan/rtl/tsan_report.h   | 51 ++++++++++++------------
 2 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/compiler-rt/lib/tsan/rtl/tsan_report.cpp b/compiler-rt/lib/tsan/rtl/tsan_report.cpp
index 11e0ccf396984dd..ca04f9e1faf074d 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_report.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_report.cpp
@@ -31,13 +31,11 @@ class Decorator: public __sanitizer::SanitizerCommonDecorator {
 
 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 e847b119c603915..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,32 +88,32 @@ 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;
+  ReportType typ = ReportTypeRace;
   uptr tag = kExternalTagNone;
   Vector<ReportStack*> stacks;
   Vector<ReportMop*> mops;



More information about the llvm-commits mailing list