clang  19.0.0git
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
clang::interp::Block Class Referencefinal

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

#include "/home/runner/work/llvm/llvm/repo/clang/lib/AST/Interp/InterpBlock.h"

Public Member Functions

 Block (const std::optional< unsigned > &DeclID, const Descriptor *Desc, bool IsStatic=false, bool IsExtern=false)
 Creates a new block. More...
 
 Block (const Descriptor *Desc, bool IsStatic=false, bool IsExtern=false)
 
const DescriptorgetDescriptor () const
 Returns the block's descriptor. More...
 
bool hasPointers () const
 Checks if the block has any live pointers. More...
 
bool isExtern () const
 Checks if the block is extern. More...
 
bool isStatic () const
 Checks if the block has static storage duration. More...
 
bool isTemporary () const
 Checks if the block is temporary. More...
 
unsigned getSize () const
 Returns the size of the block. More...
 
std::optional< unsignedgetDeclID () const
 Returns the declaration ID. More...
 
bool isInitialized () const
 
std::byte * data ()
 Returns a pointer to the stored data. More...
 
const std::byte * data () const
 
std::byte * rawData ()
 Returns a pointer to the raw data, including metadata. More...
 
const std::byte * rawData () const
 
template<typename T >
Tderef ()
 Returns a view over the data. More...
 
template<typename T >
const Tderef () const
 
void invokeCtor ()
 Invokes the constructor. More...
 
void invokeDtor ()
 Invokes the Destructor. More...
 
void dump () const
 
void dump (llvm::raw_ostream &OS) const
 

Protected Member Functions

 Block (const Descriptor *Desc, bool IsExtern, bool IsStatic, bool IsDead)
 
void cleanup ()
 Deletes a dead block at the end of its lifetime. More...
 
void addPointer (Pointer *P)
 Pointer chain management. More...
 
void removePointer (Pointer *P)
 
void replacePointer (Pointer *Old, Pointer *New)
 
bool hasPointer (const Pointer *P) const
 

Protected Attributes

PointerPointers = nullptr
 Start of the chain of pointers. More...
 
std::optional< unsignedDeclID
 Unique identifier of the declaration. More...
 
bool IsStatic = false
 Flag indicating if the block has static storage duration. More...
 
bool IsExtern = false
 Flag indicating if the block is an extern. More...
 
bool IsDead = false
 Flag indicating if the pointer is dead. More...
 
bool IsInitialized = false
 Flag indicating if the block contents have been initialized via invokeCtor. More...
 
const DescriptorDesc
 Pointer to the stack slot descriptor. More...
 

Friends

class Pointer
 
class DeadBlock
 
class InterpState
 

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) │ Desc->getMetadataSize() │ Desc->getSize() │ └───────────────┴─────────────────────────┴─────────────────┘

Desc->getAllocSize() describes the size after the Block, i.e. the data size and the metadata size.

Definition at line 49 of file InterpBlock.h.

Constructor & Destructor Documentation

◆ Block() [1/3]

clang::interp::Block::Block ( const std::optional< unsigned > &  DeclID,
const Descriptor Desc,
bool  IsStatic = false,
bool  IsExtern = false 
)
inline

Creates a new block.

Definition at line 52 of file InterpBlock.h.

References Desc.

◆ Block() [2/3]

clang::interp::Block::Block ( const Descriptor Desc,
bool  IsStatic = false,
bool  IsExtern = false 
)
inline

Definition at line 58 of file InterpBlock.h.

References Desc.

◆ Block() [3/3]

clang::interp::Block::Block ( const Descriptor Desc,
bool  IsExtern,
bool  IsStatic,
bool  IsDead 
)
inlineprotected

Definition at line 133 of file InterpBlock.h.

Member Function Documentation

◆ addPointer()

void Block::addPointer ( Pointer P)
protected

Pointer chain management.

Definition at line 19 of file InterpBlock.cpp.

References hasPointer(), IsStatic, P, and Pointers.

Referenced by replacePointer().

◆ cleanup()

void Block::cleanup ( )
protected

Deletes a dead block at the end of its lifetime.

Definition at line 56 of file InterpBlock.cpp.

References IsDead, and Pointers.

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

◆ 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 82 of file InterpBlock.h.

References Desc, clang::interp::Descriptor::getMetadataSize(), and rawData().

Referenced by clang::interp::DeadBlock::data(), clang::interp::InterpState::deallocate(), deref(), clang::interp::Pointer::elem(), invokeCtor(), and invokeDtor().

◆ data() [2/2]

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

Definition at line 87 of file InterpBlock.h.

References Desc, clang::interp::Descriptor::getMetadataSize(), and rawData().

◆ deref() [1/2]

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

