[NFC][Clang][Coverity] Fix Static Code Analysis Concerns with copy without assign

This patch adds copy/move assignment operator to the class which has user-defined copy/move constructor.

Reviewed By: tahonermann, NoQ, aaronpuchert

Differential Revision: https://reviews.llvm.org/D150411
This commit is contained in:
Manna, Soumi 2023-05-18 18:13:58 -07:00
parent 8f061edef8
commit b4fbc4bdbf
15 changed files with 92 additions and 2 deletions

View File

@ -3210,7 +3210,6 @@ private:
public:
ObjCEncOptions() : Bits(0) {}
ObjCEncOptions(const ObjCEncOptions &RHS) : Bits(RHS.Bits) {}
#define OPT_LIST(V) \
V(ExpandPointedToStructures, 0) \

View File

@ -155,6 +155,10 @@ namespace consumed {
ConsumedStateMap(const ConsumedStateMap &Other)
: Reachable(Other.Reachable), From(Other.From), VarMap(Other.VarMap) {}
// The copy assignment operator is defined as deleted pending further
// motivation.
ConsumedStateMap &operator=(const ConsumedStateMap &) = delete;
/// Warn if any of the parameters being tracked are not in the state
/// they were declared to be in upon return from a function.
void checkParamsForReturnTypestate(SourceLocation BlameLoc,

View File

@ -488,6 +488,10 @@ public:
Undefined(const Stmt *S = nullptr) : SExpr(COP_Undefined), Cstmt(S) {}
Undefined(const Undefined &U) : SExpr(U), Cstmt(U.Cstmt) {}
// The copy assignment operator is defined as deleted pending further
// motivation.
Undefined &operator=(const Undefined &) = delete;
static bool classof(const SExpr *E) { return E->opcode() == COP_Undefined; }
template <class V>
@ -566,6 +570,10 @@ public:
LiteralT(T Dat) : Literal(ValueType::getValueType<T>()), Val(Dat) {}
LiteralT(const LiteralT<T> &L) : Literal(L), Val(L.Val) {}
// The copy assignment operator is defined as deleted pending further
// motivation.
LiteralT &operator=(const LiteralT<T> &) = delete;
T value() const { return Val;}
T& value() { return Val; }

View File

@ -240,6 +240,10 @@ class CopyOnWriteVector {
VectorData() = default;
VectorData(const VectorData &VD) : Vect(VD.Vect) {}
// The copy assignment operator is defined as deleted pending further
// motivation.
VectorData &operator=(const VectorData &) = delete;
};
public:

View File

@ -42,6 +42,15 @@ public:
Other.Alloc.setPointer(nullptr);
}
// The move assignment operator is defined as deleted pending further
// motivation.
BumpVectorContext &operator=(BumpVectorContext &&) = delete;
// The copy constrcutor and copy assignment operator is defined as deleted
// pending further motivation.
BumpVectorContext(const BumpVectorContext &) = delete;
BumpVectorContext &operator=(const BumpVectorContext &) = delete;
/// Construct a new BumpVectorContext that reuses an existing
/// BumpPtrAllocator. This BumpPtrAllocator is not destroyed when the
/// BumpVectorContext object is destroyed.

View File

@ -181,6 +181,10 @@ public:
RewriteRope() = default;
RewriteRope(const RewriteRope &RHS) : Chunks(RHS.Chunks) {}
// The copy assignment operator is defined as deleted pending further
// motivation.
RewriteRope &operator=(const RewriteRope &) = delete;
using iterator = RopePieceBTree::iterator;
using const_iterator = RopePieceBTree::iterator;

View File

@ -657,6 +657,15 @@ public:
F.CalledDone = true;
}
// The move assignment operator is defined as deleted pending
// further motivation.
Filter &operator=(Filter &&) = delete;
// The copy constrcutor and copy assignment operator is defined as deleted
// pending further motivation.
Filter(const Filter &) = delete;
Filter &operator=(const Filter &) = delete;
~Filter() {
assert(CalledDone &&
"LookupResult::Filter destroyed without done() call");

View File

@ -696,6 +696,8 @@ public:
AttributePool(AttributeFactory &factory) : Factory(factory) {}
AttributePool(const AttributePool &) = delete;
// The copy assignment operator is defined as deleted pending further
// motivation.
AttributePool &operator=(const AttributePool &) = delete;
~AttributePool() { Factory.reclaimPool(*this); }
@ -703,6 +705,10 @@ public:
/// Move the given pool's allocations to this pool.
AttributePool(AttributePool &&pool) = default;
// The move assignment operator is defined as deleted pending further
// motivation.
AttributePool &operator=(AttributePool &&pool) = delete;
AttributeFactory &getFactory() const { return Factory; }
void clear() {

View File

@ -1787,6 +1787,12 @@ public:
const FunctionDecl *Fn, Sema &S);
SemaDiagnosticBuilder(SemaDiagnosticBuilder &&D);
SemaDiagnosticBuilder(const SemaDiagnosticBuilder &) = default;
// The copy and move assignment operator is defined as deleted pending
// further motivation.
SemaDiagnosticBuilder &operator=(const SemaDiagnosticBuilder &) = delete;
SemaDiagnosticBuilder &operator=(SemaDiagnosticBuilder &&) = delete;
~SemaDiagnosticBuilder();
bool isImmediate() const { return ImmediateDiag.has_value(); }

View File

@ -51,6 +51,12 @@ public:
BugReporterVisitor() = default;
BugReporterVisitor(const BugReporterVisitor &) = default;
BugReporterVisitor(BugReporterVisitor &&) {}
// The copy and move assignment operator is defined as deleted pending further
// motivation.
BugReporterVisitor &operator=(const BugReporterVisitor &) = delete;
BugReporterVisitor &operator=(BugReporterVisitor &&) = delete;
virtual ~BugReporterVisitor();
/// Return a diagnostic piece which should be associated with the

View File

@ -672,6 +672,11 @@ public:
SymbolVisitor(const SymbolVisitor &) = default;
SymbolVisitor(SymbolVisitor &&) {}
// The copy and move assignment operator is defined as deleted pending further
// motivation.
SymbolVisitor &operator=(const SymbolVisitor &) = delete;
SymbolVisitor &operator=(SymbolVisitor &&) = delete;
/// A visitor method invoked by ProgramStateManager::scanReachableSymbols.
///
/// The method returns \c true if symbols should continue be scanned and \c

View File

@ -829,7 +829,13 @@ public:
ApplyDebugLocation(ApplyDebugLocation &&Other) : CGF(Other.CGF) {
Other.CGF = nullptr;
}
ApplyDebugLocation &operator=(ApplyDebugLocation &&) = default;
// Define copy assignment operator.
ApplyDebugLocation &operator=(ApplyDebugLocation &&Other) {
CGF = Other.CGF;
Other.CGF = nullptr;
return *this;
}
~ApplyDebugLocation();

View File

@ -148,6 +148,12 @@ public:
public:
Cleanup(const Cleanup &) = default;
Cleanup(Cleanup &&) {}
// The copy and move assignment operator is defined as deleted pending
// further motivation.
Cleanup &operator=(const Cleanup &) = delete;
Cleanup &operator=(Cleanup &&) = delete;
Cleanup() = default;
virtual bool isRedundantBeforeReturn() { return false; }

View File

@ -199,6 +199,16 @@ struct AccessTarget : public AccessedEntity {
: Target(S.Target), Has(S.Has) {
S.Target = nullptr;
}
// The move assignment operator is defined as deleted pending further
// motivation.
SavedInstanceContext &operator=(SavedInstanceContext &&) = delete;
// The copy constrcutor and copy assignment operator is defined as deleted
// pending further motivation.
SavedInstanceContext(const SavedInstanceContext &) = delete;
SavedInstanceContext &operator=(const SavedInstanceContext &) = delete;
~SavedInstanceContext() {
if (Target)
Target->HasInstanceContext = Has;

View File

@ -653,6 +653,14 @@ private:
Root(O.Root) {
O.Root = nullptr;
}
// The move assignment operator is defined as deleted pending further
// motivation.
DiagText &operator=(DiagText &&) = delete;
// The copy constrcutor and copy assignment operator is defined as deleted
// pending further motivation.
DiagText(const DiagText &) = delete;
DiagText &operator=(const DiagText &) = delete;
~DiagText() {
for (Piece *P : AllocatedPieces)