13 #ifndef LLVM_CLANG_AST_INTERP_DESCRIPTOR_H
14 #define LLVM_CLANG_AST_INTERP_DESCRIPTOR_H
27 using DeclTy = llvm::PointerUnion<const Decl *, const Expr *>;
28 using InitMapPtr = std::optional<std::pair<bool, std::shared_ptr<InitMap>>>;
34 bool IsMutable,
bool IsActive,
47 std::byte *DstFieldPtr,
62 LLVM_PREFERRED_TYPE(
bool)
68 LLVM_PREFERRED_TYPE(
bool)
71 LLVM_PREFERRED_TYPE(
bool)
74 LLVM_PREFERRED_TYPE(
bool)
77 LLVM_PREFERRED_TYPE(
bool)
87 void dump(llvm::raw_ostream &OS)
const;
96 const unsigned ElemSize;
100 const unsigned MDSize;
102 const unsigned AllocSize;
105 static constexpr
unsigned UnknownSizeMark = (
unsigned)-1;
121 const std::optional<PrimType>
PrimT = std::nullopt;
177 return dyn_cast_if_present<ValueDecl>(
asDecl());
181 return dyn_cast_if_present<VarDecl>(
asDecl());
185 return dyn_cast_if_present<FieldDecl>(
asDecl());
189 return dyn_cast_if_present<RecordDecl>(
asDecl());
235 void dump(llvm::raw_ostream &OS)
const;
254 T *data() {
return Data.get(); }
255 const T *data()
const {
return Data.get(); }
258 bool initializeElement(
unsigned I);
261 bool isElementInitialized(
unsigned I)
const;
263 static constexpr
size_t numFields(
unsigned N) {
264 return (N + PER_FIELD - 1) / PER_FIELD;
267 unsigned UninitFields;
268 std::unique_ptr<T[]>
Data;
llvm::MachO::Record Record
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
Represents a member of a struct/union/class.
A (possibly-)qualified type.
Represents a struct/union/class.
Encodes a location in the source.
The base class of the type hierarchy.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
A memory block, either on the stack or in the heap.
A pointer to a memory block, live or dead.
Structure/Class descriptor.
std::optional< std::pair< bool, std::shared_ptr< InitMap > >> InitMapPtr
void(*)(Block *Storage, std::byte *FieldPtr, const Descriptor *FieldDesc) BlockDtorFn
Invoked when a block is destroyed.
unsigned llvm::PointerUnion< const Decl *, const Expr * > DeclTy
PrimType
Enumeration of the primitive types of the VM.
void(*)(Block *Storage, const std::byte *SrcFieldPtr, std::byte *DstFieldPtr, const Descriptor *FieldDesc) BlockMoveFn
Invoked when a block with pointers referencing it goes out of scope.
void(*)(Block *Storage, std::byte *FieldPtr, bool IsConst, bool IsMutable, bool IsActive, const Descriptor *FieldDesc) BlockCtorFn
Invoked whenever a block is created.
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
Token to denote structures of unknown size.
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.
unsigned getNumElems() const
Returns the number of elements stored in the block.
unsigned getSize() const
Returns the size of the object without metadata.
void makeDummy()
Make this descriptor a dummy descriptor.
bool isPrimitive() const
Checks if the descriptor is of a primitive.
QualType getElemQualType() const
const Expr * asExpr() const
bool isCompositeArray() const
Checks if the descriptor is of an array of composites.
const ValueDecl * asValueDecl() const
const BlockCtorFn CtorFn
Storage management methods.
const Decl * asDecl() const
const FieldDecl * asFieldDecl() const
const Descriptor *const ElemDesc
Descriptor of the array element.
bool isDummy() const
Checks if this is a dummy descriptor.
unsigned getMetadataSize() const
Returns the size of the metadata.
SourceLocation getLocation() const
const bool IsMutable
Flag indicating if a field is mutable.
static constexpr MetadataSize InlineDescMD
const RecordDecl * asRecordDecl() const
std::optional< unsigned > MetadataSize
bool isUnknownSizeArray() const
Checks if the descriptor is of an array of unknown size.
bool IsDummy
Flag indicating if this is a dummy descriptor.
unsigned getElemSize() const
returns the size of an element when the structure is viewed as an array.
const bool IsArray
Flag indicating if the block is an array.
const DeclTy & getSource() const
bool isPrimitiveArray() const
Checks if the descriptor is of an array of primitives.
Descriptor(const DeclTy &D, PrimType Type, MetadataSize MD, bool IsConst, bool IsTemporary, bool IsMutable)
Allocates a descriptor for a primitive.
bool isZeroSizeArray() const
Checks if the descriptor is of an array of zero size.
PrimType getPrimType() const
bool isRecord() const
Checks if the descriptor is of a record.
const bool IsTemporary
Flag indicating if the block is a temporary.
const Record *const ElemRecord
Pointer to the record, if block contains records.
const std::optional< PrimType > PrimT
The primitive type this descriptor was created for, or the primitive element type in case this is a p...
const VarDecl * asVarDecl() const
bool isArray() const
Checks if the descriptor is of an array.
Bitfield tracking the initialisation status of elements of primitive arrays.
InitMap(unsigned N)
Initializes the map with no fields set.
Inline descriptor embedded in structures and arrays.
unsigned IsActive
Flag indicating if the field is the active member of a union.
unsigned IsBase
Flag indicating if the field is an embedded base class.
unsigned Offset
Offset inside the structure/array.
unsigned IsInitialized
For primitive fields, it indicates if the field was initialized.
unsigned IsConst
Flag indicating if the storage is constant or not.
unsigned IsFieldMutable
Flag indicating if the field is mutable (if in a record).