[clang] 7e1b62b - [NFC][Clang] Fix static analyzer tool remark about missing user-defined assignment operator

via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 17 19:25:15 PDT 2023


Author: Manna, Soumi
Date: 2023-04-17T22:21:30-04:00
New Revision: 7e1b62bd9ca8ab34444c3307e19abecdd482210f

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

LOG: [NFC][Clang] Fix static analyzer tool remark about missing user-defined assignment operator

Reported by Coverity:

Copy without assign
This class has a user-defined copy constructor but no user-defined assignment operator. If the copy constructor is necessary to manage owned resources then a corresponding assignment operator is usually required. If an object of this type is assigned memory leaks and/or use-after-free errors may occur. Note that a compiler-generated assignment operator will perform only a bit-wise copy for any fields that do not have their own assignment operators defined.

Class has user-written copy constructor but no user-written assignment operator

copy_without_assign: Class <unnamed>::DeclUseTracker has a user-written copy constructor <unnamed>::DeclUseTracker::DeclUseTracker(<unnamed>::DeclUseTracker const &) =delete but no corresponding user-written assignment operator.

Reviewed By: aaron.ballman

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

Added: 
    

Modified: 
    clang/lib/Analysis/UnsafeBufferUsage.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index ff818140b2d8..99081490848e 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -645,6 +645,7 @@ class DeclUseTracker {
 public:
   DeclUseTracker() = default;
   DeclUseTracker(const DeclUseTracker &) = delete; // Let's avoid copies.
+  DeclUseTracker &operator=(const DeclUseTracker &) = delete;
   DeclUseTracker(DeclUseTracker &&) = default;
   DeclUseTracker &operator=(DeclUseTracker &&) = default;
 


        


More information about the cfe-commits mailing list