clang 24.0.0git
clang::interp::Descriptor Struct Referencefinal

Describes a memory block created by an allocation site. More...

#include "/work/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/AST/ByteCode/Descriptor.h"

Classes

struct  UnknownSize
 Token to denote structures of unknown size. More...

Public Member Functions

 Descriptor (DeclOrExpr D, const Type *SourceTy, PrimType Type, bool IsConst, bool IsTemporary, bool IsMutable, bool IsVolatile)
 Allocates a descriptor for a primitive.
 Descriptor (DeclOrExpr D, const Type *SourceTy, PrimType Type, size_t NumElems, bool IsConst, bool IsTemporary, bool IsMutable, bool IsVolatile)
 Allocates a descriptor for an array of primitives.
 Descriptor (DeclOrExpr D, PrimType Type, bool IsConst, bool IsTemporary, UnknownSize)
 Allocates a descriptor for an array of primitives of unknown size.
 Descriptor (DeclOrExpr D, const Type *SourceTy, const Descriptor *Elem, unsigned NumElems, bool IsConst, bool IsTemporary, bool IsMutable)
 Allocates a descriptor for an array of composites.
 Descriptor (DeclOrExpr D, const Descriptor *Elem, bool IsTemporary, UnknownSize)
 Allocates a descriptor for an array of composites of unknown size.
 Descriptor (DeclOrExpr D, const Record *R, bool IsConst, bool IsTemporary, bool IsMutable, bool IsVolatile)
 Allocates a descriptor for a record.
 Descriptor (DeclOrExpr D)
 Allocates a dummy descriptor.
QualType getType () const
QualType getElemQualType () const
QualType getDataType (const ASTContext &Ctx) const
SourceLocation getLocation () const
SourceInfo getLoc () const
const DeclasDecl () const
const ExprasExpr () const
DeclOrExpr getSource () const
const ValueDeclasValueDecl () const
const VarDeclasVarDecl () const
const FieldDeclasFieldDecl () const
const RecordDeclasRecordDecl () const
template<typename T>
const TgetAs () const
unsigned getSize () const
 Returns the size of the object without metadata.
PrimType getPrimType () const
unsigned getAllocSize () const
 Returns the allocated size, including metadata.
unsigned getElemSize () const
 returns the size of an element when the structure is viewed as an array.
unsigned getElemDataSize () const
 Returns the element data size, i.e.
unsigned getNumElems () const
 Returns the number of elements stored in the block.
bool isPrimitiveArray () const
 Checks if the descriptor is of an array of primitives.
bool isCompositeArray () const
 Checks if the descriptor is of an array of composites.
bool isZeroSizeArray () const
 Checks if the descriptor is of an array of zero size.
bool isUnknownSizeArray () const
 Checks if the descriptor is of an array of unknown size.
bool isPrimitive () const
 Checks if the descriptor is of a primitive.
bool isArray () const
 Checks if the descriptor is of an array.
bool isRecord () const
 Checks if the descriptor is of a record.
bool isUnion () const
 Checks if the descriptor is of a union.
bool hasTrivialDtor () const
 Whether variables of this descriptor need their destructor called or not.
void dump () const
void dump (llvm::raw_ostream &OS) const
void dumpFull (unsigned Offset=0, unsigned Indent=0) const
 Dump descriptor, including all valid offsets.

Public Attributes

const Record *const ElemRecord = nullptr
 Pointer to the record, if block contains records.
const Descriptor *const ElemDesc = nullptr
 Descriptor of the array element.
const OptPrimType PrimT = std::nullopt
 The primitive type this descriptor was created for, or the primitive element type in case this is a primitive array.
const bool IsConst = false
 Flag indicating if the block is mutable.
const bool IsMutable = false
 Flag indicating if a field is mutable.
const bool IsTemporary = false
 Flag indicating if the block is a temporary.
const bool IsVolatile = false
const bool IsArray = false
 Flag indicating if the block is an array.
bool IsConstexprUnknown = false
const BlockCtorFn CtorFn = nullptr
 Storage management methods.
const BlockDtorFn DtorFn = nullptr

Static Public Attributes

static constexpr unsigned MaxArrayElemBytes
 Maximum number of bytes to be used for array elements.

Detailed Description

Describes a memory block created by an allocation site.

Definition at line 122 of file Descriptor.h.

Constructor & Destructor Documentation

◆ Descriptor() [1/7]

Descriptor::Descriptor ( DeclOrExpr D,
const Type * SourceTy,
PrimType Type,
bool IsConst,
bool IsTemporary,
bool IsMutable,
bool IsVolatile )

Allocates a descriptor for a primitive.

Primitives.

Definition at line 294 of file Descriptor.cpp.

References clang::interp::align(), CtorFn, DtorFn, getDtorPrim(), IsConst, IsMutable, IsTemporary, IsVolatile, clang::nullptr, clang::interp::primSize(), and PrimT.

