clang 22.0.0git
clang::interp::Descriptor Struct Referencefinal

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

#include "/home/buildbot/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 Types

using MetadataSize = std::optional<unsigned>

Public Member Functions

 Descriptor (const DeclTy &D, const Type *SourceTy, PrimType Type, MetadataSize MD, bool IsConst, bool IsTemporary, bool IsMutable, bool IsVolatile)
 Allocates a descriptor for a primitive.
 Descriptor (const DeclTy &D, PrimType Type, MetadataSize MD, size_t NumElems, bool IsConst, bool IsTemporary, bool IsMutable)
 Allocates a descriptor for an array of primitives.
 Descriptor (const DeclTy &D, PrimType Type, MetadataSize MDSize, bool IsConst, bool IsTemporary, UnknownSize)
 Allocates a descriptor for an array of primitives of unknown size.
 Descriptor (const DeclTy &D, const Type *SourceTy, const Descriptor *Elem, MetadataSize MD, unsigned NumElems, bool IsConst, bool IsTemporary, bool IsMutable)
 Allocates a descriptor for an array of composites.
 Descriptor (const DeclTy &D, const Descriptor *Elem, MetadataSize MD, bool IsTemporary, UnknownSize)
 Allocates a descriptor for an array of composites of unknown size.
 Descriptor (const DeclTy &D, const Record *R, MetadataSize MD, bool IsConst, bool IsTemporary, bool IsMutable, bool IsVolatile)
 Allocates a descriptor for a record.
 Descriptor (const DeclTy &D, MetadataSize MD=std::nullopt)
 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
const DeclTygetSource () const
const ValueDeclasValueDecl () const
const VarDeclasVarDecl () const
const FieldDeclasFieldDecl () const
const RecordDeclasRecordDecl () 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 getMetadataSize () const
 Returns the size of the metadata.
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 MetadataSize InlineDescMD = sizeof(InlineDescriptor)
static constexpr MetadataSize GlobalMD = sizeof(GlobalInlineDescriptor)
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.

Member Typedef Documentation

◆ MetadataSize

Definition at line 143 of file Descriptor.h.

Constructor & Destructor Documentation

◆ Descriptor() [1/7]

Descriptor::Descriptor ( const DeclTy & D,
const Type * SourceTy,
PrimType Type,
MetadataSize MD,
bool IsConst,
bool IsTemporary,
bool IsMutable,
bool IsVolatile )

Allocates a descriptor for a primitive.

Primitives.

Definition at line 287 of file Descriptor.cpp.

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

Referenced by Descriptor(), and Descriptor().

◆ Descriptor() [2/7]

Descriptor::Descriptor ( const DeclTy & D,
PrimType Type,
MetadataSize MD,
size_t NumElems,
bool IsConst,
bool IsTemporary,
bool IsMutable )

Allocates a descriptor for an array of primitives.

Primitive arrays.

Definition at line 300 of file Descriptor.cpp.

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

◆ Descriptor() [3/7]

Descriptor::Descriptor ( const DeclTy & D,
PrimType Type,
MetadataSize MDSize,
bool IsConst,
bool IsTemporary,
UnknownSize  )

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

Primitive unknown-size arrays.

Definition at line 314 of file Descriptor.cpp.

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

◆ Descriptor() [4/7]

Descriptor::Descriptor ( const DeclTy & D,
const Type * SourceTy,
const Descriptor * Elem,
MetadataSize MD,
unsigned NumElems,
bool IsConst,
bool IsTemporary,
bool IsMutable )

Allocates a descriptor for an array of composites.

Arrays of composite elements.

Definition at line 326 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 ( const DeclTy & D,
const Descriptor * Elem,
MetadataSize MD,
bool IsTemporary,
UnknownSize  )

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

Unknown-size arrays of composite elements.

