clang 24.0.0git
clang::interp::Pointer Class Reference

A pointer to a memory block, live or dead. More...

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

Public Member Functions

 Pointer ()
 Pointer (IntPointer &&IntPtr)
 Pointer (Block *B)
 Pointer (Block *B, uint64_t BaseAndOffset)
 Pointer (const Pointer &P)
 Pointer (Pointer &&P)
 Pointer (uint64_t Address, const Type *Ty, uint64_t Offset=0, std::optional< bool > IsNull=std::nullopt)
 Pointer (const Function *F, uint64_t Offset=0)
 Pointer (const Type *TypePtr, const Type *TypeInfoType, uint64_t Offset=0)
 Pointer (const Expr *Base, unsigned Id)
 Pointer (StringPointer Str, uint64_t Offset=0)
 Pointer (DeclOrExpr DOE, bool ConstexprUnknown=false)
 Pointer (OpaquePointer OP, uint64_t Offset=0)
 Pointer (Block *Pointee, unsigned Base, uint64_t Offset)
 Pointer (PtrView V)
 ~Pointer ()
Pointer & operator= (const Pointer &P)
Pointer & operator= (Pointer &&P)
bool operator== (const Pointer &P) const
bool operator!= (const Pointer &P) const
APValue toAPValue (const ASTContext &ASTCtx) const
 Converts the pointer to an APValue.
std::string toDiagnosticString (const ASTContext &Ctx) const
 Converts the pointer to a string usable in diagnostics.
uint64_t getIntegerRepresentation () const
PtrView view () const
std::optional< APValue > toRValue (const Context &Ctx, QualType ResultType) const
 Converts the pointer to an APValue that is an rvalue.
Pointer atIndex (uint64_t Idx) const
 Offsets a pointer inside an array.
Pointer atField (unsigned Off) const
 Creates a pointer to a field.
Pointer atFieldSub (unsigned Off) const
 Subtract the given offset from the current Base and Offset of the pointer.
Pointer narrow () const
 Restricts the scope of an array element pointer.
Pointer expand () const
 Expands a pointer to the containing array, undoing narrowing.
bool isZero () const
 Checks if the pointer is null.
bool isLive () const
 Checks if the pointer is live.
bool isField () const
 Checks if the item is a field in an object.
const Descriptor * getDeclDesc () const
 Accessor for information about the declaration site.
SourceLocation getDeclLoc () const
DeclOrExpr getSource () const
 Returns the expression or declaration the pointer has been created for.
Pointer getBase () const
 Returns a pointer to the object of which this pointer is a field.
Pointer getArray () const
 Returns the parent array.
const Descriptor * getFieldDesc () const
 Accessors for information about the innermost field.
QualType getType () const
 Returns the type of the innermost field.
const VarDecl * getRootVarDecl () const
const ValueDecl * getRootValueDecl () const
const Expr * getRootExpr () const
Pointer getDeclPtr () const
size_t elemSize () const
 Returns the element size of the innermost field.
size_t getSize () const
 Returns the total size of the innermost field.
unsigned getOffset () const
 Returns the offset into an array.
bool isArrayRoot () const
 Whether this array refers to an array, but not to the first element.
bool inArray () const
 Checks if the innermost field is an array.
bool inUnion () const
bool inPrimitiveArray () const
 Checks if the structure is a primitive array.
bool isUnknownSizeArray () const
 Checks if the structure is an array of unknown size.
bool isArrayElement () const
 Checks if the pointer points to an array.
bool isRoot () const
 Pointer points directly to a block.
bool canBeInitialized () const
 If this pointer has an InlineDescriptor we can use to initialize.
const BlockPointer & asBlockPointer () const
const IntPointer & asIntPointer () const
const FunctionPointer & asFunctionPointer () const
const TypeidPointer & asTypeidPointer () const
const StringPointer & asStringPointer () const
const OpaquePointer & asOpaquePointer () const
bool isBlockPointer () const
bool isIntegralPointer () const
bool isFunctionPointer () const
bool isTypeidPointer () const
bool isStringPointer () const
bool isOpaquePointer () const
const Record * getRecord () const
 Returns the record descriptor of a class.
const Record * getElemRecord () const
 Returns the element record type, if this is a non-primive array.
const FieldDecl * getField () const
 Returns the field information.
bool isExtern () const
 Checks if the storage is extern.
bool isStatic () const
 Checks if the storage is static.
bool isTemporary () const
 Checks if the storage is temporary.
bool isDynamic () const
 Checks if the storage has been dynamically allocated.
bool isStaticTemporary () const
 Checks if the storage is a static temporary.
bool isMutable () const
 Checks if the field is mutable.
bool isWeak () const
bool isActive () const
 Checks if the object is active.
bool isBaseClass () const
 Checks if a structure is a base class.
bool isVirtualBaseClass () const
bool isDummy () const
 Checks if the pointer points to a dummy value.
bool isConst () const
 Checks if an object or a subfield is mutable.
bool isConstInMutable () const
bool isVolatile () const
 Checks if an object or a subfield is volatile.
UnsignedOrNone getDeclID () const
 Returns the declaration ID.
uint64_t getByteOffset () const
 Returns the byte offset from the start.
unsigned getNumElems () const
 Returns the number of elements.
