9#ifndef LLVM_CLANG_AST_INTERP_DYNAMIC_ALLOCATOR_H
10#define LLVM_CLANG_AST_INTERP_DYNAMIC_ALLOCATOR_H
14#include "llvm/ADT/SmallVector.h"
15#include "llvm/ADT/iterator_range.h"
16#include "llvm/Support/Allocator.h"
35 std::unique_ptr<std::byte[]> Memory;
36 Allocation(std::unique_ptr<std::byte[]> Memory)
37 : Memory(std::move(Memory)) {}
40 struct AllocationSite {
42 bool IsArrayAllocation =
false;
44 AllocationSite(std::unique_ptr<std::byte[]> Memory,
bool Array)
45 : IsArrayAllocation(Array) {
46 Allocations.push_back({std::move(Memory)});
49 size_t size()
const {
return Allocations.size(); }
76 if (
auto It = AllocationSites.find(Source); It != AllocationSites.end())
77 return It->second.IsArrayAllocation;
83 llvm::DenseMap<const Expr *, AllocationSite>::const_iterator;
85 return llvm::make_range(AllocationSites.begin(), AllocationSites.end());
89 llvm::DenseMap<const Expr *, AllocationSite> AllocationSites;
91 using PoolAllocTy = llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator>;
92 PoolAllocTy DescAllocator;
95 template <
typename... Ts>
Descriptor *allocateDescriptor(Ts &&...Args) {
96 return new (DescAllocator)
Descriptor(std::forward<Ts>(Args)...);
This represents one expression.
A memory block, either on the stack or in the heap.
Manages dynamic memory allocations done during bytecode interpretation.
bool deallocate(const Expr *Source, const Block *BlockToDelete, InterpState &S)
Deallocate the given source+block combination.
bool isArrayAllocation(const Expr *Source) const
Checks whether the allocation done at the given source is an array allocation.
Block * allocate(const Descriptor *D, unsigned EvalID)
Allocate ONE element of the given descriptor.
llvm::iterator_range< const_virtual_iter > allocation_sites() const
unsigned getNumAllocations() const
llvm::DenseMap< const Expr *, AllocationSite >::const_iterator const_virtual_iter
Allocation site iterator.
DynamicAllocator()=default
PrimType
Enumeration of the primitive types of the VM.
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
Describes a memory block created by an allocation site.