Definition at line 341 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 ( const DeclTy & D,
const Record * R,
MetadataSize MD,
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 ( const DeclTy & D,
MetadataSize MD = std::nullopt )

Allocates a dummy descriptor.

Dummy.

Definition at line 364 of file Descriptor.cpp.

References ElemRecord, 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 222 of file Descriptor.h.

References asDecl().

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

◆ asRecordDecl()

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

Definition at line 226 of file Descriptor.h.

References asDecl().

◆ asValueDecl()

◆ asVarDecl()

◆ dump() [1/2]

LLVM_DUMP_METHOD void Descriptor::dump ( ) const

Definition at line 380 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

Dump descriptor, including all valid offsets.

Definition at line 417 of file Disasm.cpp.

References dump(), ElemDesc, ElemRecord, getAllocSize(), getMetadataSize(), getNumElems(), getSize(), clang::Indent(), isCompositeArray(), isPrimitive(), and isRecord().

◆ getAllocSize()

◆ getDataType()

◆ 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 244 of file Descriptor.h.

Referenced by clang::interp::Pointer::elem(), clang::interp::Pointer::elemSize(), getNumElems(), and clang::interp::interp__builtin_strlen().

◆ getLoc()

SourceInfo Descriptor::getLoc ( ) const

Definition at line 446 of file Descriptor.cpp.

◆ getLocation()

◆ getMetadataSize()

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

◆ getNumElems()

◆ getPrimType()

◆ getSize()

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

Returns the size of the object without metadata.

Definition at line 231 of file Descriptor.h.

References isUnknownSizeArray().

Referenced by clang::interp::AllocCN(), dumpFull(), clang::interp::Pointer::elemSize(), getNumElems(), and clang::interp::Pointer::getSize().

◆ getSource()

const DeclTy & clang::interp::Descriptor::getSource ( ) const
inline

Definition at line 212 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 454 of file Descriptor.cpp.

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

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

◆ isArray()

◆ isCompositeArray()

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

◆ isPrimitive()

◆ isPrimitiveArray()

◆ isRecord()

◆ isUnion()

bool Descriptor::isUnion ( ) const

Checks if the descriptor is of a union.

Definition at line 469 of file Descriptor.cpp.

References ElemRecord, and isRecord().

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

◆ isUnknownSizeArray()

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

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

Definition at line 260 of file Descriptor.h.

Referenced by dump(), getSize(), and clang::interp::Pointer::isUnknownSizeArray().

◆ isZeroSizeArray()

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

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

Definition at line 258 of file Descriptor.h.

Referenced by dump().

Member Data Documentation

◆ CtorFn

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

Storage management methods.

Definition at line 172 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

◆ GlobalMD

MetadataSize clang::interp::Descriptor::GlobalMD = sizeof(GlobalInlineDescriptor)
staticconstexpr

Definition at line 145 of file Descriptor.h.

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

◆ InlineDescMD

◆ IsArray

◆ IsConst

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

◆ IsConstexprUnknown

◆ IsMutable

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

Flag indicating if a field is mutable.

Definition at line 163 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 165 of file Descriptor.h.

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

◆ IsVolatile

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

◆ MaxArrayElemBytes

unsigned clang::interp::Descriptor::MaxArrayElemBytes
staticconstexpr
Initial value:
=
std::numeric_limits<decltype(AllocSize)>::max() - sizeof(InitMapPtr) -
align(std::max(*InlineDescMD, *GlobalMD))
__DEVICE__ int max(int __a, int __b)
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
Definition PrimType.h:185
std::optional< std::pair< bool, std::shared_ptr< InitMap > > > InitMapPtr
Definition Descriptor.h:30
static constexpr MetadataSize GlobalMD
Definition Descriptor.h:145
static constexpr MetadataSize InlineDescMD
Definition Descriptor.h:144

Maximum number of bytes to be used for array elements.

Definition at line 148 of file Descriptor.h.

Referenced by clang::interp::CheckArraySize(), 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 159 of file Descriptor.h.

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


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