Skip to content

Commit

Permalink
[NFC][clang] Fix static analyzer concerns
Browse files Browse the repository at this point in the history
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.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D156975
  • Loading branch information
Fznamznon committed Aug 3, 2023
1 parent f887cb1 commit 25d6f9d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions clang/include/clang/AST/APValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,25 +270,33 @@ class APValue {
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 {
APValue *Elts;
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 {
Expand Down

0 comments on commit 25d6f9d

Please sign in to comment.