13#ifndef LLVM_CLANG_AST_INTERP_DESCRIPTOR_H
14#define LLVM_CLANG_AST_INTERP_DESCRIPTOR_H
29using DeclTy = llvm::PointerUnion<const Decl *, const Expr *>;
30using InitMapPtr = std::optional<std::pair<bool, std::shared_ptr<InitMap>>>;
36 bool IsMutable,
bool IsVolatile,
bool IsActive,
73 LLVM_PREFERRED_TYPE(
bool)
79 LLVM_PREFERRED_TYPE(
bool)
82 LLVM_PREFERRED_TYPE(
bool)
85 LLVM_PREFERRED_TYPE(
bool)
88 LLVM_PREFERRED_TYPE(
bool)
91 LLVM_PREFERRED_TYPE(
bool)
94 LLVM_PREFERRED_TYPE(
bool)
98 LLVM_PREFERRED_TYPE(
bool)
101 LLVM_PREFERRED_TYPE(
bool)
103 LLVM_PREFERRED_TYPE(
bool)
117 void dump(llvm::raw_ostream &OS)
const;
119static_assert(
sizeof(GlobalInlineDescriptor) !=
sizeof(InlineDescriptor),
"");
126 const Type *SourceType =
nullptr;
128 const unsigned ElemSize;
132 const unsigned MDSize;
134 const unsigned AllocSize;
137 static constexpr unsigned UnknownSizeMark = (
unsigned)-1;
210 const Decl *
asDecl()
const {
return dyn_cast<const Decl *>(Source); }
211 const Expr *
asExpr()
const {
return dyn_cast<const Expr *>(Source); }
215 return dyn_cast_if_present<ValueDecl>(
asDecl());
219 return dyn_cast_if_present<VarDecl>(
asDecl());
223 return dyn_cast_if_present<FieldDecl>(
asDecl());
227 return dyn_cast_if_present<RecordDecl>(
asDecl());
276 void dump(llvm::raw_ostream &OS)
const;
277 void dumpFull(
unsigned Offset = 0,
unsigned Indent = 0)
const;
286 static constexpr uint64_t PER_FIELD =
sizeof(T) *
CHAR_BIT;
296 T *data() {
return Data.get(); }
297 const T *data()
const {
return Data.get(); }
300 bool initializeElement(
unsigned I);
303 bool isElementInitialized(
unsigned I)
const;
305 static constexpr size_t numFields(
unsigned N) {
306 return (N + PER_FIELD - 1) / PER_FIELD;
309 unsigned UninitFields;
310 std::unique_ptr<T[]>
Data;
llvm::MachO::Record Record
__DEVICE__ int max(int __a, int __b)
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
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.
Describes the statement/declaration an opcode was generated from.
void(*)(Block *Storage, std::byte *FieldPtr, bool IsConst, bool IsMutable, bool IsVolatile, bool IsActive, bool InUnion, const Descriptor *FieldDesc) BlockCtorFn
Invoked whenever a block is created.
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.
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
PrimType
Enumeration of the primitive types of the VM.
llvm::PointerUnion< const Decl *, const Expr * > DeclTy
The JSON file list parser is used to communicate input to InstallAPI.
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 dumpFull(unsigned Offset=0, unsigned Indent=0) const
Dump descriptor, including all valid offsets.
bool isPrimitive() const
Checks if the descriptor is of a primitive.
QualType getElemQualType() const
const RecordDecl * asRecordDecl() const
bool hasTrivialDtor() const
Whether variables of this descriptor need their destructor called or not.
bool isCompositeArray() const
Checks if the descriptor is of an array of composites.
const OptPrimType PrimT
The primitive type this descriptor was created for, or the primitive element type in case this is a p...
static constexpr MetadataSize GlobalMD
const ValueDecl * asValueDecl() const
const BlockCtorFn CtorFn
Storage management methods.
static constexpr unsigned MaxArrayElemBytes
Maximum number of bytes to be used for array elements.
const DeclTy & getSource() const
const Decl * asDecl() const
const Descriptor *const ElemDesc
Descriptor of the array element.
SourceInfo getLoc() const
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
QualType getDataType(const ASTContext &Ctx) const
std::optional< unsigned > MetadataSize
bool isUnknownSizeArray() const
Checks if the descriptor is of an array of unknown size.
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.
bool isPrimitiveArray() const
Checks if the descriptor is of an array of primitives.
bool isZeroSizeArray() const
Checks if the descriptor is of an array of zero size.
const FieldDecl * asFieldDecl() const
const VarDecl * asVarDecl() const
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.
bool isUnion() const
Checks if the descriptor is of a union.
const Expr * asExpr() const
bool isArray() const
Checks if the descriptor is of an array.
Descriptor used for global variables.
GlobalInitState InitState
Bitfield tracking the initialisation status of elements of primitive arrays.
Inline descriptor embedded in structures and arrays.
unsigned IsActive
Flag indicating if the field is the active member of a union.
unsigned IsConstInMutable
Flag indicating if this field is a const field nested in a mutable parent field.
unsigned IsBase
Flag indicating if the field is an embedded base class.
unsigned IsVirtualBase
Flag inidcating if the field is a virtual base class.
unsigned InUnion
Flag indicating if this field is in a union (even if nested).
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 IsArrayElement
Flag indicating if the field is an element of a composite array.
unsigned IsFieldMutable
Flag indicating if the field is mutable (if in a record).