[compiler-rt] [llvm] [sanitizers][NFC] delete some copy constructor and copy assignment to more comply to rule of three (PR #112844)

Wu Yingcong via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 17 23:14:45 PDT 2024


https://github.com/yingcong-wu updated https://github.com/llvm/llvm-project/pull/112844

>From 39773eb3a1e40f22bae0aeabc6a72566a0d172b4 Mon Sep 17 00:00:00 2001
From: "Wu, Yingcong" <yingcong.wu at intel.com>
Date: Thu, 17 Oct 2024 22:57:55 -0700
Subject: [PATCH 1/3] delete copy constructor and copy assign op

---
 compiler-rt/lib/asan/asan_report.cpp            |  3 +++
 compiler-rt/lib/asan/asan_stack.cpp             |  3 +++
 compiler-rt/lib/fuzzer/FuzzerCorpus.h           |  2 ++
 compiler-rt/lib/fuzzer/FuzzerFork.cpp           |  3 +++
 compiler-rt/lib/fuzzer/FuzzerInternal.h         | 12 ++++++++++++
 compiler-rt/lib/fuzzer/FuzzerLoop.cpp           |  3 +++
 compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp    |  5 ++++-
 compiler-rt/lib/lsan/lsan_common.h              |  3 +++
 compiler-rt/lib/msan/msan.cpp                   |  3 +++
 compiler-rt/lib/msan/msan.h                     |  3 +++
 compiler-rt/lib/msan/msan_interceptors.cpp      |  2 ++
 .../sanitizer_common/sanitizer_addrhashmap.h    |  3 +++
 .../sanitizer_allocator_report.cpp              |  4 ++++
 .../lib/sanitizer_common/sanitizer_common.h     |  8 ++++++++
 .../sanitizer_deadlock_detector_interface.h     |  3 +++
 .../lib/sanitizer_common/sanitizer_file.h       |  3 +++
 .../lib/sanitizer_common/sanitizer_procmaps.h   |  2 ++
 .../sanitizer_common/sanitizer_ring_buffer.h    |  2 ++
 .../sanitizer_stoptheworld_linux_libcdep.cpp    | 11 +++++++++++
 .../lib/sanitizer_common/sanitizer_symbolizer.h |  6 ++++++
 .../sanitizer_symbolizer_win.cpp                |  3 +++
 .../sanitizer_thread_registry.h                 |  4 ++++
 compiler-rt/lib/tsan/rtl/tsan_dense_alloc.h     |  3 +++
 compiler-rt/lib/tsan/rtl/tsan_interceptors.h    |  3 +++
 .../lib/tsan/rtl/tsan_interceptors_posix.cpp    |  5 +++++
 compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp |  3 +++
 compiler-rt/lib/tsan/rtl/tsan_rtl.h             |  9 +++++++++
 compiler-rt/lib/tsan/rtl/tsan_vector_clock.h    |  2 ++
 compiler-rt/lib/ubsan/ubsan_diag.h              |  3 +++
 .../Instrumentation/AddressSanitizer.cpp        |  5 +++++
 .../Instrumentation/ControlHeightReduction.cpp  | 17 ++++++++++-------
 .../Instrumentation/GCOVProfiling.cpp           |  1 +
 32 files changed, 134 insertions(+), 8 deletions(-)

diff --git a/compiler-rt/lib/asan/asan_report.cpp b/compiler-rt/lib/asan/asan_report.cpp
index 45aa607dcda07f..b6f5a657eac6c8 100644
--- a/compiler-rt/lib/asan/asan_report.cpp
+++ b/compiler-rt/lib/asan/asan_report.cpp
@@ -210,6 +210,9 @@ class ScopedInErrorReport {
   // with the debugger and point it to an error description.
   static ErrorDescription current_error_;
   bool halt_on_error_;
+
+  ScopedInErrorReport(const ScopedInErrorReport &) = delete;
+  ScopedInErrorReport &operator=(const ScopedInErrorReport &) = delete;
 };
 
 ErrorDescription ScopedInErrorReport::current_error_(LINKER_INITIALIZED);
diff --git a/compiler-rt/lib/asan/asan_stack.cpp b/compiler-rt/lib/asan/asan_stack.cpp
index 764c6ac193fb06..5f2694908bf15e 100644
--- a/compiler-rt/lib/asan/asan_stack.cpp
+++ b/compiler-rt/lib/asan/asan_stack.cpp
@@ -47,6 +47,9 @@ class ScopedUnwinding {
  private:
   AsanThread *thread = nullptr;
   bool can_unwind = true;
+
+  ScopedUnwinding(const ScopedUnwinding &) = delete;
+  ScopedUnwinding &operator=(const ScopedUnwinding &) = delete;
 };
 
 }  // namespace