Referenced by Descriptor(), and Descriptor().

◆ Descriptor() [2/7]

Descriptor::Descriptor ( DeclOrExpr D,
const Type * SourceTy,
PrimType Type,
size_t NumElems,
bool IsConst,
bool IsTemporary,
bool IsMutable,
bool IsVolatile )

Allocates a descriptor for an array of primitives.

Primitive arrays.

Definition at line 305 of file Descriptor.cpp.

References clang::interp::align(), CtorFn, DtorFn, getDtorArrayPrim(), IsArray, IsConst, IsMutable, IsTemporary, IsVolatile, MaxArrayElemBytes, clang::nullptr, clang::interp::primSize(), PrimT, and true.

◆ Descriptor() [3/7]

Descriptor::Descriptor ( DeclOrExpr D,
PrimType Type,
bool IsConst,
bool IsTemporary,
UnknownSize  )

Allocates a descriptor for an array of primitives of unknown size.

Primitive unknown-size arrays.

Definition at line 318 of file Descriptor.cpp.

References CtorFn, DtorFn, false, getDtorArrayPrim(), IsArray, IsConst, IsMutable, IsTemporary, clang::nullptr, clang::interp::primSize(), PrimT, and true.

◆ Descriptor() [4/7]

Descriptor::Descriptor ( DeclOrExpr D,
const Type * SourceTy,
const Descriptor * Elem,
unsigned NumElems,
bool IsConst,
bool IsTemporary,
bool IsMutable )

Allocates a descriptor for an array of composites.

Arrays of composite elements.

Definition at line 328 of file Descriptor.cpp.

References ctorArrayDesc(), CtorFn, Descriptor(), dtorArrayDesc(), DtorFn, ElemDesc, getAllocSize(), IsArray, IsConst, IsMutable, IsTemporary, max(), clang::nullptr, and true.

◆ Descriptor() [5/7]

Descriptor::Descriptor ( DeclOrExpr D,
const Descriptor * Elem,
bool IsTemporary,
UnknownSize  )

Allocates a descriptor for an array of composites of unknown size.

Unknown-size arrays of composite elements.

Definition at line 342 of file Descriptor.cpp.

References ctorArrayDesc(), CtorFn, Descriptor(), dtorArrayDesc(), DtorFn, ElemDesc, false, getAllocSize(), IsArray, IsConst, IsMutable, IsTemporary, clang::nullptr, and true.

◆ Descriptor() [6/7]

Descriptor::Descriptor ( DeclOrExpr D,
const Record * R,
bool IsConst,
bool IsTemporary,
bool IsMutable,
bool IsVolatile )

Allocates a descriptor for a record.

Composite records.

Definition at line 352 of file Descriptor.cpp.

References CtorFn, ctorRecord(), DtorFn, dtorRecord(), ElemRecord, IsConst, IsMutable, IsTemporary, IsVolatile, max(), needsRecordDtor(), and clang::nullptr.

◆ Descriptor() [7/7]

Descriptor::Descriptor ( DeclOrExpr D)

Allocates a dummy descriptor.

Dummy.

Definition at line 362 of file Descriptor.cpp.

References ElemDesc, false, IsConst, IsMutable, IsTemporary, clang::nullptr, and true.

Member Function Documentation

◆ asDecl()

◆ asExpr()

◆ asFieldDecl()

const FieldDecl * clang::interp::Descriptor::asFieldDecl ( ) const
inline

Definition at line 213 of file Descriptor.h.

References asDecl().

Referenced by clang::interp::PtrView::getField(), and toRValue().

◆ asRecordDecl()

const RecordDecl * clang::interp::Descriptor::asRecordDecl ( ) const
inline

Definition at line 217 of file Descriptor.h.

References asDecl().

◆ asValueDecl()

◆ asVarDecl()

◆ dump() [1/2]

LLVM_DUMP_METHOD void Descriptor::dump ( ) const

Definition at line 429 of file Disasm.cpp.

References dump().

Referenced by clang::interp::Program::dump().

◆ dump() [2/2]

LLVM_DUMP_METHOD void Descriptor::dump ( llvm::raw_ostream & OS) const

◆ dumpFull()

LLVM_DUMP_METHOD void Descriptor::dumpFull ( unsigned Offset = 0,
unsigned Indent = 0 ) const

◆ getAllocSize()

◆ getAs()

template<typename T>
const T * clang::interp::Descriptor::getAs ( ) const
inline

Definition at line 221 of file Descriptor.h.

References asDecl(), and clang::T.

◆ getDataType()

◆ getElemDataSize()

unsigned Descriptor::getElemDataSize ( ) const

Returns the element data size, i.e.

not what the size of our primitive data type is, but what the data size of that is. E.g., for PT_SInt32, that's 4 bytes.

Definition at line 506 of file Descriptor.cpp.

