clang 24.0.0git
clang::interp::Block Class Referencefinal

A memory block, either on the stack or in the heap. More...

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

Public Types

enum  BlockKind : uint8_t { None , Local , Global }

Public Member Functions

 Block (unsigned EvalID, UnsignedOrNone DeclID, const Descriptor *Desc, BlockKind K, BlockFlags Flags=BlockFlags::empty())
 Block (unsigned EvalID, const Descriptor *Desc, BlockKind K, BlockFlags Flags=BlockFlags::empty())
bool isGlobal () const
bool isLocal () const
const Descriptor * getDescriptor () const
 Returns the block's descriptor.
bool hasPointers () const
 Checks if the block has any live pointers.
bool isExtern () const
 Checks if the block is extern.
bool isTemporary () const
 Checks if the block is temporary.
bool isWeak () const
bool isDynamic () const
bool isDead () const
bool isConstexprUnknown () const
bool isAccessible () const
unsigned getSize () const
 Returns the size of the block, excluding metadata.
unsigned getAllocSize () const
 Returns the size of the block, including metadata.
UnsignedOrNone getDeclID () const
 Returns the declaration ID.
bool isInitialized () const
 Returns whether the data of this block has been initialized via invoking the Ctor func.
unsigned getEvalID () const
 The Evaluation ID this block was created in.
void movePointersTo (Block *B)
 Move all pointers from this block to.
void removePointers ()
 Make all pointers that currently point to this block point to nullptr.
std::byte * data ()
 Returns a pointer to the stored data.
const std::byte * data () const
template<typename T>
const T & deref () const
template<typename T>
T & deref ()
template<typename T>
T & getBlockDesc ()
template<typename T>
const T & getBlockDesc () const
void invokeCtor ()
 Invokes the constructor.
void invokeCtorNoMemset ()
 The same, but won't memset() the memory first to zero.
void invokeDtor ()
 Invokes the Destructor.
void dump () const
void dump (llvm::raw_ostream &OS) const

Static Public Member Functions

static unsigned allocSize (const Descriptor *D, BlockKind K)
 Number of bytes needed to allocate the block.
static unsigned getMetadataSize (BlockKind K)

Friends

class Pointer
class DeadBlock
class InterpState
class DynamicAllocator
class Program

Detailed Description

A memory block, either on the stack or in the heap.

The storage described by the block is immediately followed by optional metadata, which is followed by the actual data.

Block* rawData() data() │ │ │ │ │ │ ▼ ▼ ▼ ┌───────────────┬──────────────────┬─────────────────┐ │ Block │ Metadata │ Data │ │ sizeof(Block) │ MDSize │ Desc->getSize() │ └───────────────┴──────────────────┴─────────────────┘

getSize() returns Desc->getAllocSize(). getAllocSize() returns getMetadataSize() + Desc->getAllocSize().

Definition at line 68 of file Block.h.

Member Enumeration Documentation

◆ BlockKind

Enumerator
None 
Local 
Global 

Definition at line 70 of file Block.h.

Constructor & Destructor Documentation

◆ Block() [1/2]

clang::interp::Block::Block ( unsigned EvalID,
UnsignedOrNone DeclID,
const Descriptor * Desc,
BlockKind K,
BlockFlags Flags = BlockFlags::empty() )
inline

◆ Block() [2/2]

clang::interp::Block::Block ( unsigned EvalID,
const Descriptor * Desc,
BlockKind K,
BlockFlags Flags = BlockFlags::empty() )
inline

Definition at line 77 of file Block.h.

References clang::interp::BlockFlags::empty(), getAllocSize(), and getMetadataSize().

Member Function Documentation

◆ allocSize()

unsigned clang::interp::Block::allocSize ( const Descriptor * D,
BlockKind K )
inlinestatic

Number of bytes needed to allocate the block.

Definition at line 83 of file Block.h.

References Block(), clang::interp::Descriptor::getAllocSize(), and getMetadataSize().

Referenced by clang::interp::DynamicAllocator::allocate(), and clang::interp::EvalEmitter::createLocal().

◆ data() [1/2]

std::byte * clang::interp::Block::data ( )
inline

Returns a pointer to the stored data.

You are allowed to read Desc->getSize() bytes from this address.

Definition at line 140 of file Block.h.

Referenced by deref(), deref(), clang::interp::InterpFrame::getParamPointer(), invokeCtorNoMemset(), and invokeDtor().

◆ data() [2/2]

const std::byte * clang::interp::Block::data ( ) const
inline

Definition at line 141 of file Block.h.

◆ deref() [1/2]

template<typename T>
T & clang::interp::Block::deref ( )
inline

Definition at line 146 of file Block.h.

References data(), and clang::T.

◆ deref() [2/2]

◆ dump() [1/2]

void clang::interp::Block::dump ( ) const
inline

Definition at line 188 of file Block.h.

References dump().

Referenced by dump().

◆ dump() [2/2]

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

Definition at line 607 of file Disasm.cpp.

References isDead(), isDynamic(), isExtern(), isWeak(), Next, and Pointer.

◆ getAllocSize()

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

Returns the size of the block, including metadata.

