File tree Expand file tree Collapse file tree
include/phasar/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/ExtendedTaintAnalysis
lib/PhasarLLVM/DataFlowSolver/IfdsIde/Problems/ExtendedTaintAnalysis Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,7 +38,9 @@ struct AbstractMemoryLoactionStorage : public llvm::FoldingSetNode {
3838 const llvm::Value *Baseptr;
3939 uint32_t Lifetime;
4040 uint32_t NumOffsets;
41- ptrdiff_t Offsets[0 ]; // NOLINT
41+ // / The actual length of Offsets is a runtime-constant determined by
42+ // / NumOffsets. Note, that NumOffsets can be larger than 1
43+ ptrdiff_t Offsets[1 ]; // NOLINT
4244
4345protected:
4446 AbstractMemoryLoactionStorage (
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class AbstractMemoryLocationFactoryBase {
3737 struct Allocator {
3838 struct Block {
3939 Block *Next = nullptr ;
40- void *Data[0 ];
40+ void *Data[1 ]; // NOLINT
4141
4242 static Block *create (Block *Next, size_t NumPointerEntries);
4343 static void destroy (Block *Blck);
@@ -49,18 +49,23 @@ class AbstractMemoryLocationFactoryBase {
4949 Block *Root = nullptr ;
5050 void **Pos = nullptr , **End = nullptr ;
5151
52- Allocator () = default ;
52+ Allocator () noexcept = default ;
5353 Allocator (size_t InitialCapacity);
54+ Allocator (const Allocator &) = delete ;
55+ Allocator (Allocator &&Other) noexcept ;
5456 ~Allocator ();
5557
58+ Allocator &operator =(const Allocator &) = delete ;
59+ Allocator &operator =(Allocator &&Other) noexcept ;
60+
5661 AbstractMemoryLocationImpl *create (const llvm::Value *Baseptr,
5762 size_t Lifetime,
5863 llvm::ArrayRef<ptrdiff_t > Offsets);
5964
6065 private:
6166 constexpr static size_t ExpectedNumAmLsPerBlock = 1024 ;
6267 constexpr static size_t MinNumPointersPerAML =
63- sizeof (AbstractMemoryLocationImpl) / sizeof (void *);
68+ offsetof (AbstractMemoryLocationImpl, Offsets ) / sizeof (void *);
6469 constexpr static size_t NumPointersPerBlock =
6570 (MinNumPointersPerAML + 3 ) * ExpectedNumAmLsPerBlock;
6671 };
Original file line number Diff line number Diff line change 1717
1818namespace psr ::detail {
1919
20+ // / We intentionally don't initialize the Data member as it will be a dynamic
21+ // / array at runtime
22+ // NOLINTNEXTLINE (cppcoreguidelines-pro-type-member-init)
2023AbstractMemoryLocationFactoryBase::Allocator::Block::Block (Block *Next)
2124 : Next(Next) {}
2225
@@ -34,6 +37,11 @@ auto AbstractMemoryLocationFactoryBase::Allocator::Block::create(
3437 std::terminate ();
3538 }
3639
40+ static_assert (
41+ alignof (AbstractMemoryLocationImpl) == alignof (size_t ),
42+ " The alignment of the AbstractMemoryLocationImpl allocation cannot be "
43+ " guaranteed as it differs from the alignment of size_t" );
44+
3745 auto *Ret = reinterpret_cast <Block *>(new size_t [1 + NumPointerEntries]);
3846
3947 new (Ret) Block (Next);
@@ -69,6 +77,21 @@ AbstractMemoryLocationFactoryBase::Allocator::~Allocator() {
6977 End = nullptr ;
7078}
7179
80+ AbstractMemoryLocationFactoryBase::Allocator::Allocator (
81+ Allocator &&Other) noexcept
82+ : Root(Other.Root), Pos(Other.Pos), End(Other.End) {
83+ Other.Root = nullptr ;
84+ Other.Pos = nullptr ;
85+ Other.End = nullptr ;
86+ }
87+
88+ auto AbstractMemoryLocationFactoryBase::Allocator::operator =(
89+ Allocator &&Other) noexcept -> Allocator & {
90+ this ->Allocator ::~Allocator ();
91+ new (this ) Allocator (std::move (Other));
92+ return *this ;
93+ }
94+
7295AbstractMemoryLocationImpl *
7396AbstractMemoryLocationFactoryBase::Allocator::create (
7497 const llvm::Value *Baseptr, size_t Lifetime,
You can’t perform that action at this time.
0 commit comments