aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/FileCheck/FileCheckImpl.h
diff options
context:
space:
mode:
authorAlex Zinenko <zinenko@google.com>2021-03-12 12:19:47 +0100
committerAlex Zinenko <zinenko@google.com>2021-03-12 18:52:14 +0100
commit4affd0c40eccbce921f185e1e09f84f8194cd4cf (patch)
tree02992f89635e122cbe69118c27636c664c057307 /llvm/lib/FileCheck/FileCheckImpl.h
parent1ce2b584543a6ae350d976ec3db667e7265ee3fe (diff)
downloadllvm-4affd0c40eccbce921f185e1e09f84f8194cd4cf.zip
llvm-4affd0c40eccbce921f185e1e09f84f8194cd4cf.tar.gz
llvm-4affd0c40eccbce921f185e1e09f84f8194cd4cf.tar.bz2
[mlir] fix a memory leak in NestedPattern
NestedPattern uses a BumpPtrAllocator to store child (nested) pattern objects to decrease the overhead of dynamic allocation. This assumes all allocations happen inside the allocator that will be freed as a whole. However, NestedPattern contains `std::function` as a member, which allocates internally using `new`, unaware of the BumpPtrAllocator. Since NestedPattern only holds pointers to the nested patterns allocated in the BumpPtrAllocator, it never calls their destructors, so the destructor of the `std::function`s they contain are never called either, leaking the allocated memory. Make NestedPattern explicitly call destructors of nested patterns. This additionally requires to actually copy the nested patterns in copy-construction and copy-assignment instead of just sharing the pointer to the arena-allocated list of children to avoid double-free. An alternative solution would be to add reference counting to the list of arena-allocated list of children. Reviewed By: nicolasvasilache Differential Revision: https://reviews.llvm.org/D98485
Diffstat (limited to 'llvm/lib/FileCheck/FileCheckImpl.h')
0 files changed, 0 insertions, 0 deletions