13#ifndef LLVM_CLANG_AST_INTERP_BLOCK_H
14#define LLVM_CLANG_AST_INTERP_BLOCK_H
17#include "llvm/Support/raw_ostream.h"
46 static constexpr uint8_t ExternFlag = 1 << 0;
47 static constexpr uint8_t DeadFlag = 1 << 1;
48 static constexpr uint8_t WeakFlag = 1 << 2;
49 static constexpr uint8_t DummyFlag = 1 << 3;
54 bool IsStatic =
false,
bool IsExtern =
false,
bool IsWeak =
false,
56 : Desc(Desc), DeclID(DeclID), EvalID(EvalID), IsStatic(IsStatic) {
58 AccessFlags |= (ExternFlag * IsExtern);
59 AccessFlags |= (WeakFlag * IsWeak);
60 AccessFlags |= (DummyFlag * IsDummy);
64 bool IsExtern =
false,
bool IsWeak =
false,
bool IsDummy =
false)
65 : Desc(Desc), EvalID(EvalID), IsStatic(IsStatic) {
67 AccessFlags |= (ExternFlag * IsExtern);
68 AccessFlags |= (WeakFlag * IsWeak);
69 AccessFlags |= (DummyFlag * IsDummy);
77 bool isExtern()
const {
return AccessFlags & ExternFlag; }
82 bool isWeak()
const {
return AccessFlags & WeakFlag; }
83 bool isDynamic()
const {
return (DynAllocId != std::nullopt); }
84 bool isDummy()
const {
return AccessFlags & DummyFlag; }
85 bool isDead()
const {
return AccessFlags & DeadFlag; }
103 const std::byte *
data()
const {
112 return reinterpret_cast<std::byte *
>(
this) +
sizeof(
Block);
115 return reinterpret_cast<const std::byte *
>(
this) +
sizeof(
Block);
119 return *
reinterpret_cast<const T *
>(
data());
124 assert(!IsInitialized);
131 IsInitialized =
true;
136 assert(IsInitialized);
139 IsInitialized =
false;
143 void dump(llvm::raw_ostream &OS)
const;
155 bool IsWeak,
bool IsDummy,
bool IsDead)
158 AccessFlags |= (ExternFlag * IsExtern);
159 AccessFlags |= (DeadFlag * IsDead);
160 AccessFlags |= (WeakFlag * IsWeak);
161 AccessFlags |= (DummyFlag * IsDummy);
165 void setDynAllocId(
unsigned ID) { DynAllocId =
ID; }
175 bool hasPointer(
const Pointer *
P)
const;
179 const Descriptor *Desc;
184 const unsigned EvalID = ~0u;
189 bool IsInitialized =
false;
193 uint8_t AccessFlags = 0;
A memory block, either on the stack or in the heap.
unsigned getSize() const
Returns the size of the block.
void invokeDtor()
Invokes the Destructor.
bool isExtern() const
Checks if the block is extern.
std::byte * data()
Returns a pointer to the stored data.
const Descriptor * getDescriptor() const
Returns the block's descriptor.
Block(unsigned EvalID, const Descriptor *Desc, bool IsStatic=false, bool IsExtern=false, bool IsWeak=false, bool IsDummy=false)
const std::byte * rawData() const
void invokeCtor()
Invokes the constructor.
bool isStatic() const
Checks if the block has static storage duration.
Block(unsigned EvalID, UnsignedOrNone DeclID, const Descriptor *Desc, bool IsStatic=false, bool IsExtern=false, bool IsWeak=false, bool IsDummy=false)
Creates a new block.
bool isTemporary() const
Checks if the block is temporary.
std::byte * rawData()
Returns a pointer to the raw data, including metadata.
const std::byte * data() const
bool isInitialized() const
Returns whether the data of this block has been initialized via invoking the Ctor func.
UnsignedOrNone getDeclID() const
Returns the declaration ID.
unsigned getEvalID() const
The Evaluation ID this block was created in.
bool isAccessible() const
bool hasPointers() const
Checks if the block has any live pointers.
Descriptor for a dead block.
std::byte * data()
Returns a pointer to the stored data.
Manages dynamic memory allocations done during bytecode interpretation.
A pointer to a memory block, live or dead.
The program contains and links the bytecode for all functions.
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.
const bool IsConst
Flag indicating if the block is mutable.
unsigned getAllocSize() const
Returns the allocated size, including metadata.
const BlockCtorFn CtorFn
Storage management methods.
unsigned getMetadataSize() const
Returns the size of the metadata.
const bool IsMutable
Flag indicating if a field is mutable.
const bool IsTemporary
Flag indicating if the block is a temporary.