clang 20.0.0git
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
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, PrimType Type, MetadataSize MD, bool IsConst, bool IsTemporary, bool IsMutable)
 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 IsTemporary, UnknownSize)
 Allocates a descriptor for an array of primitives of unknown size.
 
 Descriptor (const DeclTy &D, 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)
 Allocates a descriptor for a record.
 
 Descriptor (const DeclTy &D)
 Allocates a dummy descriptor.
 
void makeDummy ()
 Make this descriptor a dummy descriptor.
 
QualType getType () const
 
QualType getElemQualType () const
 
SourceLocation getLocation () 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 isDummy () const
 Checks if this is a dummy descriptor.
 
void dump () const
 
void dump (llvm::raw_ostream &OS) const
 

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 std::optional< PrimTypePrimT = 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 IsArray = false
 Flag indicating if the block is an array.
 
bool IsDummy = false
 Flag indicating if this is a dummy descriptor.
 
const BlockCtorFn CtorFn = nullptr
 Storage management methods.
 
const BlockDtorFn DtorFn = nullptr
 
const BlockMoveFn MoveFn = 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 111 of file Descriptor.h.

Member Typedef Documentation

◆ MetadataSize

Definition at line 131 of file Descriptor.h.

Constructor & Destructor Documentation

◆ Descriptor() [1/7]

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

Allocates a descriptor for a primitive.

Primitives.

Definition at line 314 of file Descriptor.cpp.

◆ 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 326 of file Descriptor.cpp.

References MaxArrayElemBytes.

◆ Descriptor() [3/7]

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

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

Primitive unknown-size arrays.

Definition at line 340 of file Descriptor.cpp.

◆ Descriptor() [4/7]