const Block * block () const
const std::byte * getRawAddress () const
 If backed by actual data (i.e.
int64_t getIndex () const
 Returns the index into an array.
bool isOnePastEnd () const
 Checks if the index is one past end.
bool isPastEnd () const
 Checks if the pointer points past the end of the object.
bool isElementPastEnd () const
 Checks if the pointer is an out-of-bounds element pointer.
bool isZeroSizeArray () const
 Checks if the pointer is pointing to a zero-size array.
bool canDeref (PrimType T) const
 Checks whether the pointer can be dereferenced to the given PrimType.
template<typename T>
T & deref () const
 Dereferences the pointer, if it's live.
template<typename T>
T load () const
template<typename T>
T & elem (unsigned I) const
 Dereferences the element at index I.
template<typename T>
T loadElem (unsigned I) const
bool isConstexprUnknown () const
bool isDereferencable () const
 Whether this block can be read from at all.
bool isReadablePointerType () const
void initialize () const
 Initializes a field.
void initializeElement (unsigned Index) const
 Initialized the given element of a primitive array.
void initializeAllElements () const
 Initialize all elements of a primitive array at once.
bool isInitialized () const
 Checks if an object was initialized.
bool isElementInitialized (unsigned Index) const
 Like isInitialized(), but for primitive arrays.
bool allElementsInitialized () const
bool allElementsAlive () const
bool isElementAlive (unsigned Index) const
void activate () const
 Activates a field.
void deactivate () const
 Deactivates an entire strurcutre.
Lifetime getLifetime () const
void startLifetime () const
 Start the lifetime of this pointer.
void endLifetime () const
 Ends the lifetime of the pointer.
void setLifeState (Lifetime L) const
Pointer stripBaseCasts () const
 Strip base casts from this Pointer.
ComparisonCategoryResult compare (const Pointer &Other) const
 Compare two pointers.
bool pointsToLiteral () const
 Whether this points to a block that's been created for a "literal lvalue", i.e.
bool pointsToLabel () const
 Whether this points to a block created for an AddrLabelExpr.
const AddrLabelExpr * getPointedToLabel () const
 Returns the AddrLabelExpr the Pointer points to, if any.
void print (llvm::raw_ostream &OS) const
 Prints the pointer.
std::optional< size_t > computeOffsetForComparison (const ASTContext &ASTCtx) const
 Compute an integer that can be used to compare this pointer to another one.
std::optional< size_t > computeLayoutOffset (const ASTContext &ASTCtx) const
 Compute the pointer offset as given by the ASTRecordLayout.

Static Public Member Functions

static bool hasSameBase (const Pointer &A, const Pointer &B)
 Checks if two pointers are comparable.
static bool elemsOfSameArray (const Pointer &A, const Pointer &B)
 Checks if two pointers can be subtracted.
static bool pointToSameBlock (const Pointer &A, const Pointer &B)
 Checks if both given pointers point to the same block.
static std::optional< std::pair< PtrView, PtrView > > computeSplitPoint (const Pointer &A, const Pointer &B)

Friends

class Block
class DeadBlock
class MemberPointer
class InterpState
class DynamicAllocator
class Program

Detailed Description

A pointer to a memory block, live or dead.

This object can be allocated into interpreter stack frames. If pointing to a live block, it is a link in the chain of pointers pointing to the block.

In the simplest form, a Pointer has a Block* (the pointee) and both Base and Offset are 0, which means it will point to raw data.

The Base field is used to access metadata about the data. For primitive arrays, the Base is followed by an InitMap. In a variety of cases, the Base is preceded by an InlineDescriptor, which is used to track the initialization state, among other things.

The Offset field is used to access the actual data. In other words, the data the pointer decribes can be found at Pointee->rawData() + Pointer.Offset.

/// Pointee                      Offset
/// │                              │
/// │                              │
/// ▼                              ▼
/// ┌───────┬────────────┬─────────┬────────────────────────────┐
/// │ Block │ InlineDesc │ InitMap │ Actual Data                │
/// └───────┴────────────┴─────────┴────────────────────────────┘
///                      ▲
///                      │
///                      │
///                     Base
/// 

Definition at line 546 of file Pointer.h.

Constructor & Destructor Documentation

◆ Pointer() [1/15]

◆ Pointer() [2/15]

clang::interp::Pointer::Pointer ( IntPointer && IntPtr)
inline

Definition at line 549 of file Pointer.h.

References Int.

◆ Pointer() [3/15]

Pointer::Pointer ( Block * B)

Definition at line 38 of file Pointer.cpp.

References Block, and Pointer().

◆ Pointer() [4/15]

Pointer::Pointer ( Block * B,
uint64_t BaseAndOffset )

Definition at line 42 of file Pointer.cpp.

References Block, and Pointer().

◆ Pointer() [5/15]

◆ Pointer() [6/15]

◆ Pointer() [7/15]

clang::interp::Pointer::Pointer ( uint64_t Address,
const Type * Ty,
uint64_t Offset = 0,
std::optional< bool > IsNull = std::nullopt )
inline

Definition at line 555 of file Pointer.h.

References clang::interp::Address, Int, and IsNull.

◆ Pointer() [8/15]

clang::interp::Pointer::Pointer ( const Function * F,
uint64_t Offset = 0 )
inline

Definition at line 559 of file Pointer.h.

References Fn.

◆ Pointer() [9/15]

clang::interp::Pointer::Pointer ( const Type * TypePtr,
const Type * TypeInfoType,
uint64_t Offset = 0 )
inline

Definition at line 561 of file Pointer.h.

References Typeid.

◆ Pointer() [10/15]

clang::interp::Pointer::Pointer ( const Expr * Base,
unsigned Id )
inline

Definition at line 566 of file Pointer.h.

References Str, and clang::interp::String.

◆ Pointer() [11/15]

clang::interp::Pointer::Pointer ( StringPointer Str,
uint64_t Offset = 0 )
inline

Definition at line 568 of file Pointer.h.

References Str, and clang::interp::String.

◆ Pointer() [12/15]

clang::interp::Pointer::Pointer ( DeclOrExpr DOE,
bool ConstexprUnknown = false )
inline

◆ Pointer() [13/15]

clang::interp::Pointer::Pointer ( OpaquePointer OP,
uint64_t Offset = 0 )
inline

Definition at line 578 of file Pointer.h.

References Opaque.

◆ Pointer() [14/15]

Pointer::Pointer ( Block * Pointee,
unsigned Base,
uint64_t Offset )

Definition at line 45 of file Pointer.cpp.

References Block, BS, and clang::interp::Block::getMetadataSize().

◆ Pointer() [15/15]

clang::interp::Pointer::Pointer ( PtrView V)
inlineexplicit

Definition at line 582 of file Pointer.h.

References Pointer(), and V.

◆ ~Pointer()

Pointer::~Pointer ( )

Definition at line 106 of file Pointer.cpp.

References Block, BS, and isBlockPointer().

Member Function Documentation

◆ activate()

void clang::interp::Pointer::activate ( ) const
inline

Activates a field.

Definition at line 1244 of file Pointer.h.

References view().

◆ allElementsAlive()

◆ allElementsInitialized()

bool clang::interp::Pointer::allElementsInitialized ( ) const
inline

Definition at line 1235 of file Pointer.h.

References getFieldDesc(), isArrayRoot(), and view().

◆ asBlockPointer()

const BlockPointer & clang::interp::Pointer::asBlockPointer ( ) const
inlinenodiscard

Definition at line 835 of file Pointer.h.

References BS, and clang::isBlockPointer().

Referenced by computeSplitPoint(), and clang::interp::DeadBlock::DeadBlock().

◆ asFunctionPointer()

const FunctionPointer & clang::interp::Pointer::asFunctionPointer ( ) const
inlinenodiscard

Definition at line 843 of file Pointer.h.

References Fn, and isFunctionPointer().

Referenced by toAPValue().

◆ asIntPointer()

const IntPointer & clang::interp::Pointer::asIntPointer ( ) const
inlinenodiscard

Definition at line 839 of file Pointer.h.

References Int, and isIntegralPointer().

Referenced by toAPValue(), and toDiagnosticString().

◆ asOpaquePointer()

const OpaquePointer & clang::interp::Pointer::asOpaquePointer ( ) const
inlinenodiscard

Definition at line 855 of file Pointer.h.

References isOpaquePointer(), and Opaque.

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

◆ asStringPointer()

const StringPointer & clang::interp::Pointer::asStringPointer ( ) const
inlinenodiscard

◆ asTypeidPointer()

const TypeidPointer & clang::interp::Pointer::asTypeidPointer ( ) const
inlinenodiscard

Definition at line 847 of file Pointer.h.

References isTypeidPointer(), and Typeid.

Referenced by computeLayoutOffset(), computeOffsetForComparison(), hasSameBase(), and print().

◆ atField()

Pointer clang::interp::Pointer::atField ( unsigned Off) const
inlinenodiscard

Creates a pointer to a field.

Definition at line 631 of file Pointer.h.

References atField(), clang::Off, Pointer(), Pointer, and view().

Referenced by atField(), clang::interp::MemberPointer::getBase(), and clang::interp::MemberPointer::toPointer().

◆ atFieldSub()

Pointer clang::interp::Pointer::atFieldSub ( unsigned Off) const
inlinenodiscard

Subtract the given offset from the current Base and Offset of the pointer.

Definition at line 637 of file Pointer.h.

References BS, clang::Off, Pointer(), and Pointer.

Referenced by clang::interp::MemberPointer::getBase().

◆ atIndex()

Pointer clang::interp::Pointer::atIndex ( uint64_t Idx) const
inlinenodiscard

◆ block()

◆ canBeInitialized()

bool clang::interp::Pointer::canBeInitialized ( ) const
inline

If this pointer has an InlineDescriptor we can use to initialize.

Definition at line 828 of file Pointer.h.

References BS, and clang::isBlockPointer().

Referenced by clang::interp::interp__builtin_carryop(), and clang::interp::interp__builtin_overflowop().

◆ canDeref()

bool clang::interp::Pointer::canDeref ( PrimType T) const
inline

◆ compare()

ComparisonCategoryResult clang::interp::Pointer::compare ( const Pointer & Other) const
inline

Compare two pointers.

Definition at line 1280 of file Pointer.h.

References clang::Equal, clang::Greater, hasSameBase(), clang::Less, clang::Other, Pointer(), and clang::Unordered.

◆ computeLayoutOffset()

std::optional< size_t > Pointer::computeLayoutOffset ( const ASTContext & ASTCtx) const

Compute the pointer offset as given by the ASTRecordLayout.

Returns the result in bytes.

Definition at line 609 of file Pointer.cpp.

References asTypeidPointer(), clang::interp::Block, clang::cast(), clang::interp::PtrView::expand(), clang::interp::Fn, clang::interp::PtrView::getArray(), clang::ASTContext::getASTRecordLayout(), clang::interp::PtrView::getBase(), clang::ASTRecordLayout::getBaseClassOffset(), clang::ASTContext::getCanonicalTagType(), clang::interp::PtrView::getDeclDesc(), clang::interp::Descriptor::getElemQualType(), clang::interp::PtrView::getField(), clang::interp::PtrView::getFieldDesc(), clang::FieldDecl::getFieldIndex(), clang::ASTRecordLayout::getFieldOffset(), clang::interp::PtrView::getIndex(), getIntegerRepresentation(), clang::FieldDecl::getParent(), clang::CharUnits::getQuantity(), getRecordDecl(), clang::interp::Descriptor::getType(), clang::ValueDecl::getType(), clang::ASTContext::getTypeSizeInChars(), clang::ASTRecordLayout::getVBaseClassOffset(), clang::ASTContext::hasLayout(), Int, clang::interp::Int, clang::interp::Descriptor::isArray(), clang::interp::PtrView::isArrayElement(), clang::interp::PtrView::isBaseClass(), clang::interp::PtrView::isOnePastEnd(), clang::interp::PtrView::isPastEnd(), clang::interp::PtrView::isRoot(), clang::interp::PtrView::isVirtualBaseClass(), Opaque, clang::interp::Opaque, clang::Result, Str, clang::interp::String, clang::T, clang::ASTContext::toCharUnitsFromBits(), clang::interp::Typeid, clang::interp::TypeidPointer::TypePtr, validType(), and view().

Referenced by computeOffsetForComparison(), and clang::interp::SubPtr().

◆ computeOffsetForComparison()

std::optional< size_t > Pointer::computeOffsetForComparison ( const ASTContext & ASTCtx) const

Compute an integer that can be used to compare this pointer to another one.

Compute an offset that can be used to compare the pointer to another one with the same base.

This is usually NOT the same as the pointer offset regarding the AST record layout.

To get accurate results, we basically have to compute the lvalue offset using the ASTRecordLayout.

This function will fail if we're trying to get the type size of a forward declaration.

Definition at line 528 of file Pointer.cpp.

References asTypeidPointer(), clang::interp::Block, computeLayoutOffset(), clang::interp::PtrView::elemSize(), clang::interp::PtrView::expand(), clang::interp::Fn, clang::interp::PtrView::getArray(), clang::ASTContext::getASTRecordLayout(), clang::interp::PtrView::getBase(), clang::interp::PtrView::getDeclDesc(), clang::interp::PtrView::getField(), clang::FieldDecl::getFieldIndex(), clang::ASTRecordLayout::getFieldOffset(), clang::interp::PtrView::getIndex(), clang::interp::PtrView::getInlineDesc(), getIntegerRepresentation(), clang::CharUnits::getQuantity(), clang::interp::PtrView::getRecord(), clang::interp::Descriptor::getType(), clang::ValueDecl::getType(), clang::ASTContext::getTypeSizeInChars(), clang::ASTContext::hasLayout(), Int, clang::interp::Int, clang::interp::PtrView::isArrayElement(), clang::interp::PtrView::isBaseClass(), clang::interp::PtrView::isOnePastEnd(), clang::interp::PtrView::isRoot(), clang::interp::PtrView::isVirtualBaseClass(), clang::interp::InlineDescriptor::Offset, clang::interp::Opaque, clang::Result, Str, clang::interp::String, clang::T, clang::ASTContext::toCharUnitsFromBits(), clang::interp::Typeid, clang::interp::TypeidPointer::TypePtr, validType(), and view().

Referenced by clang::interp::CmpHelper< Pointer >(), and clang::interp::CmpHelperEQ< Pointer >().

◆ computeSplitPoint()

◆ deactivate()

void clang::interp::Pointer::deactivate ( ) const
inline

Deactivates an entire strurcutre.

Definition at line 1246 of file Pointer.h.

◆ deref()

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

◆ elem()

template<typename T>
T & clang::interp::Pointer::elem ( unsigned I) const
inline

Dereferences the element at index I.

This is equivalent to atIndex(I).deref<T>().

Definition at line 1141 of file Pointer.h.

References BS, getFieldDesc(), getNumElems(), clang::isBlockPointer(), isDereferencable(), isLive(), clang::T, and view().

Referenced by clang::interp::convertBoolVectorToInt(), clang::interp::CopyArray(), clang::interp::Divc(), clang::interp::interp__builtin_elementwise_abs(), clang::interp::interp__builtin_elementwise_fp_binop(), clang::interp::interp__builtin_elementwise_int_binop(), clang::interp::interp__builtin_elementwise_int_unaryop(), clang::interp::interp__builtin_elementwise_maxmin(), clang::interp::interp__builtin_elementwise_triop(), clang::interp::interp__builtin_elementwise_triop_fp(), clang::interp::interp__builtin_ia32_addsub(), clang::interp::interp__builtin_ia32_cmp_mask(), clang::interp::interp__builtin_ia32_cvt_mask2vec(), clang::interp::interp__builtin_ia32_cvt_vec2mask(), clang::interp::interp__builtin_ia32_cvtpd2ps(), clang::interp::interp__builtin_ia32_cvtsd2ss(), clang::interp::interp__builtin_ia32_dbpsadbw(), clang::interp::interp__builtin_ia32_extract_vector(), clang::interp::interp__builtin_ia32_extract_vector_masked(), clang::interp::interp__builtin_ia32_gfni_affine(), clang::interp::interp__builtin_ia32_gfni_mul(), clang::interp::interp__builtin_ia32_insert_subvector(), clang::interp::interp__builtin_ia32_mpsadbw(), clang::interp::interp__builtin_ia32_multishiftqb(), clang::interp::interp__builtin_ia32_pack(), clang::interp::interp__builtin_ia32_pclmulqdq(), clang::interp::interp__builtin_ia32_pmul(), clang::interp::interp__builtin_ia32_psadbw(), clang::interp::interp__builtin_ia32_select(), clang::interp::interp__builtin_ia32_select_scalar(), clang::interp::interp__builtin_ia32_shift_with_count(), clang::interp::interp__builtin_ia32_shufbitqmb_mask(), clang::interp::interp__builtin_ia32_shuffle_generic(), clang::interp::interp__builtin_ia32_test_op(), clang::interp::interp__builtin_ia32_vcvtps2ph(), clang::interp::interp__builtin_ia32_vec_ext(), clang::interp::interp__builtin_ia32_vec_set(), clang::interp::interp__builtin_ia32_vpconflict(), clang::interp::interp__builtin_ia32_vpdp(), clang::interp::interp__builtin_nan(), clang::interp::interp__builtin_scalar_fp_round_mask_binop(), clang::interp::interp__builtin_vector_reduce(), clang::interp::interp_builtin_horizontal_fp_binop(), clang::interp::interp_builtin_horizontal_int_binop(), clang::interp::interp_builtin_ia32_cvt_scalar_to_int(), clang::interp::interp_builtin_ia32_cvt_vector_to_int(), and clang::interp::Mulc().

◆ elemSize()

size_t clang::interp::Pointer::elemSize ( ) const
inline

Returns the element size of the innermost field.

Definition at line 756 of file Pointer.h.

References isIntegralPointer(), isStringPointer(), Str, and view().

Referenced by getIntegerRepresentation(), and toAPValue().

◆ elemsOfSameArray()

bool Pointer::elemsOfSameArray ( const Pointer & A,
const Pointer & B )
static

Checks if two pointers can be subtracted.

Definition at line 1015 of file Pointer.cpp.

References clang::interp::BlockPointer::Base, BS, getField(), hasSameBase(), isBaseClass(), isBlockPointer(), Pointer(), and V.

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

◆ endLifetime()

void clang::interp::Pointer::endLifetime ( ) const
inline

Ends the lifetime of the pointer.

This works for pointer with an InlineDescriptor as well as primitive array elements. This function is used by std::destroy_at.

Definition at line 1264 of file Pointer.h.

References clang::interp::Ended, and setLifeState().

◆ expand()

Pointer clang::interp::Pointer::expand ( ) const
inlinenodiscard

Expands a pointer to the containing array, undoing narrowing.

Definition at line 651 of file Pointer.h.

References expand(), clang::isBlockPointer(), Pointer(), Pointer, and view().

Referenced by clang::interp::CheckNewTypeMismatch(), expand(), clang::interp::interp__builtin_memcpy(), clang::interp::operator<<(), and pointsToLastObject().

◆ getArray()

Pointer clang::interp::Pointer::getArray ( ) const
inlinenodiscard

Returns the parent array.

Definition at line 713 of file Pointer.h.

References getArray(), Pointer(), Pointer, and view().

Referenced by getArray(), clang::interp::operator<<(), and pointsToLastObject().

◆ getBase()

Pointer clang::interp::Pointer::getBase ( ) const
inlinenodiscard

Returns a pointer to the object of which this pointer is a field.

Definition at line 711 of file Pointer.h.

References getBase(), Pointer(), Pointer, and view().

Referenced by computeSplitPoint(), getBase(), and pointsToLastObject().

◆ getByteOffset()

uint64_t clang::interp::Pointer::getByteOffset ( ) const
inline

Returns the byte offset from the start.

Definition at line 986 of file Pointer.h.

References clang::isBlockPointer(), isOnePastEnd(), and clang::interp::PtrView::PastEndMark.

Referenced by clang::interp::interp__builtin_strlen(), and clang::interp::PtrPtrCast().

◆ getDeclDesc()

const Descriptor * clang::interp::Pointer::getDeclDesc ( ) const
inline

Accessor for information about the declaration site.

Definition at line 688 of file Pointer.h.

References BS, and clang::isBlockPointer().

Referenced by clang::interp::CheckLiteralType(), getDeclLoc(), getFieldDesc(), getRootExpr(), getRootValueDecl(), getSource(), isConstexprUnknown(), and toAPValue().

◆ getDeclID()

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

Returns the declaration ID.

Definition at line 977 of file Pointer.h.

References BS, and clang::isBlockPointer().

◆ getDeclLoc()

SourceLocation clang::interp::Pointer::getDeclLoc ( ) const
inline

Definition at line 696 of file Pointer.h.

References getDeclDesc().

◆ getDeclPtr()

Pointer clang::interp::Pointer::getDeclPtr ( ) const
inlinenodiscard

Definition at line 753 of file Pointer.h.

References BS, Pointer(), and Pointer.

Referenced by toAPValue().

◆ getElemRecord()

const Record * clang::interp::Pointer::getElemRecord ( ) const
inline

Returns the element record type, if this is a non-primive array.

Definition at line 874 of file Pointer.h.

References view().

◆ getField()

const FieldDecl * clang::interp::Pointer::getField ( ) const
inline

Returns the field information.

Definition at line 876 of file Pointer.h.

References getFieldDesc().

Referenced by elemsOfSameArray(), and pointsToLastObject().

◆ getFieldDesc()

◆ getIndex()

◆ getIntegerRepresentation()

uint64_t clang::interp::Pointer::getIntegerRepresentation ( ) const
inline

◆ getLifetime()

Lifetime clang::interp::Pointer::getLifetime ( ) const
inline

Definition at line 1250 of file Pointer.h.

References clang::isBlockPointer(), clang::interp::Started, and view().

◆ getNumElems()

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

◆ getOffset()

unsigned clang::interp::Pointer::getOffset ( ) const
inline

Returns the offset into an array.

Definition at line 773 of file Pointer.h.

References clang::interp::PtrView::PastEndMark, and view().

◆ getPointedToLabel()

const AddrLabelExpr * clang::interp::Pointer::getPointedToLabel ( ) const
inline

Returns the AddrLabelExpr the Pointer points to, if any.

Definition at line 1308 of file Pointer.h.

References getRootExpr().

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

◆ getRawAddress()

const std::byte * clang::interp::Pointer::getRawAddress ( ) const
inline

If backed by actual data (i.e.

a block or string pointer), return an address to that data.

Definition at line 1014 of file Pointer.h.

References BS, clang::StringLiteral::getBytes(), clang::StringLiteral::getCharByteWidth(), clang::isBlockPointer(), isStringPointer(), and Str.

◆ getRecord()

const Record * clang::interp::Pointer::getRecord ( ) const
inline

Returns the record descriptor of a class.

Definition at line 868 of file Pointer.h.

References clang::isBlockPointer(), and view().

Referenced by clang::interp::Memcpy(), pointsToLastObject(), and clang::interp::MemberPointer::toPointer().

◆ getRootExpr()

◆ getRootValueDecl()

const ValueDecl * Pointer::getRootValueDecl ( ) const

◆ getRootVarDecl()

const VarDecl * Pointer::getRootVarDecl ( ) const

Definition at line 1325 of file Pointer.cpp.

References getRootValueDecl().

◆ getSize()

size_t clang::interp::Pointer::getSize ( ) const
inline

Returns the total size of the innermost field.

Definition at line 767 of file Pointer.h.

References getFieldDesc(), and clang::isBlockPointer().

◆ getSource()

DeclOrExpr clang::interp::Pointer::getSource ( ) const
inline

Returns the expression or declaration the pointer has been created for.

Definition at line 699 of file Pointer.h.

References Fn, clang::interp::Function::getDecl(), getDeclDesc(), clang::isBlockPointer(), and isFunctionPointer().

◆ getType()

◆ hasSameBase()

◆ inArray()

bool clang::interp::Pointer::inArray ( ) const
inline

Checks if the innermost field is an array.

Definition at line 783 of file Pointer.h.

References clang::isBlockPointer(), isStringPointer(), and view().

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

◆ initialize()

◆ initializeAllElements()

◆ initializeElement()

void clang::interp::Pointer::initializeElement ( unsigned Index) const
inline

Initialized the given element of a primitive array.

Definition at line 1213 of file Pointer.h.

References view().

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

◆ inPrimitiveArray()

bool clang::interp::Pointer::inPrimitiveArray ( ) const
inline

Checks if the structure is a primitive array.

Definition at line 797 of file Pointer.h.

References clang::isBlockPointer(), and view().

◆ inUnion()

bool clang::interp::Pointer::inUnion ( ) const
inline

Definition at line 790 of file Pointer.h.

References BS, clang::isBlockPointer(), and view().

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

◆ isActive()

bool clang::interp::Pointer::isActive ( ) const
inline

Checks if the object is active.

Definition at line 941 of file Pointer.h.

References clang::isBlockPointer(), and view().

◆ isArrayElement()

bool clang::interp::Pointer::isArrayElement ( ) const
inline

Checks if the pointer points to an array.

Definition at line 811 of file Pointer.h.

References clang::isBlockPointer(), and view().

Referenced by clang::interp::operator<<(), and pointsToLastObject().

◆ isArrayRoot()

bool clang::interp::Pointer::isArrayRoot ( ) const
inline

Whether this array refers to an array, but not to the first element.

Definition at line 780 of file Pointer.h.

References view().

Referenced by allElementsAlive(), allElementsInitialized(), clang::interp::BitCast(), initializeAllElements(), and clang::interp::operator<<().

◆ isBaseClass()

bool clang::interp::Pointer::isBaseClass ( ) const
inline

Checks if a structure is a base class.

Definition at line 947 of file Pointer.h.

References view().

Referenced by elemsOfSameArray(), clang::interp::IsBaseClass(), clang::interp::operator<<(), and pointsToLastObject().

◆ isBlockPointer()

◆ isConst()

bool clang::interp::Pointer::isConst ( ) const
inline

Checks if an object or a subfield is mutable.

Definition at line 954 of file Pointer.h.

References clang::isBlockPointer(), isIntegralPointer(), isStringPointer(), and view().

◆ isConstexprUnknown()

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

◆ isConstInMutable()

bool clang::interp::Pointer::isConstInMutable ( ) const
inline

Definition at line 963 of file Pointer.h.

References false, clang::isBlockPointer(), and isRoot().

◆ isDereferencable()

bool clang::interp::Pointer::isDereferencable ( ) const
inline

Whether this block can be read from at all.

This is only true for block pointers that point to a valid location inside that block.

Definition at line 1189 of file Pointer.h.

References clang::isBlockPointer(), isConstexprUnknown(), isDummy(), and isPastEnd().

Referenced by deref(), elem(), load(), and loadElem().

◆ isDummy()

◆ isDynamic()

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

Checks if the storage has been dynamically allocated.

Definition at line 904 of file Pointer.h.

References BS, and clang::isBlockPointer().

Referenced by pointsToLiteral(), and toAPValue().

◆ isElementAlive()

◆ isElementInitialized()

bool clang::interp::Pointer::isElementInitialized ( unsigned Index) const
inline

Like isInitialized(), but for primitive arrays.

Definition at line 1229 of file Pointer.h.

References clang::isBlockPointer(), and view().

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

◆ isElementPastEnd()

bool clang::interp::Pointer::isElementPastEnd ( ) const
inline

Checks if the pointer is an out-of-bounds element pointer.

Definition at line 1066 of file Pointer.h.

References clang::interp::PtrView::PastEndMark.

Referenced by print().

◆ isExtern()

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

Checks if the storage is extern.

Definition at line 883 of file Pointer.h.

References clang::isBlockPointer(), and view().

◆ isField()

bool clang::interp::Pointer::isField ( ) const
inline

Checks if the item is a field in an object.

Definition at line 680 of file Pointer.h.

References clang::isBlockPointer(), and view().

◆ isFunctionPointer()

bool clang::interp::Pointer::isFunctionPointer ( ) const
inline

◆ isInitialized()

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

Checks if an object was initialized.

Definition at line 1221 of file Pointer.h.

References clang::isBlockPointer(), and view().

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

◆ isIntegralPointer()

bool clang::interp::Pointer::isIntegralPointer ( ) const
inline

◆ isLive()

bool clang::interp::Pointer::isLive ( ) const
inline

Checks if the pointer is live.

Definition at line 674 of file Pointer.h.

References clang::isBlockPointer(), and view().

Referenced by deref(), clang::interp::DoBitCastPtr(), elem(), clang::interp::isReadable(), load(), loadElem(), clang::interp::operator<<(), and toRValue().

◆ isMutable()

bool clang::interp::Pointer::isMutable ( ) const
inline

Checks if the field is mutable.

Definition at line 915 of file Pointer.h.

References clang::isBlockPointer(), and view().

◆ isOnePastEnd()

◆ isOpaquePointer()

◆ isPastEnd()

bool clang::interp::Pointer::isPastEnd ( ) const
inline

Checks if the pointer points past the end of the object.

Definition at line 1056 of file Pointer.h.

References BS, isIntegralPointer(), isStringPointer(), isZero(), and Str.

Referenced by isDereferencable(), and toRValue().

◆ isReadablePointerType()

bool clang::interp::Pointer::isReadablePointerType ( ) const
inline

◆ isRoot()

bool clang::interp::Pointer::isRoot ( ) const
inline

◆ isStatic()

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

Checks if the storage is static.

Definition at line 889 of file Pointer.h.

References BS, and clang::isBlockPointer().

Referenced by allElementsAlive(), and isStaticTemporary().

◆ isStaticTemporary()

bool clang::interp::Pointer::isStaticTemporary ( ) const
inline

Checks if the storage is a static temporary.

Definition at line 912 of file Pointer.h.

References isStatic(), and isTemporary().

◆ isStringPointer()

◆ isTemporary()

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

Checks if the storage is temporary.

Definition at line 896 of file Pointer.h.

References BS, and clang::isBlockPointer().

Referenced by isStaticTemporary().

◆ isTypeidPointer()

bool clang::interp::Pointer::isTypeidPointer ( ) const
inline

Definition at line 863 of file Pointer.h.

References clang::interp::Typeid.

Referenced by asTypeidPointer(), and clang::interp::CmpHelper< Pointer >().

◆ isUnknownSizeArray()

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

◆ isVirtualBaseClass()

bool clang::interp::Pointer::isVirtualBaseClass ( ) const
inline

Definition at line 948 of file Pointer.h.

References view().

◆ isVolatile()

bool clang::interp::Pointer::isVolatile ( ) const
inline

Checks if an object or a subfield is volatile.

Definition at line 970 of file Pointer.h.

References clang::isBlockPointer(), and view().

◆ isWeak()

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

Definition at line 921 of file Pointer.h.

References BS, Fn, clang::isBlockPointer(), isFunctionPointer(), isOpaquePointer(), and Opaque.

◆ isZero()

◆ isZeroSizeArray()

bool clang::interp::Pointer::isZeroSizeArray ( ) const
inline

Checks if the pointer is pointing to a zero-size array.

Definition at line 1069 of file Pointer.h.

References getFieldDesc(), isFunctionPointer(), and isOpaquePointer().

Referenced by toAPValue(), and toRValue().

◆ load()

◆ loadElem()

◆ narrow()

Pointer clang::interp::Pointer::narrow ( ) const
inlinenodiscard

Restricts the scope of an array element pointer.

Definition at line 644 of file Pointer.h.

References clang::isBlockPointer(), narrow(), Pointer(), Pointer, and view().

Referenced by narrow(), and clang::interp::RunDestructors().

◆ operator!=()

bool clang::interp::Pointer::operator!= ( const Pointer & P) const
inline

Definition at line 589 of file Pointer.h.

References Pointer().

◆ operator=() [1/2]

◆ operator=() [2/2]

◆ operator==()

◆ pointsToLabel()

bool Pointer::pointsToLabel ( ) const

Whether this points to a block created for an AddrLabelExpr.

Definition at line 1068 of file Pointer.cpp.

References isOpaquePointer(), isZero(), and Opaque.

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

◆ pointsToLiteral()

bool Pointer::pointsToLiteral ( ) const

Whether this points to a block that's been created for a "literal lvalue", i.e.

a non-MaterializeTemporaryExpr Expr.

Definition at line 1057 of file Pointer.cpp.

References getRootExpr(), clang::isa(), isDynamic(), and isZero().

◆ pointToSameBlock()

bool Pointer::pointToSameBlock ( const Pointer & A,
const Pointer & B )
static

Checks if both given pointers point to the same block.

Definition at line 1009 of file Pointer.cpp.

References block(), isBlockPointer(), and Pointer().

Referenced by clang::interp::interp__builtin_memcpy(), and clang::interp::runRecordDestructor().

◆ print()

◆ setLifeState()

void clang::interp::Pointer::setLifeState ( Lifetime L) const
inline

Definition at line 1266 of file Pointer.h.

References clang::isBlockPointer(), and view().

Referenced by endLifetime(), and startLifetime().

◆ startLifetime()

void clang::interp::Pointer::startLifetime ( ) const
inline

Start the lifetime of this pointer.

This works for pointer with an InlineDescriptor as well as primitive array elements. Pointers are usually alive by default, unless the underlying object has been allocated with std::allocator. This function is used by std::construct_at.

Definition at line 1260 of file Pointer.h.

References setLifeState(), and clang::interp::Started.

◆ stripBaseCasts()

Pointer clang::interp::Pointer::stripBaseCasts ( ) const
inlinenodiscard

Strip base casts from this Pointer.

The result is either a root pointer or something that isn't a base class anymore.

Definition at line 1275 of file Pointer.h.

References Pointer(), Pointer, stripBaseCasts(), and view().

Referenced by clang::interp::CallVirt(), clang::interp::interp__builtin_memcpy(), and stripBaseCasts().

◆ toAPValue()

APValue Pointer::toAPValue ( const ASTContext & ASTCtx) const

Converts the pointer to an APValue.

Definition at line 253 of file Pointer.cpp.

References clang::APValue, clang::interp::PointerPathEntry::Array, clang::APValue::LValuePathEntry::ArrayIndex(), clang::interp::Descriptor::asDecl(), clang::interp::Descriptor::asExpr(), asFunctionPointer(), asIntPointer(), clang::interp::Descriptor::asValueDecl(), clang::interp::PointerPathEntry::Base, clang::interp::Block, block(), clang::cast(), elemSize(), clang::interp::PointerPathEntry::Field, clang::interp::Fn, clang::CharUnits::fromQuantity(), clang::interp::FunctionPointer::Func, clang::Type::getAsRecordDecl(), clang::ASTContext::getASTRecordLayout(), clang::ASTRecordLayout::getBaseClassOffset(), clang::interp::Descriptor::getDataType(), clang::interp::Function::getDecl(), clang::interp::Record::getDecl(), getDeclDesc(), getDeclPtr(), clang::RecordDecl::getDefinition(), clang::APValue::LValueBase::getDynamicAlloc(), clang::interp::Descriptor::getElemQualType(), clang::interp::Function::getExpr(), getFieldDesc(), clang::ASTRecordLayout::getFieldOffset(), getFieldOffset(), clang::CharUnits::getQuantity(), clang::APValue::LValueBase::getTypeInfo(), clang::ASTContext::getTypeSizeInChars(), clang::ASTRecordLayout::getVBaseClassOffset(), clang::ASTContext::hasLayout(), clang::interp::Int, isBlockPointer(), isConstexprUnknown(), isDynamic(), isOnePastEnd(), isZero(), isZeroSizeArray(), clang::interp::PointerPathEntry::NegativeArray, Opaque, clang::interp::Opaque, clang::Result, Str, clang::interp::String, clang::ASTContext::toCharUnitsFromBits(), Typeid, clang::interp::Typeid, validType(), view(), and clang::CharUnits::Zero().

Referenced by toDiagnosticString(), and toRValue().

◆ toDiagnosticString()

◆ toRValue()

◆ view()

◆ Block

friend class Block
friend

Definition at line 1325 of file Pointer.h.

References Block.

Referenced by Block, block(), operator=(), operator=(), Pointer(), Pointer(), Pointer(), print(), and ~Pointer().

◆ DeadBlock

friend class DeadBlock
friend

Definition at line 1326 of file Pointer.h.

References DeadBlock.

Referenced by DeadBlock.

◆ DynamicAllocator

friend class DynamicAllocator
friend

Definition at line 1329 of file Pointer.h.

References DynamicAllocator.

Referenced by DynamicAllocator.

◆ InterpState

friend class InterpState
friend

Definition at line 1328 of file Pointer.h.

References InterpState.

Referenced by InterpState.

◆ MemberPointer

friend class MemberPointer
friend

Definition at line 1327 of file Pointer.h.

References MemberPointer.

Referenced by MemberPointer.

◆ Program

friend class Program
friend

Definition at line 1330 of file Pointer.h.

References BS, and Program.

Referenced by Program.

Member Data Documentation

◆ BS

◆ Fn

◆ Int

◆ Opaque

◆ Str

◆ Typeid

TypeidPointer clang::interp::Pointer::Typeid

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