Skip to content

Commit

Permalink
[NFC][Clang] Fix static analyzer tool remark about missing user-defin…
Browse files Browse the repository at this point in the history
…ed 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
  • Loading branch information
smanna12 committed Apr 18, 2023
1 parent cf8d684 commit 7e1b62b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions clang/lib/Analysis/UnsafeBufferUsage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 7e1b62b

Please sign in to comment.