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.
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 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->data() + Pointer.Offset.

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

Definition at line 548 of file Pointer.h.

Constructor & Destructor Documentation

◆ Pointer() [1/15]

◆ Pointer() [2/15]

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

Definition at line 551 of file Pointer.h.

References Int.

◆ Pointer() [3/15]

Pointer::Pointer ( Block * B)

Definition at line 37 of file Pointer.cpp.

References Block, and Pointer().

◆ Pointer() [4/15]

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

Definition at line 39 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 557 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 561 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 563 of file Pointer.h.

References Typeid.

◆ Pointer() [10/15]

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

Definition at line 568 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 570 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 580 of file Pointer.h.

References Opaque.

◆ Pointer() [14/15]

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

Definition at line 42 of file Pointer.cpp.

References Block, and BS.

◆ Pointer() [15/15]

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

Definition at line 584 of file Pointer.h.

References Pointer(), and V.

◆ ~Pointer()

Pointer::~Pointer ( )

Definition at line 102 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 1251 of file Pointer.h.

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

◆ allElementsAlive()

◆ allElementsInitialized()

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

Definition at line 1242 of file Pointer.h.

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

◆ asBlockPointer()

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

Definition at line 849 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 857 of file Pointer.h.

References Fn, and isFunctionPointer().

Referenced by toAPValue().

◆ asIntPointer()

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

Definition at line 853 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 869 of file Pointer.h.

References isOpaquePointer(), and Opaque.

Referenced by inArray(), isArrayRoot(), and clang::interp::PtrPtrCast().

◆ asStringPointer()

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

◆ asTypeidPointer()

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

Definition at line 861 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 633 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 639 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()

◆ 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 1291 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 605 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 524 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 1257 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 1148 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 758 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 1002 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 1275 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 653 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 715 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 713 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 993 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 690 of file Pointer.h.

References BS, and clang::isBlockPointer().

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

◆ getDeclID()

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

Returns the declaration ID.

Definition at line 984 of file Pointer.h.

References BS, and clang::isBlockPointer().

◆ getDeclLoc()

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

Definition at line 698 of file Pointer.h.

References getDeclDesc().

◆ getDeclPtr()

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

Definition at line 755 of file Pointer.h.

References BS, Pointer(), and Pointer.

◆ getElemRecord()

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

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

Definition at line 888 of file Pointer.h.

References view().

◆ getField()

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

Returns the field information.

Definition at line 890 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 1261 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 775 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 1319 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 1021 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 882 of file Pointer.h.

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

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

◆ getRootExpr()

◆ getRootValueDecl()

const ValueDecl * Pointer::getRootValueDecl ( ) const

◆ getRootVarDecl()

const VarDecl * Pointer::getRootVarDecl ( ) const

Definition at line 1312 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 769 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 701 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 797 of file Pointer.h.

References asOpaquePointer(), clang::interp::Block, clang::interp::Opaque, clang::interp::String, 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 1220 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 818 of file Pointer.h.

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

◆ inUnion()

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

Definition at line 811 of file Pointer.h.

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

◆ isActive()

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

Checks if the object is active.

Definition at line 953 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 832 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 782 of file Pointer.h.

References asOpaquePointer(), clang::interp::Block, clang::interp::Opaque, clang::interp::String, and 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 959 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 966 of file Pointer.h.

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

◆ isConstexprUnknown()

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

◆ 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 1196 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 918 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 1236 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 1073 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 897 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 682 of file Pointer.h.

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

◆ isFunctionPointer()

◆ isInitialized()

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

Checks if an object was initialized.

Definition at line 1228 of file Pointer.h.

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

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

◆ 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 676 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 929 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 1063 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

Pointer points directly to a block.

Definition at line 839 of file Pointer.h.

References clang::isBlockPointer(), isOpaquePointer(), isZero(), Opaque, and view().

Referenced by computeSplitPoint(), getFieldDesc(), pointsToLastObject(), and print().

◆ isStatic()

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

Checks if the storage is static.

Definition at line 903 of file Pointer.h.

References BS, and clang::isBlockPointer().

Referenced by isStaticTemporary().

◆ isStaticTemporary()

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

Checks if the storage is a static temporary.

Definition at line 926 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 910 of file Pointer.h.

References BS, and clang::isBlockPointer().

Referenced by isStaticTemporary().

◆ isTypeidPointer()

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

Definition at line 877 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 960 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 977 of file Pointer.h.

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

◆ isWeak()

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

Definition at line 935 of file Pointer.h.

References clang::interp::Block, BS, Fn, clang::interp::Fn, Opaque, and clang::interp::Opaque.

◆ isZero()

◆ isZeroSizeArray()

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

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

Definition at line 1076 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 646 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 591 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 1055 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 1044 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 996 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 1277 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 1271 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 1286 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 249 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(), clang::RecordDecl::getDefinition(), clang::interp::Descriptor::getDynAllocKind(), clang::APValue::LValueBase::getDynamicAlloc(), clang::interp::Descriptor::getElemQualType(), clang::interp::Function::getExpr(), 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 1336 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 1337 of file Pointer.h.

References DeadBlock.

Referenced by DeadBlock.

◆ DynamicAllocator

friend class DynamicAllocator
friend

Definition at line 1340 of file Pointer.h.

References DynamicAllocator.

Referenced by DynamicAllocator.

◆ InterpState

friend class InterpState
friend

Definition at line 1339 of file Pointer.h.

References InterpState.

Referenced by InterpState.

◆ MemberPointer

friend class MemberPointer
friend

Definition at line 1338 of file Pointer.h.

References MemberPointer.

Referenced by MemberPointer.

◆ Program

friend class Program
friend

Definition at line 1341 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: