[clang] 5ebff1a - [NFC][Clang] Fix Coverity issues of copy without assign

via cfe-commits cfe-commits at lists.llvm.org
Sun May 14 19:56:57 PDT 2023


Author: Manna, Soumi
Date: 2023-05-14T19:49:28-07:00
New Revision: 5ebff1ac1b986c6b5317aaf5ab6c4830a711067a

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

LOG: [NFC][Clang] Fix Coverity issues of copy without assign

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

Reviewed By: tahonermann

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

Added: 
    

Modified: 
    clang/include/clang/Analysis/BodyFarm.h
    clang/include/clang/Sema/ParsedAttr.h
    clang/lib/Analysis/UnsafeBufferUsage.cpp
    clang/lib/Serialization/ASTWriterStmt.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Analysis/BodyFarm.h b/clang/include/clang/Analysis/BodyFarm.h
index eaa6472433dde..52be29cb7885e 100644
--- a/clang/include/clang/Analysis/BodyFarm.h
+++ b/clang/include/clang/Analysis/BodyFarm.h
@@ -40,6 +40,9 @@ class BodyFarm {
   /// Remove copy constructor to avoid accidental copying.
   BodyFarm(const BodyFarm &other) = delete;
 
+  /// Delete copy assignment operator.
+  BodyFarm &operator=(const BodyFarm &other) = delete;
+
 private:
   typedef llvm::DenseMap<const Decl *, std::optional<Stmt *>> BodyMap;
 

diff  --git a/clang/include/clang/Sema/ParsedAttr.h b/clang/include/clang/Sema/ParsedAttr.h
index 345c3c89edca7..837725c079807 100644
--- a/clang/include/clang/Sema/ParsedAttr.h
+++ b/clang/include/clang/Sema/ParsedAttr.h
@@ -696,11 +696,13 @@ class AttributePool {
   AttributePool(AttributeFactory &factory) : Factory(factory) {}
 
   AttributePool(const AttributePool &) = delete;
+  AttributePool &operator=(const AttributePool &) = delete;
 
   ~AttributePool() { Factory.reclaimPool(*this); }
 
   /// Move the given pool's allocations to this pool.
   AttributePool(AttributePool &&pool) = default;
+  AttributePool &operator=(AttributePool &&pool) = default;
 
   AttributeFactory &getFactory() const { return Factory; }
 
@@ -912,6 +914,7 @@ class ParsedAttributes : public ParsedAttributesView {
 public:
   ParsedAttributes(AttributeFactory &factory) : pool(factory) {}
   ParsedAttributes(const ParsedAttributes &) = delete;
+  ParsedAttributes &operator=(const ParsedAttributes &) = delete;
 
   AttributePool &getPool() const { return pool; }
 

diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 7871fed519b98..700a09445b508 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -762,7 +762,9 @@ class Strategy {
 public:
   Strategy() = default;
   Strategy(const Strategy &) = delete; // Let's avoid copies.
+  Strategy &operator=(const Strategy &) = delete;
   Strategy(Strategy &&) = default;
+  Strategy &operator=(Strategy &&) = default;
 
   void set(const VarDecl *VD, Kind K) { Map[VD] = K; }
 

diff  --git a/clang/lib/Serialization/ASTWriterStmt.cpp b/clang/lib/Serialization/ASTWriterStmt.cpp
index 90c30fce0a8e7..363f7569acd3e 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -42,6 +42,7 @@ namespace clang {
           Code(serialization::STMT_NULL_PTR), AbbrevToUse(0) {}
 
     ASTStmtWriter(const ASTStmtWriter&) = delete;
+    ASTStmtWriter &operator=(const ASTStmtWriter &) = delete;
 
     uint64_t Emit() {
       assert(Code != serialization::STMT_NULL_PTR &&


        


More information about the cfe-commits mailing list