diff --git a/compiler-rt/lib/fuzzer/FuzzerCorpus.h b/compiler-rt/lib/fuzzer/FuzzerCorpus.h
index 48b5a2cff02e25..6a227b3293fe75 100644
--- a/compiler-rt/lib/fuzzer/FuzzerCorpus.h
+++ b/compiler-rt/lib/fuzzer/FuzzerCorpus.h
@@ -469,6 +469,8 @@ class InputCorpus {
   size_t NumFeatureUpdates() const { return NumUpdatedFeatures; }
 
 private:
+  InputCorpus(const InputCorpus &) = delete;
+  InputCorpus &operator=(const InputCorpus &) = delete;
 
   static const bool FeatureDebug = false;
 
diff --git a/compiler-rt/lib/fuzzer/FuzzerFork.cpp b/compiler-rt/lib/fuzzer/FuzzerFork.cpp
index e544cd846e4db5..c40c4e7e31d853 100644
--- a/compiler-rt/lib/fuzzer/FuzzerFork.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerFork.cpp
@@ -83,6 +83,9 @@ struct FuzzJob {
     RmDirRecursive(CorpusDir);
     RmDirRecursive(FeaturesDir);
   }
+
+  FuzzJob(const FuzzJob &) = delete;
+  FuzzJob &operator=(const FuzzJob &) = delete;
 };
 
 struct GlobalEnv {
diff --git a/compiler-rt/lib/fuzzer/FuzzerInternal.h b/compiler-rt/lib/fuzzer/FuzzerInternal.h
index 88504705137a8f..49b4dbcdf5ee1b 100644
--- a/compiler-rt/lib/fuzzer/FuzzerInternal.h
+++ b/compiler-rt/lib/fuzzer/FuzzerInternal.h
@@ -34,6 +34,8 @@ class Fuzzer final {
   Fuzzer(UserCallback CB, InputCorpus &Corpus, MutationDispatcher &MD,
          const FuzzingOptions &Options);
   ~Fuzzer() = delete;
+  Fuzzer(const Fuzzer &) = delete;
+  Fuzzer &operator=(const Fuzzer &) = delete;
   void Loop(std::vector<SizedFile> &CorporaFiles);
   void ReadAndExecuteSeedCorpora(std::vector<SizedFile> &CorporaFiles);
   void MinimizeCrashLoop(const Unit &U);
@@ -160,6 +162,11 @@ struct ScopedEnableMsanInterceptorChecks {
     if (EF->__msan_scoped_disable_interceptor_checks)
       EF->__msan_scoped_disable_interceptor_checks();
   }
+
+  ScopedEnableMsanInterceptorChecks(const ScopedEnableMsanInterceptorChecks &) =
+      delete;
+  ScopedEnableMsanInterceptorChecks &
+  operator=(const ScopedEnableMsanInterceptorChecks &) = delete;
 };
 
 struct ScopedDisableMsanInterceptorChecks {
@@ -171,6 +178,11 @@ struct ScopedDisableMsanInterceptorChecks {
     if (EF->__msan_scoped_enable_interceptor_checks)
       EF->__msan_scoped_enable_interceptor_checks();
   }
+
+  ScopedDisableMsanInterceptorChecks(
+      const ScopedDisableMsanInterceptorChecks &) = delete;
+  ScopedDisableMsanInterceptorChecks &
+  operator=(const ScopedDisableMsanInterceptorChecks &) = delete;
 };
 
 } // namespace fuzzer
