23 for (
auto &
Iter : AllocationSites) {
24 auto &AllocSite =
Iter.second;
25 for (
auto &
Alloc : AllocSite.Allocations) {
37 B->Pointers =
nullptr;
42 AllocationSites.clear();
46 size_t NumElements,
unsigned EvalID,
58 size_t NumElements,
unsigned EvalID,
78 llvm::erase_if(DeadAllocations, [](Allocation &
Alloc) ->
bool {
79 return !
Alloc.block()->hasPointers();
83 std::make_unique<std::byte[]>(
sizeof(
Block) +
D->getAllocSize());
84 auto *B =
new (Memory.get())
Block(EvalID,
D,
false);
93 ID->IsFieldMutable =
false;
95 ID->IsInitialized =
false;
96 ID->IsVolatile =
false;
98 if (
D->isCompositeArray())
104 if (
auto It = AllocationSites.find(
D->asExpr());
105 It != AllocationSites.end()) {
106 It->second.Allocations.emplace_back(std::move(Memory));
107 B->setDynAllocId(It->second.NumAllocs);
108 ++It->second.NumAllocs;
110 AllocationSites.insert(
111 {
D->asExpr(), AllocationSite(std::move(Memory), AllocForm)});
114 assert(B->isDynamic());
120 auto It = AllocationSites.find(Source);
121 if (It == AllocationSites.end())
124 auto &Site = It->second;
125 assert(!Site.empty());
128 auto *AllocIt = llvm::find_if(Site.Allocations, [&](
const Allocation &A) {
129 return BlockToDelete == A.block();
132 assert(AllocIt != Site.Allocations.end());
134 Block *B = AllocIt->block();
146 B->AccessFlags |= Block::DeadFlag;
147 DeadAllocations.push_back(std::move(*AllocIt));
148 Site.Allocations.erase(AllocIt);
150 if (Site.size() == 0)
151 AllocationSites.erase(It);
156 Site.Allocations.erase(AllocIt);
158 AllocationSites.erase(It);
This represents one expression.
A memory block, either on the stack or in the heap.
void invokeDtor()
Invokes the Destructor.
void invokeCtor()
Invokes the constructor.
bool isInitialized() const
Returns whether the data of this block has been initialized via invoking the Ctor func.
bool hasPointers() const
Checks if the block has any live pointers.
bool deallocate(const Expr *Source, const Block *BlockToDelete, InterpState &S)
Deallocate the given source+block combination.
Block * allocate(const Descriptor *D, unsigned EvalID, Form AllocForm)
Allocate ONE element of the given descriptor.
A pointer to a memory block, live or dead.
const BlockPointer & asBlockPointer() const
PrimType
Enumeration of the primitive types of the VM.
bool Alloc(InterpState &S, CodePtr OpPC, const Descriptor *Desc)
The JSON file list parser is used to communicate input to InstallAPI.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(const_cast< Expr * >(T -> getSizeExpr())))
const FunctionProtoType * T
Pointer * Next
Next link in the pointer chain.
Block * Pointee
The block the pointer is pointing to.
Describes a memory block created by an allocation site.
unsigned getMetadataSize() const
Returns the size of the metadata.
static constexpr MetadataSize InlineDescMD
const Expr * asExpr() const
Inline descriptor embedded in structures and arrays.