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 Member Functions

 Block (unsigned EvalID, UnsignedOrNone DeclID, const Descriptor *Desc, unsigned MDSize=0, bool IsStatic=false, bool IsExtern=false, bool IsWeak=false)
 Creates a new block.
 Block (unsigned EvalID, const Descriptor *Desc, unsigned MDSize=0, bool IsStatic=false, bool IsExtern=false, bool IsWeak=false)
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 isStatic () const
 Checks if the block has static storage duration.
bool isTemporary () const
 Checks if the block is temporary.
bool isWeak () const
bool isDynamic () const
bool isDead () const
unsigned getSize () const
 Returns the size of the block, including metadata.
unsigned getMetadataSize () const
 Returns the size of the 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
std::byte * rawData ()
 Returns a pointer to the raw data, including metadata.
const std::byte * rawData () 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
bool isAccessible () const

Static Public Attributes

static constexpr uint8_t InlineDescMD = sizeof(InlineDescriptor)
static constexpr uint8_t GlobalMD = sizeof(GlobalInlineDescriptor)

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 MDSize + Desc->getAllocSize().

Definition at line 43 of file Block.h.

Constructor & Destructor Documentation

◆ Block() [1/2]

clang::interp::Block::Block ( unsigned EvalID,
UnsignedOrNone DeclID,
const Descriptor * Desc,
unsigned MDSize = 0,
bool IsStatic = false,
bool IsExtern = false,
bool IsWeak = false )
inline

Creates a new block.

Definition at line 54 of file Block.h.

Referenced by getBlockDesc(), movePointersTo(), rawData(), and rawData().

◆ Block() [2/2]

clang::interp::Block::Block ( unsigned EvalID,
const Descriptor * Desc,
unsigned MDSize = 0,
bool IsStatic = false,
bool IsExtern = false,
bool IsWeak = false )
inline

Definition at line 64 of file Block.h.

Member Function Documentation

◆ 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 108 of file Block.h.

References rawData().

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 109 of file Block.h.

References rawData().

◆ deref() [1/2]

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

Definition at line 123 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 158 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 610 of file Disasm.cpp.

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

◆ getBlockDesc() [1/2]

◆ getBlockDesc() [2/2]

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

Definition at line 129 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 95 of file Block.h.

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

◆ getDescriptor()

◆ getEvalID()

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

The Evaluation ID this block was created in.

Definition at line 100 of file Block.h.

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

◆ getMetadataSize()

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

Returns the size of the metadata.

Definition at line 93 of file Block.h.

Referenced by clang::interp::Program::getPtrGlobal(), and clang::interp::Pointer::Pointer().

◆ getSize()

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

Returns the size of the block, including metadata.

Definition at line 91 of file Block.h.

Referenced by clang::interp::InterpState::deallocate(), invokeCtor(), 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 75 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 134 of file Block.h.

References getSize(), invokeCtorNoMemset(), and rawData().

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 140 of file Block.h.

References data().

Referenced by invokeCtor().

◆ invokeDtor()

◆ isAccessible()

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

Definition at line 161 of file Block.h.

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

◆ isDead()

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

◆ isDynamic()

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

◆ isExtern()

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

◆ isInitialized()

◆ isStatic()

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

Checks if the block has static storage duration.

Definition at line 79 of file Block.h.

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

◆ isTemporary()

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

Checks if the block is temporary.

Definition at line 81 of file Block.h.

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

◆ isWeak()

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

Definition at line 82 of file Block.h.

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().

◆ rawData() [1/2]

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

Returns a pointer to the raw data, including metadata.

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

Definition at line 113 of file Block.h.

References Block().

Referenced by clang::interp::CheckLocalLoad(), data(), data(), clang::interp::InterpState::deallocate(), getBlockDesc(), and invokeCtor().

◆ rawData() [2/2]

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

Definition at line 116 of file Block.h.

References Block().

◆ 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 165 of file Block.h.

References DeadBlock.

Referenced by DeadBlock.

◆ DynamicAllocator

friend class DynamicAllocator
friend

Definition at line 167 of file Block.h.

References DynamicAllocator.

Referenced by DynamicAllocator.

◆ InterpState

friend class InterpState
friend

Definition at line 166 of file Block.h.

References InterpState.

Referenced by InterpState.

◆ Pointer

friend class Pointer
friend

Definition at line 164 of file Block.h.

References Pointer.

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

◆ Program

friend class Program
friend

Definition at line 168 of file Block.h.

References Program.

Referenced by Program.

Member Data Documentation

◆ GlobalMD

uint8_t clang::interp::Block::GlobalMD = sizeof(GlobalInlineDescriptor)
staticconstexpr

Definition at line 51 of file Block.h.

◆ InlineDescMD


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