[clang] [Clang][Codegen][NFC] Apply rule of three to some classes (PR #154671)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 20 22:31:24 PDT 2025


https://github.com/shafik created https://github.com/llvm/llvm-project/pull/154671

Static analysis flagged these classes as having implemented the destructor but not applying rule of three. This could lead to accidental misuse and so it makes sense to apply it.

>From 41d7218a6586834bbbb482ea6c8e60546af95c0a Mon Sep 17 00:00:00 2001
From: Shafik Yaghmour <shafik.yaghmour at intel.com>
Date: Wed, 20 Aug 2025 22:28:33 -0700
Subject: [PATCH] [Clang][Codegen][NFC] Apply rule of three to some classes

Static analysis flagged these classes as having implemented the destructor but
not applying rule of three. This could lead to accidental misuse and so it makes
sense to apply it.
---
 clang/lib/CodeGen/CGDebugInfo.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h
index 497d3a6ab17b1..ff9c3cd2d1136 100644
--- a/clang/lib/CodeGen/CGDebugInfo.h
+++ b/clang/lib/CodeGen/CGDebugInfo.h
@@ -977,6 +977,8 @@ class ApplyInlineDebugLocation {
   ApplyInlineDebugLocation(CodeGenFunction &CGF, GlobalDecl InlinedFn);
   /// Restore everything back to the original state.
   ~ApplyInlineDebugLocation();
+  ApplyInlineDebugLocation(const ApplyInlineDebugLocation &) = delete;
+  ApplyInlineDebugLocation &operator=(ApplyInlineDebugLocation &) = delete;
 };
 
 class SanitizerDebugLocation {
@@ -988,6 +990,8 @@ class SanitizerDebugLocation {
                          ArrayRef<SanitizerKind::SanitizerOrdinal> Ordinals,
                          SanitizerHandler Handler);
   ~SanitizerDebugLocation();
+  SanitizerDebugLocation(const SanitizerDebugLocation &) = delete;
+  SanitizerDebugLocation &operator=(SanitizerDebugLocation &) = delete;
 };
 
 } // namespace CodeGen



More information about the cfe-commits mailing list