[NFC][Clang] Fix static analyzer tool remark about missing user-defined assignment...
authorManna, Soumi <soumi.manna@intel.com>
Tue, 18 Apr 2023 02:21:03 +0000 (22:21 -0400)
committerManna, Soumi <soumi.manna@intel.com>
Tue, 18 Apr 2023 02:21:30 +0000 (22:21 -0400)
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

clang/lib/Analysis/UnsafeBufferUsage.cpp

index ff81814..9908149 100644 (file)
@@ -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;