Descriptor::Descriptor ( const DeclTy D,
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 352 of file Descriptor.cpp.

◆ 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 365 of file Descriptor.cpp.

◆ Descriptor() [6/7]

Descriptor::Descriptor ( const DeclTy D,
const Record R,
MetadataSize  MD,
bool  IsConst,
bool  IsTemporary,
bool  IsMutable 
)

Allocates a descriptor for a record.

Composite records.

Definition at line 376 of file Descriptor.cpp.

◆ Descriptor() [7/7]

Descriptor::Descriptor ( const DeclTy D)

Allocates a dummy descriptor.

Dummy.

Definition at line 387 of file Descriptor.cpp.

Member Function Documentation

◆ asDecl()

const Decl * clang::interp::Descriptor::asDecl ( ) const
inline

◆ asExpr()

const Expr * clang::interp::Descriptor::asExpr ( ) const
inline

◆ asFieldDecl()

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

Definition at line 210 of file Descriptor.h.

References asDecl().

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

◆ asRecordDecl()

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

Definition at line 214 of file Descriptor.h.

References asDecl().

◆ asValueDecl()

const ValueDecl * clang::interp::Descriptor::asValueDecl ( ) const
inline

◆ asVarDecl()

const VarDecl * clang::interp::Descriptor::asVarDecl ( ) const
inline

◆ dump() [1/2]

LLVM_DUMP_METHOD void Descriptor::dump ( ) const

◆ dump() [2/2]

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

◆ getAllocSize()

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

◆ getElemQualType()

QualType Descriptor::getElemQualType ( ) const

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

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

◆ getLocation()

SourceLocation Descriptor::getLocation ( ) const

◆ getMetadataSize()

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

◆ getNumElems()

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

◆ getPrimType()

PrimType clang::interp::Descriptor::getPrimType ( ) const
inline

◆ getSize()

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

Returns the size of the object without metadata.

Definition at line 219 of file Descriptor.h.

References isUnknownSizeArray().

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

◆ getSource()

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

Definition at line 200 of file Descriptor.h.

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

◆ getType()

QualType Descriptor::getType ( ) const

◆ isArray()

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

Checks if the descriptor is of an array.

Definition at line 254 of file Descriptor.h.

References IsArray.

Referenced by getElemQualType(), and clang::interp::Pointer::toAPValue().

◆ isCompositeArray()

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

Checks if the descriptor is of an array of composites.

Definition at line 244 of file Descriptor.h.

References ElemDesc, and IsArray.

Referenced by clang::interp::collectBlocks(), dump(), and clang::interp::RunDestructors().

◆ isDummy()

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

Checks if this is a dummy descriptor.

Definition at line 260 of file Descriptor.h.

References IsDummy.

Referenced by dump(), clang::interp::Program::dump(), clang::interp::Program::getOrCreateDummy(), and clang::interp::Pointer::isDummy().

◆ isPrimitive()

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

Checks if the descriptor is of a primitive.

Definition at line 251 of file Descriptor.h.

References ElemRecord, and IsArray.

Referenced by clang::interp::collectBlocks(), clang::interp::copyComposite(), dump(), clang::interp::Program::dump(), getPrimType(), and clang::interp::RunDestructors().

◆ isPrimitiveArray()

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

◆ isRecord()

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

Checks if the descriptor is of a record.

Definition at line 256 of file Descriptor.h.

References ElemRecord, and IsArray.

Referenced by clang::interp::copyComposite(), clang::interp::copyRecord(), dump(), isUnion(), clang::interp::RunDestructors(), and clang::interp::runRecordDestructor().

◆ isUnion()

bool Descriptor::isUnion ( ) const

Checks if the descriptor is of a union.

Definition at line 424 of file Descriptor.cpp.

References ElemRecord, isRecord(), and clang::interp::Record::isUnion().

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

◆ isUnknownSizeArray()

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

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

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

Referenced by dump().

◆ makeDummy()

void clang::interp::Descriptor::makeDummy ( )
inline

Make this descriptor a dummy descriptor.

Definition at line 192 of file Descriptor.h.

References IsDummy.

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

Member Data Documentation

◆ CtorFn

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

Storage management methods.

Definition at line 160 of file Descriptor.h.

Referenced by clang::interp::Block::invokeCtor().

◆ DtorFn

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

Definition at line 161 of file Descriptor.h.

Referenced by clang::interp::Block::invokeDtor().

◆ ElemDesc

const Descriptor* const clang::interp::Descriptor::ElemDesc = nullptr

◆ ElemRecord

const Record* const clang::interp::Descriptor::ElemRecord = nullptr

◆ GlobalMD

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

Definition at line 133 of file Descriptor.h.

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

◆ InlineDescMD

constexpr MetadataSize clang::interp::Descriptor::InlineDescMD = sizeof(InlineDescriptor)
staticconstexpr

◆ IsArray

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

◆ IsConst

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

Flag indicating if the block is mutable.

Definition at line 149 of file Descriptor.h.

Referenced by clang::interp::Block::invokeCtor(), and clang::interp::Pointer::isConst().

◆ IsDummy

bool clang::interp::Descriptor::IsDummy = false

Flag indicating if this is a dummy descriptor.

Definition at line 157 of file Descriptor.h.

Referenced by isDummy(), and makeDummy().

◆ IsMutable

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

Flag indicating if a field is mutable.

Definition at line 151 of file Descriptor.h.

Referenced by clang::interp::Block::invokeCtor().

◆ IsTemporary

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

Flag indicating if the block is a temporary.

Definition at line 153 of file Descriptor.h.

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

◆ MaxArrayElemBytes

constexpr 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)
std::optional< std::pair< bool, std::shared_ptr< InitMap > > > InitMapPtr
Definition: Descriptor.h:29
constexpr size_t align(size_t Size)
Aligns a size to the pointer alignment.
Definition: PrimType.h:126
static constexpr MetadataSize GlobalMD
Definition: Descriptor.h:133
static constexpr MetadataSize InlineDescMD
Definition: Descriptor.h:132

Maximum number of bytes to be used for array elements.

Definition at line 136 of file Descriptor.h.

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

◆ MoveFn

const BlockMoveFn clang::interp::Descriptor::MoveFn = nullptr

Definition at line 162 of file Descriptor.h.

Referenced by clang::interp::InterpState::deallocate().

◆ PrimT

const std::optional<PrimType> 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 147 of file Descriptor.h.

Referenced by getPrimType().


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