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 enum class Form : uint8_t {
43 std::unique_ptr<std::byte[]> Memory;
44 Allocation(std::unique_ptr<std::byte[]> Memory)
45 : Memory(
std::move(Memory)) {}
48 struct AllocationSite {
52 AllocationSite(std::unique_ptr<std::byte[]> Memory,
Form AllocForm)
53 : AllocForm(AllocForm) {
54 Allocations.push_back({std::move(Memory)});
57 size_t size()
const {
return Allocations.size(); }
72 unsigned EvalID,
Form AllocForm);
85 if (
auto It = AllocationSites.find(Source); It != AllocationSites.end())
86 return It->second.AllocForm;
92 llvm::DenseMap<const Expr *, AllocationSite>::const_iterator;
94 return llvm::make_range(AllocationSites.begin(), AllocationSites.end());
98 llvm::DenseMap<const Expr *, AllocationSite> AllocationSites;
100 using PoolAllocTy = llvm::BumpPtrAllocator;
101 PoolAllocTy DescAllocator;
104 template <
typename... Ts>
Descriptor *allocateDescriptor(Ts &&...Args) {
105 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.
llvm::iterator_range< const_virtual_iter > allocation_sites() const
std::optional< Form > getAllocationForm(const Expr *Source) const
Checks whether the allocation done at the given source is an array allocation.
unsigned getNumAllocations() const
llvm::DenseMap< const Expr *, AllocationSite >::const_iterator const_virtual_iter
Allocation site iterator.
DynamicAllocator()=default
Block * allocate(const Descriptor *D, unsigned EvalID, Form AllocForm)
Allocate ONE element of the given descriptor.
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.