Returns a view over the data.

Definition at line 104 of file InterpBlock.h.

References data(), and clang::T.

◆ deref() [2/2]

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

Definition at line 105 of file InterpBlock.h.

References data(), and clang::T.

◆ dump() [1/2]

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

Definition at line 125 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 293 of file Disasm.cpp.

References IsDead, IsExtern, IsInitialized, IsStatic, P, and Pointers.

◆ getDeclID()

std::optional<unsigned> clang::interp::Block::getDeclID ( ) const
inline

Returns the declaration ID.

Definition at line 77 of file InterpBlock.h.

References DeclID.

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

◆ getDescriptor()

const Descriptor* clang::interp::Block::getDescriptor ( ) const
inline

Returns the block's descriptor.

Definition at line 65 of file InterpBlock.h.

References Desc.

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

◆ getSize()

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

Returns the size of the block.

Definition at line 75 of file InterpBlock.h.

References Desc, and clang::interp::Descriptor::getAllocSize().

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

◆ hasPointer()

bool Block::hasPointer ( const Pointer P) const
protected

Definition at line 85 of file InterpBlock.cpp.

References P, and Pointers.

Referenced by addPointer(), removePointer(), and replacePointer().

◆ hasPointers()

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

Checks if the block has any live pointers.

Definition at line 67 of file InterpBlock.h.

References Pointers.

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

◆ invokeCtor()

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

◆ invokeDtor()

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

◆ isExtern()

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

Checks if the block is extern.

Definition at line 69 of file InterpBlock.h.

References IsExtern.

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

◆ 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 71 of file InterpBlock.h.

References IsStatic.

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

◆ isTemporary()

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

Checks if the block is temporary.

Definition at line 73 of file InterpBlock.h.

References Desc, and clang::interp::Descriptor::IsTemporary.

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

◆ 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 95 of file InterpBlock.h.

Referenced by data(), clang::interp::InterpState::deallocate(), clang::interp::Pointer::deref(), invokeCtor(), and clang::interp::DeadBlock::rawData().

◆ rawData() [2/2]

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

Definition at line 98 of file InterpBlock.h.

◆ removePointer()

void Block::removePointer ( Pointer P)
protected

Definition at line 36 of file InterpBlock.cpp.

References hasPointer(), IsStatic, P, and Pointers.

Referenced by replacePointer().

◆ replacePointer()

void Block::replacePointer ( Pointer Old,
Pointer New 
)
protected

Friends And Related Function Documentation

◆ DeadBlock

friend class DeadBlock
friend

Definition at line 130 of file InterpBlock.h.

◆ InterpState

friend class InterpState
friend

Definition at line 131 of file InterpBlock.h.

◆ Pointer

friend class Pointer
friend

Definition at line 129 of file InterpBlock.h.

Member Data Documentation

◆ DeclID

std::optional<unsigned> clang::interp::Block::DeclID
protected

Unique identifier of the declaration.

Definition at line 150 of file InterpBlock.h.

Referenced by getDeclID().

◆ Desc

const Descriptor* clang::interp::Block::Desc
protected

Pointer to the stack slot descriptor.

Definition at line 162 of file InterpBlock.h.

Referenced by Block(), data(), clang::interp::Pointer::getDeclDesc(), getDescriptor(), getSize(), invokeCtor(), invokeDtor(), and isTemporary().

◆ IsDead

bool clang::interp::Block::IsDead = false
protected

Flag indicating if the pointer is dead.

This is only ever set once, when converting the Block to a DeadBlock.

Definition at line 157 of file InterpBlock.h.

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

◆ IsExtern

bool clang::interp::Block::IsExtern = false
protected

Flag indicating if the block is an extern.

Definition at line 154 of file InterpBlock.h.

Referenced by dump(), and isExtern().

◆ IsInitialized

bool clang::interp::Block::IsInitialized = false
protected

Flag indicating if the block contents have been initialized via invokeCtor.

Definition at line 160 of file InterpBlock.h.

Referenced by clang::interp::InterpState::deallocate(), dump(), invokeCtor(), invokeDtor(), and isInitialized().

◆ IsStatic

bool clang::interp::Block::IsStatic = false
protected

Flag indicating if the block has static storage duration.

Definition at line 152 of file InterpBlock.h.

Referenced by addPointer(), dump(), isStatic(), removePointer(), and replacePointer().

◆ Pointers

Pointer* clang::interp::Block::Pointers = nullptr
protected

Start of the chain of pointers.

Definition at line 148 of file InterpBlock.h.

Referenced by addPointer(), cleanup(), clang::interp::DeadBlock::DeadBlock(), dump(), hasPointer(), hasPointers(), removePointer(), and replacePointer().


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