[llvm] a919a3a - [CodeGen][NFC] Declare copy constructor & copy assignment as deleted for ScheduleDAG

Shengchen Kan via llvm-commits llvm-commits at lists.llvm.org
Fri May 26 18:36:17 PDT 2023


Author: Shengchen Kan
Date: 2023-05-27T09:36:10+08:00
New Revision: a919a3a1e739ce18d6c3026c553846544c2168e8

URL: https://github.com/llvm/llvm-project/commit/a919a3a1e739ce18d6c3026c553846544c2168e8
DIFF: https://github.com/llvm/llvm-project/commit/a919a3a1e739ce18d6c3026c553846544c2168e8.diff

LOG: [CodeGen][NFC] Declare copy constructor & copy assignment as deleted for ScheduleDAG

ScheduleDAG has derived classes ScheduleDAGVLIW and ScheduleDAGRRList,
which own resources that are freed in their destructors. Static analyzer
warns b/c they do not have user-written copy constructors.

According to the design of ScheduleDAG, it seems that it should always
be passed by reference. So I declare them as deleted in this patch.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D151538

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/ScheduleDAG.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/CodeGen/ScheduleDAG.h b/llvm/include/llvm/CodeGen/ScheduleDAG.h
index 50fff79d26236..89b71167a43a8 100644
--- a/llvm/include/llvm/CodeGen/ScheduleDAG.h
+++ b/llvm/include/llvm/CodeGen/ScheduleDAG.h
@@ -568,6 +568,15 @@ class TargetRegisterInfo;
     bool StressSched;
 #endif
 
+    // This class is designed to be passed by reference only. Copy constructor
+    // is declared as deleted here to make the derived classes have deleted
+    // implicit-declared copy constructor, which suppresses the warnings from
+    // static analyzer when the derived classes own resources that are freed in
+    // their destructors, but don't have user-written copy constructors (rule
+    // of three).
+    ScheduleDAG(const ScheduleDAG &) = delete;
+    ScheduleDAG &operator=(const ScheduleDAG &) = delete;
+
     explicit ScheduleDAG(MachineFunction &mf);
 
     virtual ~ScheduleDAG();


        


More information about the llvm-commits mailing list