[PATCH] D156975: [NFC][clang] Fix static analyzer concerns
Mariya Podchishchaeva via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 3 02:21:16 PDT 2023
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 {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156975.546762.patch
Type: text/x-patch
Size: 1129 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230803/0f10435e/attachment.bin>
More information about the cfe-commits
mailing list