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/InterpBlock.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 DescriptorgetDescriptor () 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 Tderef () const
template<typename T>
Tderef ()
template<typename T>
TgetBlockDesc ()
template<typename T>
const TgetBlockDesc () 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 InterpBlock.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 InterpBlock.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 InterpBlock.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 103 of file InterpBlock.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 104 of file InterpBlock.h.

References rawData().

◆ deref() [1/2]

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

Definition at line 118 of file InterpBlock.h.

References data(), and clang::T.

◆ deref() [2/2]

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

◆ dump() [1/2]

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

Definition at line 153 of file InterpBlock.h.

References dump().

Referenced by dump().

◆ dump() [2/2]

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

Definition at line 609 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 124 of file InterpBlock.h.

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

◆ getDeclID()

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

Returns the declaration ID.

Definition at line 90 of file InterpBlock.h.

Referenced by CheckTemporary().

◆ getDescriptor()

◆ getEvalID()

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

The Evaluation ID this block was created in.

Definition at line 95 of file InterpBlock.h.

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

◆ getMetadataSize()

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

Returns the size of the metadata.

Definition at line 88 of file InterpBlock.h.

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

◆ getSize()

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

Returns the size of the block, including metadata.

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

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

Referenced by 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 135 of file InterpBlock.h.

References data().

Referenced by invokeCtor().

◆ invokeDtor()

◆ isAccessible()

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

Definition at line 156 of file InterpBlock.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()

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

◆ isStatic()

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

Checks if the block has static storage duration.

Definition at line 79 of file InterpBlock.h.

Referenced by 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 InterpBlock.h.

Referenced by CheckTemporary(), noteValueLocation(), and noteValueLocation().

◆ isWeak()

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

Definition at line 82 of file InterpBlock.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 InterpBlock.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 108 of file InterpBlock.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 111 of file InterpBlock.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 InterpBlock.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 160 of file InterpBlock.h.

References DeadBlock.

Referenced by DeadBlock.

◆ DynamicAllocator

friend class DynamicAllocator
friend

Definition at line 162 of file InterpBlock.h.

References DynamicAllocator.

Referenced by DynamicAllocator.

◆ InterpState

friend class InterpState
friend

Definition at line 161 of file InterpBlock.h.

References InterpState.

Referenced by InterpState.

◆ Pointer

friend class Pointer
friend

Definition at line 159 of file InterpBlock.h.

References Pointer.

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

◆ Program

friend class Program
friend

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

◆ InlineDescMD


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