Definition at line 125 of file Block.h.

Referenced by Block(), Block(), and invokeCtor().

◆ getBlockDesc() [1/2]

◆ getBlockDesc() [2/2]

template<typename T>
const T & clang::interp::Block::getBlockDesc ( ) const
inline

Definition at line 160 of file Block.h.

References Block(), getBlockDesc(), and clang::T.

◆ getDeclID()

UnsignedOrNone clang::interp::Block::getDeclID ( ) const
inline

Returns the declaration ID.

Definition at line 127 of file Block.h.

Referenced by CheckGlobal(), and clang::interp::CheckTemporary().

◆ getDescriptor()

◆ getEvalID()

unsigned clang::interp::Block::getEvalID ( ) const
inline

The Evaluation ID this block was created in.

Definition at line 132 of file Block.h.

Referenced by clang::interp::CheckTemporary(), and clang::interp::InterpState::lifetimeStartedInEvaluation().

◆ getMetadataSize()

unsigned clang::interp::Block::getMetadataSize ( BlockKind K)
inlinestatic

Definition at line 87 of file Block.h.

References Global, Local, and None.

Referenced by allocSize(), Block(), Block(), clang::interp::ByteCodeEmitter::createLocal(), and getBlockDesc().

◆ getSize()

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

Returns the size of the block, excluding metadata.

Definition at line 123 of file Block.h.

Referenced by clang::interp::Pointer::print(), and clang::interp::MemberPointer::toPointer().

◆ hasPointers()

bool clang::interp::Block::hasPointers ( ) const
inline

Checks if the block has any live pointers.

Definition at line 105 of file Block.h.

Referenced by clang::interp::DynamicAllocator::deallocate(), clang::interp::InterpState::deallocate(), and movePointersTo().

◆ invokeCtor()

void clang::interp::Block::invokeCtor ( )
inline

Invokes the constructor.

Definition at line 165 of file Block.h.

References getAllocSize(), and invokeCtorNoMemset().

Referenced by clang::interp::InterpFrame::getLocalBlock(), and clang::interp::InterpFrame::getParamPointer().

◆ invokeCtorNoMemset()

void clang::interp::Block::invokeCtorNoMemset ( )
inline

The same, but won't memset() the memory first to zero.

Definition at line 171 of file Block.h.

References data().

Referenced by invokeCtor().

◆ invokeDtor()

◆ isAccessible()

bool clang::interp::Block::isAccessible ( ) const
inline

Definition at line 121 of file Block.h.

Referenced by clang::interp::CheckGlobalLoad(), and clang::interp::CheckStore().

◆ isConstexprUnknown()

bool clang::interp::Block::isConstexprUnknown ( ) const
inline

◆ isDead()

bool clang::interp::Block::isDead ( ) const
inline

◆ isDynamic()

bool clang::interp::Block::isDynamic ( ) const
inline

◆ isExtern()

bool clang::interp::Block::isExtern ( ) const
inline

◆ isGlobal()

bool clang::interp::Block::isGlobal ( ) const
inline

◆ isInitialized()

◆ isLocal()

bool clang::interp::Block::isLocal ( ) const
inline

Definition at line 100 of file Block.h.

References Local.

◆ isTemporary()

bool clang::interp::Block::isTemporary ( ) const
inline

Checks if the block is temporary.

Definition at line 109 of file Block.h.

Referenced by clang::interp::CheckTemporary(), and clang::interp::noteValueLocation().

◆ isWeak()

bool clang::interp::Block::isWeak ( ) const
inline

Definition at line 110 of file Block.h.

References clang::interp::BlockFlags::Weak.

Referenced by clang::interp::CheckWeak(), and dump().

◆ movePointersTo()

void Block::movePointersTo ( Block * B)

Move all pointers from this block to.

Parameters
B.

Definition at line 103 of file Block.cpp.

References Block(), clang::interp::Pointer::BS, hasPointers(), clang::interp::BlockPointer::Pointee, and Pointer.

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

◆ removePointers()

void Block::removePointers ( )

Make all pointers that currently point to this block point to nullptr.

Definition at line 115 of file Block.cpp.

References clang::interp::Pointer::BS, clang::interp::BlockPointer::Next, Next, clang::interp::BlockPointer::Pointee, Pointer, and clang::interp::BlockPointer::Prev.

Referenced by clang::interp::DynamicAllocator::cleanup().

◆ DeadBlock

friend class DeadBlock
friend

Definition at line 193 of file Block.h.

References DeadBlock.

Referenced by DeadBlock.

◆ DynamicAllocator

friend class DynamicAllocator
friend

Definition at line 195 of file Block.h.

References DynamicAllocator.

Referenced by DynamicAllocator.

◆ InterpState

friend class InterpState
friend

Definition at line 194 of file Block.h.

References InterpState.

Referenced by InterpState.

◆ Pointer

friend class Pointer
friend

Definition at line 192 of file Block.h.

References Pointer.

Referenced by dump(), movePointersTo(), Pointer, and removePointers().

◆ Program

friend class Program
friend

Definition at line 196 of file Block.h.

References Program.

Referenced by Program.


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