References FIXED_SIZE_INT_TYPE_SWITCH, getPrimType(), clang::interp::isIntegerOrBoolType(), isPrimitive(), isPrimitiveArray(), and clang::interp::PT_Bool.

Referenced by clang::interp::interp__builtin_strlen().

◆ getElemQualType()

◆ getElemSize()

unsigned clang::interp::Descriptor::getElemSize ( ) const
inline

returns the size of an element when the structure is viewed as an array.

Definition at line 239 of file Descriptor.h.

Referenced by dumpFull(), clang::interp::PtrView::elem(), clang::interp::PtrView::elemSize(), and getNumElems().

◆ getLoc()

SourceInfo Descriptor::getLoc ( ) const

Definition at line 481 of file Descriptor.cpp.

References asDecl().

◆ getLocation()

SourceLocation Descriptor::getLocation ( ) const

◆ getNumElems()

◆ getPrimType()

◆ getSize()

unsigned clang::interp::Descriptor::getSize ( ) const
inline

◆ getSource()

DeclOrExpr clang::interp::Descriptor::getSource ( ) const
inline

Definition at line 203 of file Descriptor.h.

Referenced by clang::interp::Pointer::getSource().

◆ getType()

◆ hasTrivialDtor()

bool Descriptor::hasTrivialDtor ( ) const

Whether variables of this descriptor need their destructor called or not.

Definition at line 489 of file Descriptor.cpp.

References ElemDesc, ElemRecord, isPrimitive(), isPrimitiveArray(), and isRecord().

Referenced by clang::interp::RunDestructors(), and clang::interp::Compiler< Emitter >::visitDtorCall().

◆ isArray()

◆ isCompositeArray()

bool clang::interp::Descriptor::isCompositeArray ( ) const
inline

◆ isPrimitive()

◆ isPrimitiveArray()

bool clang::interp::Descriptor::isPrimitiveArray ( ) const
inline

◆ isRecord()

◆ isUnion()

bool Descriptor::isUnion ( ) const

Checks if the descriptor is of a union.

Definition at line 504 of file Descriptor.cpp.

References ElemRecord, and isRecord().

Referenced by ctorRecord(), dump(), and initField().

◆ isUnknownSizeArray()

bool clang::interp::Descriptor::isUnknownSizeArray ( ) const
inline

◆ isZeroSizeArray()

bool clang::interp::Descriptor::isZeroSizeArray ( ) const
inline

Checks if the descriptor is of an array of zero size.

Definition at line 255 of file Descriptor.h.

Referenced by dump(), and clang::interp::PtrView::isZeroSizeArray().

Member Data Documentation

◆ CtorFn

const BlockCtorFn clang::interp::Descriptor::CtorFn = nullptr

Storage management methods.

Definition at line 165 of file Descriptor.h.

Referenced by ctorArrayDesc(), Descriptor(), Descriptor(), Descriptor(), Descriptor(), Descriptor(), Descriptor(), and initField().

◆ DtorFn

const BlockDtorFn clang::interp::Descriptor::DtorFn = nullptr

◆ ElemDesc

◆ ElemRecord

◆ IsArray

const bool clang::interp::Descriptor::IsArray = false

◆ IsConst

◆ IsConstexprUnknown

◆ IsMutable

const bool clang::interp::Descriptor::IsMutable = false

Flag indicating if a field is mutable.

Definition at line 156 of file Descriptor.h.

Referenced by ctorArrayDesc(), Descriptor(), Descriptor(), Descriptor(), Descriptor(), Descriptor(), Descriptor(), Descriptor(), initBase(), and initField().

◆ IsTemporary

const bool clang::interp::Descriptor::IsTemporary = false

Flag indicating if the block is a temporary.

Definition at line 158 of file Descriptor.h.

Referenced by clang::interp::CheckLocalLoad(), Descriptor(), Descriptor(), Descriptor(), Descriptor(), Descriptor(), Descriptor(), Descriptor(), and clang::interp::Program::dump().

◆ IsVolatile

◆ MaxArrayElemBytes

unsigned clang::interp::Descriptor::MaxArrayElemBytes
staticconstexpr
Initial value:
=
std::numeric_limits<decltype(AllocSize)>::max() - sizeof(InitMapPtr)
__DEVICE__ int max(int __a, int __b)
A pointer-sized struct we use to allocate into data storage.
Definition InitMap.h:79

Maximum number of bytes to be used for array elements.

Definition at line 142 of file Descriptor.h.

Referenced by clang::interp::CheckArraySize(), clang::interp::Program::createDescriptor(), Descriptor(), and clang::interp::interp__builtin_operator_new().

◆ PrimT

const OptPrimType clang::interp::Descriptor::PrimT = std::nullopt

The primitive type this descriptor was created for, or the primitive element type in case this is a primitive array.

Definition at line 152 of file Descriptor.h.

Referenced by Descriptor(), Descriptor(), Descriptor(), getPrimType(), and isPrimitive().


The documentation for this struct was generated from the following files: