Fznamznon created this revision.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a project: All.
Fznamznon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A bunch of classes in APValue free resources in the destructor but don't
have user-written copy c'tor or assignment operator, so copying them using
default ones can cause double free.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156975

Files:
  clang/include/clang/AST/APValue.h


Index: clang/include/clang/AST/APValue.h
===================================================================
--- clang/include/clang/AST/APValue.h
+++ clang/include/clang/AST/APValue.h
@@ -270,12 +270,16 @@
     APValue *Elts = nullptr;
     unsigned NumElts = 0;
     Vec() = default;
+    Vec(const Vec &) = delete;
+    Vec &operator=(const Vec &) = delete;
     ~Vec() { delete[] Elts; }
   };
   struct Arr {
     APValue *Elts;
     unsigned NumElts, ArrSize;
     Arr(unsigned NumElts, unsigned ArrSize);
+    Arr(const Arr &) = delete;
+    Arr &operator=(const Arr &) = delete;
     ~Arr();
   };
   struct StructData {
@@ -283,12 +287,16 @@
     unsigned NumBases;
     unsigned NumFields;
     StructData(unsigned NumBases, unsigned NumFields);
+    StructData(const StructData &) = delete;
+    StructData &operator=(const StructData &) = delete;
     ~StructData();
   };
   struct UnionData {
     const FieldDecl *Field;
     APValue *Value;
     UnionData();
+    UnionData(const UnionData &) = delete;
+    UnionData &operator=(const UnionData &) = delete;
     ~UnionData();
   };
   struct AddrLabelDiffData {


Index: clang/include/clang/AST/APValue.h
===================================================================
--- clang/include/clang/AST/APValue.h
+++ clang/include/clang/AST/APValue.h
@@ -270,12 +270,16 @@
     APValue *Elts = nullptr;
     unsigned NumElts = 0;
     Vec() = default;
+    Vec(const Vec &) = delete;
+    Vec &operator=(const Vec &) = delete;
     ~Vec() { delete[] Elts; }
   };
   struct Arr {
     APValue *Elts;
     unsigned NumElts, ArrSize;
     Arr(unsigned NumElts, unsigned ArrSize);
+    Arr(const Arr &) = delete;
+    Arr &operator=(const Arr &) = delete;
     ~Arr();
   };
   struct StructData {
@@ -283,12 +287,16 @@
     unsigned NumBases;
     unsigned NumFields;
     StructData(unsigned NumBases, unsigned NumFields);
+    StructData(const StructData &) = delete;
+    StructData &operator=(const StructData &) = delete;
     ~StructData();
   };
   struct UnionData {
     const FieldDecl *Field;
     APValue *Value;
     UnionData();
+    UnionData(const UnionData &) = delete;
+    UnionData &operator=(const UnionData &) = delete;
     ~UnionData();
   };
   struct AddrLabelDiffData {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D156975: [NF... Mariya Podchishchaeva via Phabricator via cfe-commits

Reply via email to