[llvm-branch-commits] [NFC][TSan] Merge ScopedReportBase into ScopedReport (PR #228640)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Oct 2 19:52:19 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Vitaly Buka (vitalybuka)

<details>
<summary>Changes</summary>

ScopedReport is the only subclass of ScopedReportBase and nothing uses
ScopedReportBase directly. Merge ScopedReportBase into ScopedReport.

Assisted-by: Gemini


---
Full diff: https://github.com/llvm/llvm-project/pull/228640.diff


2 Files Affected:

- (modified) compiler-rt/lib/tsan/rtl/tsan_rtl.h (+7-16) 
- (modified) compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp (+16-21) 


``````````diff
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
index fcfbf2f445dfa..a4bf790d5980b 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
@@ -413,8 +413,11 @@ const char *GetObjectTypeFromTag(uptr tag);
 const char *GetReportHeaderFromTag(uptr tag);
 uptr TagFromShadowStackFrame(uptr pc);
 
-class ScopedReportBase {
+class ScopedReport {
  public:
+  explicit ScopedReport(ReportType typ, uptr tag = kExternalTagNone);
+  ~ScopedReport();
+
   void AddMemoryAccess(uptr addr, uptr external_tag, Shadow s, Tid tid,
                        StackTrace stack, const MutexSet *mset);
   void AddStack(StackTrace stack, bool suppressable = false);
@@ -430,27 +433,15 @@ class ScopedReportBase {
 
   const ReportDesc *GetReport() const;
 
- protected:
-  ScopedReportBase(ReportType typ, uptr tag);
-  ~ScopedReportBase();
-
  private:
   ReportDesc *rep_;
   // Symbolizer makes lots of intercepted calls. If we try to process them,
   // at best it will cause deadlocks on internal mutexes.
   ScopedIgnoreInterceptors ignore_interceptors_;
-
-  ScopedReportBase(const ScopedReportBase &) = delete;
-  void operator=(const ScopedReportBase &) = delete;
-};
-
-class ScopedReport : public ScopedReportBase {
- public:
-  explicit ScopedReport(ReportType typ, uptr tag = kExternalTagNone);
-  ~ScopedReport();
-
- private:
   ScopedErrorReportLock lock_;
+
+  ScopedReport(const ScopedReport&) = delete;
+  void operator=(const ScopedReport&) = delete;
 };
 
 bool ShouldReport(ThreadState *thr, ReportType typ);
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
index 4a98b761b9d87..52a462617ecb4 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
@@ -163,24 +163,24 @@ bool ShouldReport(ThreadState *thr, ReportType typ) {
   }
 }
 
-ScopedReportBase::ScopedReportBase(ReportType typ, uptr tag) {
+ScopedReport::ScopedReport(ReportType typ, uptr tag) {
   CheckedMutex::CheckNoLocks();
   rep_ = New<ReportDesc>();
   rep_->typ = typ;
   rep_->tag = tag;
 }
 
-ScopedReportBase::~ScopedReportBase() { DestroyAndFree(rep_); }
+ScopedReport::~ScopedReport() { DestroyAndFree(rep_); }
 
-void ScopedReportBase::AddStack(StackTrace stack, bool suppressable) {
+void ScopedReport::AddStack(StackTrace stack, bool suppressable) {
   ReportStack **rs = rep_->stacks.PushBack();
   *rs = SymbolizeStack(stack);
   (*rs)->suppressable = suppressable;
 }
 
-void ScopedReportBase::AddMemoryAccess(uptr addr, uptr external_tag, Shadow s,
-                                       Tid tid, StackTrace stack,
-                                       const MutexSet *mset) {
+void ScopedReport::AddMemoryAccess(uptr addr, uptr external_tag, Shadow s,
+                                   Tid tid, StackTrace stack,
+                                   const MutexSet* mset) {
   uptr addr0, size;
   AccessType typ;
   s.GetAccess(&addr0, &size, &typ);
@@ -201,7 +201,7 @@ void ScopedReportBase::AddMemoryAccess(uptr addr, uptr external_tag, Shadow s,
   }
 }
 
-void ScopedReportBase::SymbolizeStackElems() {
+void ScopedReport::SymbolizeStackElems() {
   // symbolize memory ops
   for (usize i = 0, size = rep_->mops.Size(); i < size; i++) {
     ReportMop *mop = rep_->mops[i];
@@ -251,11 +251,11 @@ void ScopedReportBase::SymbolizeStackElems() {
   }
 }
 
-void ScopedReportBase::AddUniqueTid(Tid unique_tid) {
+void ScopedReport::AddUniqueTid(Tid unique_tid) {
   rep_->unique_tids.PushBack(unique_tid);
 }
 
-void ScopedReportBase::AddThread(const ThreadContext *tctx, bool suppressable) {
+void ScopedReport::AddThread(const ThreadContext* tctx, bool suppressable) {
   ctx->thread_registry.CheckLocked();
   for (uptr i = 0; i < rep_->threads.Size(); i++) {
     if ((u32)rep_->threads[i]->id == tctx->tid)
@@ -305,14 +305,14 @@ ThreadContext *IsThreadStackOrTls(uptr addr, bool *is_stack) {
 }
 #endif
 
-void ScopedReportBase::AddThread(Tid tid, bool suppressable) {
+void ScopedReport::AddThread(Tid tid, bool suppressable) {
 #if !SANITIZER_GO
   if (const ThreadContext *tctx = FindThreadByTidLocked(tid))
     AddThread(tctx, suppressable);
 #endif
 }
 
-int ScopedReportBase::AddMutex(uptr addr, StackID creation_stack_id) {
+int ScopedReport::AddMutex(uptr addr, StackID creation_stack_id) {
   for (uptr i = 0; i < rep_->mutexes.Size(); i++) {
     if (rep_->mutexes[i]->addr == addr)
       return rep_->mutexes[i]->id;
@@ -325,7 +325,7 @@ int ScopedReportBase::AddMutex(uptr addr, StackID creation_stack_id) {
   return rm->id;
 }
 
-void ScopedReportBase::AddLocation(uptr addr, uptr size) {
+void ScopedReport::AddLocation(uptr addr, uptr size) {
   if (addr == 0)
     return;
 #if !SANITIZER_GO
@@ -380,21 +380,16 @@ void ScopedReportBase::AddLocation(uptr addr, uptr size) {
 }
 
 #if !SANITIZER_GO
-void ScopedReportBase::AddSleep(StackID stack_id) {
+void ScopedReport::AddSleep(StackID stack_id) {
   rep_->sleep = SymbolizeStackId(stack_id);
 }
 #endif
 
-void ScopedReportBase::SetCount(int count) { rep_->count = count; }
+void ScopedReport::SetCount(int count) { rep_->count = count; }
 
-void ScopedReportBase::SetSigNum(int sig) { rep_->signum = sig; }
+void ScopedReport::SetSigNum(int sig) { rep_->signum = sig; }
 
-const ReportDesc *ScopedReportBase::GetReport() const { return rep_; }
-
-ScopedReport::ScopedReport(ReportType typ, uptr tag)
-    : ScopedReportBase(typ, tag) {}
-
-ScopedReport::~ScopedReport() {}
+const ReportDesc* ScopedReport::GetReport() const { return rep_; }
 
 // Replays the trace up to last_pos position in the last part
 // or up to the provided epoch/sid (whichever is earlier)

``````````

</details>


https://github.com/llvm/llvm-project/pull/228640


More information about the llvm-branch-commits mailing list