diff --git a/compiler-rt/lib/fuzzer/FuzzerLoop.cpp b/compiler-rt/lib/fuzzer/FuzzerLoop.cpp
index 6f415dd5763ac9..68ce839f41cc4a 100644
--- a/compiler-rt/lib/fuzzer/FuzzerLoop.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerLoop.cpp
@@ -92,6 +92,9 @@ class TraceLock {
 
 private:
   std::lock_guard<std::recursive_mutex> Lock;
+
+  TraceLock(const TraceLock &) = delete;
+  TraceLock &operator=(const TraceLock &) = delete;
 };
 
 ATTRIBUTE_NO_SANITIZE_MEMORY
diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
index 37aecae7237ae9..d951d1014bcf35 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
@@ -98,7 +98,10 @@ void CALLBACK AlarmHandler(PVOID, BOOLEAN) {
 
 class TimerQ {
   HANDLE TimerQueue;
- public:
+  TimerQ(const TimerQ &) = delete;
+  TimerQ &operator=(const TimerQ &) = delete;
+
+public:
   TimerQ() : TimerQueue(NULL) {}
   ~TimerQ() {
     if (TimerQueue)
diff --git a/compiler-rt/lib/lsan/lsan_common.h b/compiler-rt/lib/lsan/lsan_common.h
index f990c7850497a5..cda2b2705d88d8 100644
--- a/compiler-rt/lib/lsan/lsan_common.h
+++ b/compiler-rt/lib/lsan/lsan_common.h
@@ -285,6 +285,9 @@ void EnableInThisThread();
 struct ScopedInterceptorDisabler {
   ScopedInterceptorDisabler() { DisableInThisThread(); }
   ~ScopedInterceptorDisabler() { EnableInThisThread(); }
+  ScopedInterceptorDisabler(const ScopedInterceptorDisabler &) = delete;
+  ScopedInterceptorDisabler &operator=(const ScopedInterceptorDisabler &) =
+      delete;
 };
 
 // According to Itanium C++ ABI array cookie is a one word containing
diff --git a/compiler-rt/lib/msan/msan.cpp b/compiler-rt/lib/msan/msan.cpp
index 6c27ab21eeebfd..cb15419936c7cd 100644
--- a/compiler-rt/lib/msan/msan.cpp
+++ b/compiler-rt/lib/msan/msan.cpp
@@ -86,6 +86,9 @@ bool IsInSymbolizerOrUnwider() { return is_in_symbolizer_or_unwinder; }
 struct UnwinderScope {
   UnwinderScope() { EnterSymbolizerOrUnwider(); }
   ~UnwinderScope() { ExitSymbolizerOrUnwider(); }
+
+  UnwinderScope(const UnwinderScope &) = delete;
+  UnwinderScope &operator=(const UnwinderScope &) = delete;
 };
 
 static Flags msan_flags;
diff --git a/compiler-rt/lib/msan/msan.h b/compiler-rt/lib/msan/msan.h
index 7fb58be67a02cd..8dab07b78d6542 100644
--- a/compiler-rt/lib/msan/msan.h
+++ b/compiler-rt/lib/msan/msan.h
@@ -354,6 +354,9 @@ class ScopedThreadLocalStateBackup {
   void Restore();
  private:
   u64 va_arg_overflow_size_tls;
+  ScopedThreadLocalStateBackup(const ScopedThreadLocalStateBackup &) = delete;
+  ScopedThreadLocalStateBackup &operator=(
+      const ScopedThreadLocalStateBackup &) = delete;
 };
 
 void MsanTSDInit(void (*destructor)(void *tsd));
diff --git a/compiler-rt/lib/msan/msan_interceptors.cpp b/compiler-rt/lib/msan/msan_interceptors.cpp
index f05c20618780b7..7b11a9a8da4a95 100644
--- a/compiler-rt/lib/msan/msan_interceptors.cpp
+++ b/compiler-rt/lib/msan/msan_interceptors.cpp
@@ -71,6 +71,8 @@ void __msan_scoped_enable_interceptor_checks() { --in_interceptor_scope; }
 struct InterceptorScope {
   InterceptorScope() { ++in_interceptor_scope; }
   ~InterceptorScope() { --in_interceptor_scope; }
+  InterceptorScope(const InterceptorScope &) = delete;
+  InterceptorScope &operator=(const InterceptorScope &) = delete;
 };
 
 bool IsInInterceptorScope() {
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_addrhashmap.h b/compiler-rt/lib/sanitizer_common/sanitizer_addrhashmap.h
index fe48b9caf0670b..66ee60c4094175 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_addrhashmap.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_addrhashmap.h
@@ -92,6 +92,9 @@ class AddrHashMap {
     bool                   created_;
     bool                   remove_;
     bool                   create_;
+
+    Handle(const Handle &) = delete;
+    Handle &operator=(const Handle &) = delete;
   };
 
   typedef void (*ForEachCallback)(const uptr key, const T &val, void *arg);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_report.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_report.cpp
index 129f925e6fb686..26a5b5da741c54 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_report.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_report.cpp
@@ -38,6 +38,10 @@ class ScopedAllocatorErrorReport {
   const char *error_summary;
   const StackTrace* const stack;
   const SanitizerCommonDecorator d;
+
+  ScopedAllocatorErrorReport(const ScopedAllocatorErrorReport &) = delete;
+  ScopedAllocatorErrorReport &operator=(const ScopedAllocatorErrorReport &) =
+      delete;
 };
 
 void NORETURN ReportCallocOverflow(uptr count, uptr size,
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common.h b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
index 082d2158e579bd..c408484d49917c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common.h
@@ -261,6 +261,8 @@ class ScopedErrorReportLock {
   static void CheckLocked() SANITIZER_CHECK_LOCKED(mutex_);
 
  private:
+  ScopedErrorReportLock(const ScopedErrorReportLock &) = delete;
+  ScopedErrorReportLock &operator=(const ScopedErrorReportLock &) = delete;
   static atomic_uintptr_t reporting_thread_;
   static StaticSpinMutex mutex_;
 };
@@ -908,6 +910,9 @@ class ListOfModules {
     initialized = true;
   }
 
+  ListOfModules(const ListOfModules &) = delete;
+  ListOfModules &operator=(const ListOfModules &) = delete;
+
   InternalMmapVectorNoCtor<LoadedModule> modules_;
   // We rarely have more than 16K loaded modules.
   static const uptr kInitialCapacity = 1 << 14;
@@ -1054,6 +1059,9 @@ class RunOnDestruction {
 
  private:
   Fn fn_;
+
+  RunOnDestruction(const RunOnDestruction &) = delete;
+  RunOnDestruction &operator=(const RunOnDestruction &) = delete;
 };
 
 // A simple scope guard. Usage:
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector_interface.h b/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector_interface.h
index 7f461c98bade44..45f63d456e5473 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector_interface.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_deadlock_detector_interface.h
@@ -67,6 +67,9 @@ struct DDCallback {
   virtual u32 Unwind() { return 0; }
   virtual int UniqueTid() { return 0; }
 
+  RingBuffer(const RingBuffer &) = delete;
+  RingBuffer &operator=(const RingBuffer &) = delete;
+
  protected:
   ~DDCallback() {}
 };
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_file.h b/compiler-rt/lib/sanitizer_common/sanitizer_file.h
index bef2c842d9f24f..da21a6949092e6 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_file.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_file.h
@@ -71,6 +71,9 @@ struct FileCloser {
   explicit FileCloser(fd_t fd) : fd(fd) {}
   ~FileCloser() { CloseFile(fd); }
   fd_t fd;
+
+  FileCloser(const FileCloser &) = delete;
+  FileCloser &operator=(const FileCloser &) = delete;
 };
 
 bool SupportsColoredOutput(fd_t fd);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h
index bf3c2c28e32e39..cbd79f28e17fcd 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_procmaps.h
@@ -112,6 +112,8 @@ class MemoryMappingLayout : public MemoryMappingLayoutBase {
 
  private:
   void LoadFromCache();
+  MemoryMappingLayout(const MemoryMappingLayout &) = delete;
+  MemoryMappingLayout &operator=(const MemoryMappingLayout &) = delete;
 };
 
 // Returns code range for the specified module.
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_ring_buffer.h b/compiler-rt/lib/sanitizer_common/sanitizer_ring_buffer.h
index 6222a958b11682..96a81df09ebeb1 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_ring_buffer.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_ring_buffer.h
@@ -66,6 +66,7 @@ class RingBuffer {
   RingBuffer() {}
   ~RingBuffer() {}
   RingBuffer(const RingBuffer&) = delete;
+  RingBuffer &operator=(const RingBuffer &) = delete;
 
   // Data layout:
   // LNDDDDDDDD
@@ -159,6 +160,7 @@ class CompactRingBuffer {
  public:
   ~CompactRingBuffer() {}
   CompactRingBuffer(const CompactRingBuffer &) = delete;
+  CompactRingBuffer &operator=(const CompactRingBuffer &) = delete;
 
   uptr long_;
 };
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
index 945da99d41f4ea..0c3a0c5df25f80 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cpp
@@ -358,6 +358,10 @@ class ScopedStackSpaceWithGuard {
   uptr stack_size_;
   uptr guard_size_;
   uptr guard_start_;
+
+  ScopedStackSpaceWithGuard(const ScopedStackSpaceWithGuard &) = delete;
+  ScopedStackSpaceWithGuard &operator=(const ScopedStackSpaceWithGuard &) =
+      delete;
 };
 
 // We have a limitation on the stack frame size, so some stuff had to be moved
@@ -383,6 +387,9 @@ class StopTheWorldScope {
 
  private:
   int process_was_dumpable_;
+
+  StopTheWorldScope(const StopTheWorldScope &) = delete;
+  StopTheWorldScope &operator=(const StopTheWorldScope &) = delete;
 };
 
 // When sanitizer output is being redirected to file (i.e. by using log_path),
@@ -397,6 +404,10 @@ struct ScopedSetTracerPID {
     stoptheworld_tracer_pid = 0;
     stoptheworld_tracer_ppid = 0;
   }
+
+ private:
+  ScopedSetTracerPID(const ScopedSetTracerPID &) = delete;
+  ScopedSetTracerPID &operator=(const ScopedSetTracerPID &) = delete;
 };
 
 void StopTheWorld(StopTheWorldCallback callback, void *argument) {
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h
index bd89dc4e302fc9..f8ac653e2f1f55 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer.h
@@ -72,6 +72,9 @@ class SymbolizedStackHolder {
       Stack->ClearAll();
   }
 
+  SymbolizedStackHolder(const SymbolizedStackHolder &) = delete;
+  SymbolizedStackHolder &operator=(const SymbolizedStackHolder &) = delete;
+
  public:
   explicit SymbolizedStackHolder(SymbolizedStack *Stack = nullptr)
       : Stack(Stack) {}
@@ -235,6 +238,9 @@ class Symbolizer final {
    private:
     const Symbolizer *sym_;
     int errno_;  // Backup errno in case symbolizer change the value.
+
+    SymbolizerScope(const SymbolizerScope &) = delete;
+    SymbolizerScope &operator=(const SymbolizerScope &) = delete;
   };
 };
 
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp
index 1ff8b8f1bab480..69d0ef7e416490 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_symbolizer_win.cpp
@@ -194,6 +194,9 @@ struct ScopedHandle {
     return h;
   }
   HANDLE h_;
+
+  ScopedHandle(const ScopedHandle &) = delete;
+  ScopedHandle &operator=(const ScopedHandle &) = delete;
 };
 } // namespace
 
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h b/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h
index e06abb3932da5c..b70686b06f4ef1 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h
@@ -83,6 +83,10 @@ class ThreadContextBase {
 
  protected:
   ~ThreadContextBase();
+
+ private:
+  ThreadContextBase(const ThreadContextBase &) = delete;
+  ThreadContextBase &operator=(const ThreadContextBase &) = delete;
 };
 
 typedef ThreadContextBase* (*ThreadContextFactory)(u32 tid);
diff --git a/compiler-rt/lib/tsan/rtl/tsan_dense_alloc.h b/compiler-rt/lib/tsan/rtl/tsan_dense_alloc.h
index 2eaff39057bc5e..c60af0b16d5ccd 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_dense_alloc.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_dense_alloc.h
@@ -189,6 +189,9 @@ class DenseSlabAlloc {
     atomic_store_relaxed(&fillpos_, fillpos + 1);
     CHECK(c->pos);
   }
+
+  DenseSlabAlloc(const DenseSlabAlloc &) = delete;
+  DenseSlabAlloc &operator=(const DenseSlabAlloc &) = delete;
 };
 
 }  // namespace __tsan
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors.h b/compiler-rt/lib/tsan/rtl/tsan_interceptors.h
index a357a870fdf8e8..73c0abf08feb9e 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors.h
@@ -27,6 +27,9 @@ class ScopedInterceptor {
 
   void DisableIgnoresImpl();
   void EnableIgnoresImpl();
+
+  ScopedInterceptor(const ScopedInterceptor &) = delete;
+  ScopedInterceptor &operator=(const ScopedInterceptor &) = delete;
 };
 
 struct TsanInterceptorContext {
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
index 423d97e94d81ae..8a353ded60e438 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
@@ -386,6 +386,8 @@ struct BlockingCall {
   }
 
   ThreadState *thr;
+  BlockingCall(const BlockingCall &) = delete;
+  BlockingCall &operator=(const BlockingCall &) = delete;
 };
 
 TSAN_INTERCEPTOR(unsigned, sleep, unsigned sec) {
@@ -2669,6 +2671,9 @@ struct ScopedSyscall {
   ~ScopedSyscall() {
     ProcessPendingSignals(thr);
   }
+
+  ScopedSyscall(const ScopedSyscall &) = delete;
+  ScopedSyscall &operator=(const ScopedSyscall &) = delete;
 };
 
 #if !SANITIZER_FREEBSD && !SANITIZER_APPLE
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp b/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp
index befd6a369026d8..49fada836ff380 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interface_ann.cpp
@@ -41,6 +41,9 @@ class ScopedAnnotation {
   }
  private:
   ThreadState *const thr_;
+
+  ScopedAnnotation(const ScopedAnnotation &) = delete;
+  ScopedAnnotation &operator=(const ScopedAnnotation &) = delete;
 };
 
 #define SCOPED_ANNOTATION_RET(typ, ret)                     \
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
index f48be8e0a4fe08..6c3d40b9b26ed0 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
@@ -128,6 +128,9 @@ struct Processor {
 struct ScopedGlobalProcessor {
   ScopedGlobalProcessor();
   ~ScopedGlobalProcessor();
+
+  ScopedGlobalProcessor(const ScopedGlobalProcessor &) = delete;
+  ScopedGlobalProcessor &operator=(const ScopedGlobalProcessor &) = delete;
 };
 #endif
 
@@ -398,6 +401,9 @@ struct ScopedIgnoreInterceptors {
     cur_thread()->ignore_interceptors--;
 #endif
   }
+  ScopedIgnoreInterceptors(const ScopedIgnoreInterceptors &) = delete;
+  ScopedIgnoreInterceptors &operator=(const ScopedIgnoreInterceptors &) =
+      delete;
 };
 
 const char *GetObjectTypeFromTag(uptr tag);
@@ -650,6 +656,9 @@ class SlotLocker {
  private:
   ThreadState *thr_;
   bool locked_;
+
+  SlotLocker(const SlotLocker &) = delete;
+  SlotLocker &operator=(const SlotLocker &) = delete;
 };
 
 class SlotUnlocker {
diff --git a/compiler-rt/lib/tsan/rtl/tsan_vector_clock.h b/compiler-rt/lib/tsan/rtl/tsan_vector_clock.h
index 51d98113d8e78a..5ba69aaf10a574 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_vector_clock.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_vector_clock.h
@@ -35,6 +35,8 @@ class VectorClock {
 
  private:
   VECTOR_ALIGNED Epoch clk_[kThreadSlotCount];
+
+  VectorClock(const VectorClock&) = delete;
 };
 
 ALWAYS_INLINE Epoch VectorClock::Get(Sid sid) const {
diff --git a/compiler-rt/lib/ubsan/ubsan_diag.h b/compiler-rt/lib/ubsan/ubsan_diag.h
index c836647c98f3c5..320962c9c69d3e 100644
--- a/compiler-rt/lib/ubsan/ubsan_diag.h
+++ b/compiler-rt/lib/ubsan/ubsan_diag.h
@@ -228,6 +228,9 @@ class ScopedReport {
   Location SummaryLoc;
   ErrorType Type;
 
+  ScopedReport(const ScopedReport &) = delete;
+  ScopedReport &operator=(const ScopedReport &) = delete;
+
 public:
   ScopedReport(ReportOptions Opts, Location SummaryLoc, ErrorType Type);
   ~ScopedReport();
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index 55e9903876b1d1..841eaa4693d50f 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -654,6 +654,8 @@ class RuntimeCallInserter {
   Function *OwnerFn = nullptr;
   bool TrackInsertedCalls = false;
   SmallVector<CallInst *> InsertedCalls;
+  RuntimeCallInserter(const RuntimeCallInserter &) = delete;
+  RuntimeCallInserter &operator=(const RuntimeCallInserter &) = delete;
 
 public:
   RuntimeCallInserter(Function &Fn) : OwnerFn(&Fn) {
@@ -829,6 +831,9 @@ struct AddressSanitizer {
       Pass->LocalDynamicShadow = nullptr;
       Pass->ProcessedAllocas.clear();
     }
+
+    FunctionStateRAII(const FunctionStateRAII &) = delete;
+    FunctionStateRAII &operator=(const FunctionStateRAII &) = delete;
   };
 
   Module &M;
diff --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
index 810cbbda66085a..9c5f2e2142229b 100644
--- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
+++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
@@ -300,14 +300,17 @@ class CHR {
   bool run();
 
  private:
-  // See the comments in CHR::run() for the high level flow of the algorithm and
-  // what the following functions do.
+   CHR(const CHR &) = delete;
+   CHR &operator=(const CHR &) = delete;
 
-  void findScopes(SmallVectorImpl<CHRScope *> &Output) {
-    Region *R = RI.getTopLevelRegion();
-    if (CHRScope *Scope = findScopes(R, nullptr, nullptr, Output)) {
-      Output.push_back(Scope);
-    }
+   // See the comments in CHR::run() for the high level flow of the algorithm
+   // and what the following functions do.
+
+   void findScopes(SmallVectorImpl<CHRScope *> &Output) {
+     Region *R = RI.getTopLevelRegion();
+     if (CHRScope *Scope = findScopes(R, nullptr, nullptr, Output)) {
+       Output.push_back(Scope);
+     }
   }
   CHRScope *findScopes(Region *R, Region *NextRegion, Region *ParentRegion,
                         SmallVectorImpl<CHRScope *> &Scopes);
diff --git a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
index a409f6150a71c1..5400a7cebc3e62 100644
--- a/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
+++ b/llvm/lib/Transforms/Instrumentation/GCOVProfiling.cpp
@@ -307,6 +307,7 @@ namespace {
       assert(LinesByFile.empty());
       assert(OutEdges.empty());
     }
+    GCOVBlock &operator=(const GCOVBlock &) = delete;
 
     uint32_t Number;
     SmallVector<std::pair<GCOVBlock *, uint32_t>, 4> OutEdges;

>From 1aeece37d72433f85f3cf7743032d17326cd698a Mon Sep 17 00:00:00 2001
From: "Wu, Yingcong" <yingcong.wu at intel.com>
Date: Thu, 17 Oct 2024 23:11:00 -0700
Subject: [PATCH 2/3] updates

---
 compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp               | 5 +++--
 compiler-rt/lib/msan/msan.cpp                              | 1 -
 .../lib/sanitizer_common/sanitizer_thread_registry.h       | 7 +++----
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
index d951d1014bcf35..bb8a907f0a9335 100644
--- a/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
+++ b/compiler-rt/lib/fuzzer/FuzzerUtilWindows.cpp
@@ -98,8 +98,6 @@ void CALLBACK AlarmHandler(PVOID, BOOLEAN) {
 
 class TimerQ {
   HANDLE TimerQueue;
-  TimerQ(const TimerQ &) = delete;
-  TimerQ &operator=(const TimerQ &) = delete;
 
 public:
   TimerQ() : TimerQueue(NULL) {}
@@ -122,6 +120,9 @@ class TimerQ {
       exit(1);
     }
   }
+
+  TimerQ(const TimerQ &) = delete;
+  TimerQ &operator=(const TimerQ &) = delete;
 };
 
 static TimerQ Timer;
diff --git a/compiler-rt/lib/msan/msan.cpp b/compiler-rt/lib/msan/msan.cpp
index cb15419936c7cd..b1252734a87155 100644
--- a/compiler-rt/lib/msan/msan.cpp
+++ b/compiler-rt/lib/msan/msan.cpp
@@ -86,7 +86,6 @@ bool IsInSymbolizerOrUnwider() { return is_in_symbolizer_or_unwinder; }
 struct UnwinderScope {
   UnwinderScope() { EnterSymbolizerOrUnwider(); }
   ~UnwinderScope() { ExitSymbolizerOrUnwider(); }
-
   UnwinderScope(const UnwinderScope &) = delete;
   UnwinderScope &operator=(const UnwinderScope &) = delete;
 };
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h b/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h
index b70686b06f4ef1..1bdf826aaa89e4 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_thread_registry.h
@@ -81,12 +81,11 @@ class ThreadContextBase {
   virtual void OnReset() {}
   virtual void OnDetached(void *arg) {}
 
- protected:
-  ~ThreadContextBase();
-
- private:
   ThreadContextBase(const ThreadContextBase &) = delete;
   ThreadContextBase &operator=(const ThreadContextBase &) = delete;
+
+ protected:
+  ~ThreadContextBase();
 };
 
 typedef ThreadContextBase* (*ThreadContextFactory)(u32 tid);

>From f7990c30c02c3dcbf9f9e585bb933c697d88aeea Mon Sep 17 00:00:00 2001
From: "Wu, Yingcong" <yingcong.wu at intel.com>
Date: Thu, 17 Oct 2024 23:14:35 -0700
Subject: [PATCH 3/3] updates

---
 .../ControlHeightReduction.cpp                | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
index 9c5f2e2142229b..d4ea11b55a4347 100644
--- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
+++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp
@@ -296,21 +296,20 @@ class CHR {
       delete Scope;
     }
   }
+  CHR(const CHR &) = delete;
+  CHR &operator=(const CHR &) = delete;
 
   bool run();
 
  private:
-   CHR(const CHR &) = delete;
-   CHR &operator=(const CHR &) = delete;
+  // See the comments in CHR::run() for the high level flow of the algorithm and
+  // what the following functions do.
 
-   // See the comments in CHR::run() for the high level flow of the algorithm
-   // and what the following functions do.
-
-   void findScopes(SmallVectorImpl<CHRScope *> &Output) {
-     Region *R = RI.getTopLevelRegion();
-     if (CHRScope *Scope = findScopes(R, nullptr, nullptr, Output)) {
-       Output.push_back(Scope);
-     }
+  void findScopes(SmallVectorImpl<CHRScope *> &Output) {
+    Region *R = RI.getTopLevelRegion();
+    if (CHRScope *Scope = findScopes(R, nullptr, nullptr, Output)) {
+      Output.push_back(Scope);
+    }
   }
   CHRScope *findScopes(Region *R, Region *NextRegion, Region *ParentRegion,
                         SmallVectorImpl<CHRScope *> &Scopes);



More information about the llvm-commits mailing list