clang 17.0.0git
|
A pointer to a memory block, live or dead. More...
#include "/home/buildbot/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/AST/Interp/Pointer.h"
Public Member Functions | |
Pointer () | |
Pointer (Block *B) | |
Pointer (Block *B, unsigned BaseAndOffset) | |
Pointer (const Pointer &P) | |
Pointer (Pointer &&P) | |
~Pointer () | |
void | operator= (const Pointer &P) |
void | operator= (Pointer &&P) |
APValue | toAPValue () const |
Converts the pointer to an APValue. | |
Pointer | atIndex (unsigned Idx) const |
Offsets a pointer inside an array. | |
Pointer | atField (unsigned Off) const |
Creates a pointer to a field. | |
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. | |
Descriptor * | getDeclDesc () const |
Accessor for information about the declaration site. | |
SourceLocation | getDeclLoc () const |
Pointer | getBase () const |
Returns a pointer to the object of which this pointer is a field. | |
Pointer | getArray () const |
Returns the parent array. | |
Descriptor * | getFieldDesc () const |
Accessors for information about the innermost field. | |
QualType | getType () const |
Returns the type of the innermost field. | |
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 | 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. | |
Record * | getRecord () const |
Returns the record descriptor of a class. | |
Record * | getElemRecord () const |
const FieldDecl * | getField () const |
Returns the field information. | |
bool | isUnion () const |
Checks if the object is a union. | |
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 | isStaticTemporary () const |
Checks if the storage is a static temporary. | |
bool | isMutable () const |
Checks if the field is mutable. | |
bool | isInitialized () const |
Checks if an object was initialized. | |
bool | isActive () const |
Checks if the object is active. | |
bool | isBaseClass () const |
Checks if a structure is a base class. | |
bool | isConst () const |
Checks if an object or a subfield is mutable. | |
std::optional< unsigned > | getDeclID () const |
Returns the declaration ID. | |
unsigned | getByteOffset () const |
Returns the byte offset from the start. | |
unsigned | getNumElems () const |
Returns the number of elements. | |
Block * | block () const |
int64_t | getIndex () const |
Returns the index into an array. | |
bool | isOnePastEnd () const |
Checks if the index is one past end. | |
bool | isElementPastEnd () const |
Checks if the pointer is an out-of-bounds element pointer. | |
template<typename T > | |
T & | deref () const |
Dereferences the pointer, if it's live. | |
template<typename T > | |
T & | elem (unsigned I) const |
Dereferences a primitive element. | |
void | initialize () const |
Initializes a field. | |
void | activate () const |
Activats a field. | |
void | deactivate () const |
Deactivates an entire strurcutre. | |
void | print (llvm::raw_ostream &OS) const |
Prints the pointer. | |
Static Public Member Functions | |
static bool | hasSameBase (const Pointer &A, const Pointer &B) |
Checks if two pointers are comparable. | |
static bool | hasSameArray (const Pointer &A, const Pointer &B) |
Checks if two pointers can be subtracted. | |
Friends | |
class | Block |
class | DeadBlock |
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
|
inline |
Pointer::Pointer | ( | Block * | B | ) |
Definition at line 17 of file Pointer.cpp.
Definition at line 19 of file Pointer.cpp.
Pointer::Pointer | ( | const Pointer & | P | ) |
Definition at line 22 of file Pointer.cpp.
Pointer::Pointer | ( | Pointer && | P | ) |
Definition at line 24 of file Pointer.cpp.
References clang::interp::Block::movePointer(), and P.
Pointer::~Pointer | ( | ) |
Definition at line 37 of file Pointer.cpp.
References clang::interp::Block::cleanup(), and clang::interp::Block::removePointer().
void Pointer::activate | ( | ) | const |
Activats a field.
Definition at line 195 of file Pointer.cpp.
References clang::interp::InlineDescriptor::IsActive.
Creates a pointer to a field.
Definition at line 93 of file Pointer.h.
References Pointer().
Referenced by clang::interp::CheckFieldsInitialized(), clang::interp::GetField(), clang::interp::GetFieldPop(), clang::interp::GetPtrActiveField(), clang::interp::GetPtrBase(), clang::interp::GetPtrBasePop(), and clang::interp::GetPtrField().
Offsets a pointer inside an array.
Definition at line 81 of file Pointer.h.
References elemSize(), getDeclDesc(), getFieldDesc(), getSize(), and Pointer().
Referenced by clang::interp::CheckArrayInitialized(), clang::interp::CmpHelperEQ< Pointer >(), clang::interp::Program::createGlobalString(), and clang::interp::OffsetHelper().
|
inline |
Definition at line 293 of file Pointer.h.
Referenced by clang::interp::CheckConst(), and clang::interp::CheckFieldsInitialized().
void Pointer::deactivate | ( | ) | const |
Deactivates an entire strurcutre.
Definition at line 201 of file Pointer.cpp.
Referenced by clang::interp::GetPtrActiveField().
|
inline |
Dereferences the pointer, if it's live.
Definition at line 313 of file Pointer.h.
References isArrayRoot(), isLive(), and clang::interp::Block::rawData().
Referenced by clang::interp::GetLocal(), clang::interp::InterpFrame::getParam(), clang::interp::IncDecHelper(), clang::interp::IncDecPtrHelper(), clang::interp::Load(), clang::interp::LoadPop(), and clang::interp::InterpFrame::setParam().
|
inline |
Dereferences a primitive element.
Definition at line 323 of file Pointer.h.
References clang::interp::Block::rawData().
|
inline |
Returns the element size of the innermost field.
Definition at line 204 of file Pointer.h.
References getDeclDesc(), clang::interp::Descriptor::getElemSize(), getFieldDesc(), and clang::interp::Descriptor::getSize().
Referenced by atIndex(), getIndex(), and getNumElems().
|
inline |
Expands a pointer to the containing array, undoing narrowing.
Definition at line 135 of file Pointer.h.
References clang::interp::InlineDescriptor::Desc, getDeclDesc(), getSize(), inPrimitiveArray(), clang::interp::Descriptor::IsArray, isElementPastEnd(), clang::interp::InlineDescriptor::Offset, and Pointer().
Referenced by clang::interp::ExpandPtr().
|
inline |
Returns the parent array.
Definition at line 184 of file Pointer.h.
References Pointer().
Referenced by toAPValue().
|
inline |
Returns a pointer to the object of which this pointer is a field.
Definition at line 174 of file Pointer.h.
References clang::interp::InlineDescriptor::Offset, and Pointer().
Referenced by CheckActive(), and toAPValue().
|
inline |
Returns the byte offset from the start.
Definition at line 286 of file Pointer.h.
Referenced by clang::interp::CmpHelper< Pointer >(), and clang::interp::CmpHelperEQ< Pointer >().
|
inline |
Accessor for information about the declaration site.
Definition at line 170 of file Pointer.h.
References clang::interp::Block::Desc.
Referenced by atIndex(), clang::interp::CheckExtern(), CheckTemporary(), elemSize(), expand(), getDeclLoc(), getFieldDesc(), isConst(), and toAPValue().
|
inline |
Returns the declaration ID.
Definition at line 283 of file Pointer.h.
References clang::interp::Block::getDeclID().
Referenced by CheckGlobal(), and CheckTemporary().
|
inline |
Definition at line 171 of file Pointer.h.
References getDeclDesc(), and clang::interp::Descriptor::getLocation().
Referenced by clang::interp::CheckLive(), and CheckTemporary().
|
inline |
Definition at line 250 of file Pointer.h.
References clang::interp::Descriptor::ElemDesc, clang::interp::Descriptor::ElemRecord, and getFieldDesc().
Referenced by clang::interp::CheckArrayInitialized().
|
inline |
Returns the field information.
Definition at line 252 of file Pointer.h.
References clang::interp::Descriptor::asFieldDecl(), and getFieldDesc().
Referenced by CheckActive(), and clang::interp::CheckMutable().
|
inline |
Accessors for information about the innermost field.
Definition at line 194 of file Pointer.h.
References clang::interp::InlineDescriptor::Desc, and getDeclDesc().
Referenced by atIndex(), clang::interp::CheckArrayInitialized(), elemSize(), getElemRecord(), getField(), getOffset(), getRecord(), getSize(), getType(), hasSameArray(), inArray(), initialize(), inPrimitiveArray(), isInitialized(), isUnknownSizeArray(), narrow(), and toAPValue().
|
inline |
Returns the index into an array.
Definition at line 296 of file Pointer.h.
References elemSize(), getOffset(), and isElementPastEnd().
Referenced by initialize(), isInitialized(), clang::interp::OffsetHelper(), clang::interp::SubPtr(), and toAPValue().
|
inline |
Returns the number of elements.
Definition at line 291 of file Pointer.h.
References elemSize(), and getSize().
Referenced by clang::interp::OffsetHelper().
|
inline |
Returns the offset into an array.
Definition at line 213 of file Pointer.h.
References getFieldDesc().
Referenced by getIndex(), and isOnePastEnd().
|
inline |
Returns the record descriptor of a class.
Definition at line 248 of file Pointer.h.
References clang::interp::Descriptor::ElemRecord, and getFieldDesc().
Referenced by clang::interp::CheckFieldsInitialized().
|
inline |
Returns the total size of the innermost field.
Definition at line 210 of file Pointer.h.
References getFieldDesc(), and clang::interp::Descriptor::getSize().
Referenced by atIndex(), expand(), getNumElems(), and isOnePastEnd().
|
inline |
Returns the type of the innermost field.
Definition at line 201 of file Pointer.h.
References getFieldDesc(), and clang::interp::Descriptor::getType().
Referenced by clang::interp::CheckConst().
Checks if two pointers can be subtracted.
Definition at line 209 of file Pointer.cpp.
References getFieldDesc(), hasSameBase(), and clang::interp::Descriptor::IsArray.
Referenced by clang::interp::SubPtr().
Checks if two pointers are comparable.
Definition at line 205 of file Pointer.cpp.
Referenced by clang::interp::CmpHelper< Pointer >(), clang::interp::CmpHelperEQ< Pointer >(), and hasSameArray().
|
inline |
Checks if the innermost field is an array.
Definition at line 233 of file Pointer.h.
References getFieldDesc(), and clang::interp::Descriptor::IsArray.
Referenced by clang::interp::CmpHelperEQ< Pointer >(), isArrayRoot(), and clang::interp::OffsetHelper().
void Pointer::initialize | ( | ) | const |
Initializes a field.
Definition at line 168 of file Pointer.cpp.
References clang::interp::InitMap::allocate(), getFieldDesc(), getIndex(), clang::interp::Descriptor::getNumElems(), clang::interp::InitMap::initialize(), clang::interp::InlineDescriptor::IsInitialized, clang::interp::Descriptor::isPrimitiveArray(), and isStatic().
Referenced by clang::interp::InitPop(), clang::interp::Store(), clang::interp::StoreBitField(), clang::interp::StoreBitFieldPop(), and clang::interp::StorePop().
|
inline |
Checks if the structure is a primitive array.
Definition at line 235 of file Pointer.h.
References getFieldDesc(), and clang::interp::Descriptor::isPrimitiveArray().
|
inline |
Checks if the object is active.
Definition at line 273 of file Pointer.h.
References clang::interp::InlineDescriptor::IsActive.
Referenced by CheckActive().
|
inline |
Checks if the pointer points to an array.
Definition at line 241 of file Pointer.h.
Referenced by toAPValue().
|
inline |
|
inline |
Checks if a structure is a base class.
Definition at line 275 of file Pointer.h.
References clang::interp::InlineDescriptor::IsBase, and isField().
|
inline |
Checks if an object or a subfield is mutable.
Definition at line 278 of file Pointer.h.
References getDeclDesc(), clang::interp::InlineDescriptor::IsConst, and clang::interp::Descriptor::IsConst.
Referenced by clang::interp::CheckConst().
|
inline |
Checks if the pointer is an out-of-bounds element pointer.
Definition at line 310 of file Pointer.h.
Referenced by clang::interp::CheckRange(), expand(), getIndex(), and isOnePastEnd().
|
inline |
Checks if the storage is extern.
Definition at line 258 of file Pointer.h.
References clang::interp::Block::isExtern().
Referenced by clang::interp::CheckExtern().
|
inline |
Checks if the item is a field in an object.
Definition at line 167 of file Pointer.h.
Referenced by clang::interp::CheckLive(), isBaseClass(), and toAPValue().
bool Pointer::isInitialized | ( | ) | const |
Checks if an object was initialized.
Definition at line 148 of file Pointer.cpp.
References getFieldDesc(), getIndex(), clang::interp::InlineDescriptor::IsInitialized, clang::interp::InitMap::isInitialized(), clang::interp::Descriptor::isPrimitiveArray(), and isStatic().
Referenced by clang::interp::CheckArrayInitialized(), clang::interp::CheckFieldsInitialized(), and CheckInitialized().
|
inline |
Checks if the pointer is live.
Definition at line 165 of file Pointer.h.
References clang::interp::Block::IsDead.
Referenced by clang::interp::CheckConst(), clang::interp::CheckLive(), clang::interp::CheckMutable(), and deref().
|
inline |
Checks if the field is mutable.
Definition at line 267 of file Pointer.h.
References clang::interp::InlineDescriptor::IsFieldMutable.
Referenced by clang::interp::CheckMutable().
|
inline |
Checks if the index is one past end.
Definition at line 305 of file Pointer.h.
References getOffset(), getSize(), and isElementPastEnd().
Referenced by clang::interp::CheckRange(), narrow(), and toAPValue().
|
inline |
Pointer points directly to a block.
Definition at line 243 of file Pointer.h.
Referenced by clang::interp::CmpHelperEQ< Pointer >().
|
inline |
Checks if the storage is static.
Definition at line 260 of file Pointer.h.
References clang::interp::Block::isStatic().
Referenced by CheckGlobal(), initialize(), isInitialized(), and isStaticTemporary().
|
inline |
Checks if the storage is a static temporary.
Definition at line 264 of file Pointer.h.
References isStatic(), and isTemporary().
Referenced by CheckTemporary().
|
inline |
Checks if the storage is temporary.
Definition at line 262 of file Pointer.h.
References clang::interp::Block::isTemporary().
Referenced by clang::interp::CheckLive(), and isStaticTemporary().
bool clang::interp::Pointer::isUnion | ( | ) | const |
Checks if the object is a union.
|
inline |
Checks if the structure is an array of unknown size.
Definition at line 237 of file Pointer.h.
References getFieldDesc(), and clang::interp::Descriptor::isUnknownSizeArray().
Referenced by clang::interp::CheckArray(), narrow(), and toAPValue().
|
inline |
Checks if the pointer is null.
Definition at line 163 of file Pointer.h.
Referenced by clang::interp::CheckLive(), clang::interp::CheckNull(), clang::interp::CmpHelperEQ< Pointer >(), narrow(), and toAPValue().
|
inline |
Restricts the scope of an array element pointer.
Definition at line 99 of file Pointer.h.
References getFieldDesc(), inPrimitiveArray(), isOnePastEnd(), isUnknownSizeArray(), isZero(), and Pointer().
Referenced by clang::interp::CheckArrayInitialized(), clang::interp::Program::createGlobalString(), and clang::interp::NarrowPtr().
void Pointer::operator= | ( | const Pointer & | P | ) |
Definition at line 44 of file Pointer.cpp.
References clang::interp::Block::addPointer(), clang::interp::Block::cleanup(), Offset, P, and clang::interp::Block::removePointer().
void Pointer::operator= | ( | Pointer && | P | ) |
Definition at line 61 of file Pointer.cpp.
References clang::interp::Block::cleanup(), clang::interp::Block::movePointer(), Offset, P, and clang::interp::Block::removePointer().
|
inline |
Prints the pointer.
Definition at line 340 of file Pointer.h.
References clang::interp::Block::getSize(), and OS.
APValue Pointer::toAPValue | ( | ) | const |
Converts the pointer to an APValue.
Definition at line 78 of file Pointer.cpp.
References clang::APValue::LValuePathEntry::ArrayIndex(), clang::interp::Descriptor::asDecl(), clang::interp::Descriptor::asExpr(), clang::interp::Descriptor::asValueDecl(), getArray(), getBase(), getDeclDesc(), getFieldDesc(), getIndex(), isArrayElement(), isField(), isOnePastEnd(), isUnknownSizeArray(), isZero(), Offset, and clang::CharUnits::Zero().