clang  10.0.0svn
Public Member Functions | Static Public Member Functions | Friends | List of all members
clang::interp::Pointer Class Reference

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

#include "/opt/doxygen-docs/src/llvm/tools/clang/lib/AST/Interp/Pointer.h"

Public Member Functions

 Pointer ()
 
 Pointer (Block *B)
 
 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. More...
 
Pointer atIndex (unsigned Idx) const
 Offsets a pointer inside an array. More...
 
Pointer atField (unsigned Off) const
 Creates a pointer to a field. More...
 
Pointer narrow () const
 Restricts the scope of an array element pointer. More...
 
Pointer expand () const
 Expands a pointer to the containing array, undoing narrowing. More...
 
bool isZero () const
 Checks if the pointer is null. More...
 
bool isLive () const
 Checks if the pointer is live. More...
 
bool isField () const
 Checks if the item is a field in an object. More...
 
DescriptorgetDeclDesc () const
 Accessor for information about the declaration site. More...
 
SourceLocation getDeclLoc () const
 
Pointer getBase () const
 Returns a pointer to the object of which this pointer is a field. More...
 
Pointer getArray () const
 Returns the parent array. More...
 
DescriptorgetFieldDesc () const
 Accessors for information about the innermost field. More...
 
QualType getType () const
 Returns the type of the innermost field. More...
 
size_t elemSize () const
 Returns the element size of the innermost field. More...
 
size_t getSize () const
 Returns the total size of the innermost field. More...
 
unsigned getOffset () const
 Returns the offset into an array. More...
 
bool inArray () const
 Checks if the innermost field is an array. More...
 
bool inPrimitiveArray () const
 Checks if the structure is a primitive array. More...
 
bool isUnknownSizeArray () const
 Checks if the structure is an array of unknown size. More...
 
bool isArrayElement () const
 Checks if the pointer points to an array. More...
 
bool isRoot () const
 Pointer points directly to a block. More...
 
RecordgetRecord () const
 Returns the record descriptor of a class. More...
 
const FieldDeclgetField () const
 Returns the field information. More...
 
bool isUnion () const
 Checks if the object is a union. More...
 
bool isExtern () const
 Checks if the storage is extern. More...
 
bool isStatic () const
 Checks if the storage is static. More...
 
bool isTemporary () const
 Checks if the storage is temporary. More...
 
bool isStaticTemporary () const
 Checks if the storage is a static temporary. More...
 
bool isMutable () const
 Checks if the field is mutable. More...
 
bool isInitialized () const
 Checks if an object was initialized. More...
 
bool isActive () const
 Checks if the object is active. More...
 
bool isBaseClass () const
 Checks if a structure is a base class. More...
 
bool isConst () const
 Checks if an object or a subfield is mutable. More...
 
llvm::Optional< unsigned > getDeclID () const
 Returns the declaration ID. More...
 
unsigned getByteOffset () const
 Returns the byte offset from the start. More...
 
unsigned getNumElems () const
 Returns the number of elements. More...
 
int64_t getIndex () const
 Returns the index into an array. More...
 
bool isOnePastEnd () const
 Checks if the index is one past end. More...
 
bool isElementPastEnd () const
 Checks if the pointer is an out-of-bounds element pointer. More...
 
template<typename T >
T & deref () const
 Dereferences the pointer, if it's live. More...
 
template<typename T >
T & elem (unsigned I) const
 Dereferences a primitive element. More...
 
void initialize () const
 Initializes a field. More...
 
void activate () const
 Activats a field. More...
 
void deactivate () const
 Deactivates an entire strurcutre. More...
 
void print (llvm::raw_ostream &OS) const
 Prints the pointer. More...
 

Static Public Member Functions

static bool hasSameBase (const Pointer &A, const Pointer &B)
 Checks if two pointers are comparable. More...
 
static bool hasSameArray (const Pointer &A, const Pointer &B)
 Checks if two pointers can be subtracted. More...
 

Friends

class Block
 
class DeadBlock
 

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.

Definition at line 39 of file Pointer.h.

Constructor & Destructor Documentation

◆ Pointer() [1/4]

clang::interp::Pointer::Pointer ( )
inline

Definition at line 45 of file Pointer.h.

References operator=(), P, toAPValue(), and ~Pointer().

Referenced by atField(), atIndex(), expand(), getArray(), getBase(), narrow(), and Pointer().

◆ Pointer() [2/4]

Pointer::Pointer ( Block B)

Definition at line 17 of file Pointer.cpp.

◆ Pointer() [3/4]

Pointer::Pointer ( const Pointer P)

Definition at line 19 of file Pointer.cpp.

◆ Pointer() [4/4]

Pointer::Pointer ( Pointer &&  P)

◆ ~Pointer()

Pointer::~Pointer ( )

Definition at line 34 of file Pointer.cpp.

References clang::interp::Block::cleanup(), and clang::interp::Block::removePointer().

Referenced by Pointer().

Member Function Documentation

◆ activate()

void Pointer::activate ( ) const

◆ atField()

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

◆ atIndex()

Pointer clang::interp::Pointer::atIndex ( unsigned  Idx) const
inline

Offsets a pointer inside an array.

Definition at line 58 of file Pointer.h.

References elemSize(), getDeclDesc(), getFieldDesc(), getSize(), and Pointer().

Referenced by clang::interp::EvalEmitter::fallthrough().

◆ deactivate()

void Pointer::deactivate ( ) const

Deactivates an entire strurcutre.

Definition at line 183 of file Pointer.cpp.

Referenced by elem(), clang::interp::GetPtrActiveField(), and clang::interp::GetPtrActiveThisField().

◆ 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 a primitive element.

Definition at line 286 of file Pointer.h.

References activate(), clang::interp::Block::data(), deactivate(), hasSameArray(), hasSameBase(), and initialize().

◆ elemSize()

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

Returns the element size of the innermost field.

Definition at line 181 of file Pointer.h.

References getDeclDesc(), clang::interp::Descriptor::getElemSize(), getFieldDesc(), and clang::interp::Descriptor::getSize().

Referenced by atIndex(), getIndex(), and getNumElems().

◆ expand()

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

◆ getArray()

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

Returns the parent array.

Definition at line 161 of file Pointer.h.

References Pointer().

Referenced by toAPValue().

◆ getBase()

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

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

Definition at line 151 of file Pointer.h.

References clang::interp::InlineDescriptor::Offset, and Pointer().

Referenced by toAPValue(), and clang::interp::VirtBaseHelper().

◆ getByteOffset()

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

Returns the byte offset from the start.

Definition at line 255 of file Pointer.h.

◆ getDeclDesc()

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

Accessor for information about the declaration site.

Definition at line 147 of file Pointer.h.

References clang::interp::Block::Desc.

Referenced by atIndex(), elemSize(), expand(), getDeclLoc(), getFieldDesc(), isConst(), print(), and toAPValue().

◆ getDeclID()

llvm::Optional<unsigned> clang::interp::Pointer::getDeclID ( ) const
inline

Returns the declaration ID.

Definition at line 252 of file Pointer.h.

References clang::interp::Block::getDeclID().

◆ getDeclLoc()

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

Definition at line 148 of file Pointer.h.

References getDeclDesc(), and clang::interp::Descriptor::getLocation().

◆ getField()

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

Returns the field information.

Definition at line 223 of file Pointer.h.

References clang::interp::Descriptor::asFieldDecl(), getFieldDesc(), and isUnion().

◆ getFieldDesc()

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

◆ getIndex()

int64_t clang::interp::Pointer::getIndex ( ) const
inline

Returns the index into an array.

Definition at line 263 of file Pointer.h.

References elemSize(), getOffset(), and isElementPastEnd().

Referenced by initialize(), isInitialized(), and toAPValue().

◆ getNumElems()

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

Returns the number of elements.

Definition at line 260 of file Pointer.h.

References elemSize(), and getSize().

Referenced by clang::interp::EvalEmitter::fallthrough().

◆ getOffset()

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

Returns the offset into an array.

Definition at line 190 of file Pointer.h.

References getFieldDesc().

Referenced by getIndex(), and isOnePastEnd().

◆ getRecord()

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

Returns the record descriptor of a class.

Definition at line 221 of file Pointer.h.

References clang::interp::Descriptor::ElemRecord, and getFieldDesc().

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

◆ getSize()

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

Returns the total size of the innermost field.

Definition at line 187 of file Pointer.h.

References getFieldDesc(), and clang::interp::Descriptor::getSize().

Referenced by atIndex(), expand(), getNumElems(), and isOnePastEnd().

◆ getType()

QualType clang::interp::Pointer::getType ( ) const
inline

Returns the type of the innermost field.

Definition at line 178 of file Pointer.h.

References getFieldDesc(), and clang::interp::Descriptor::getType().

◆ hasSameArray()

bool Pointer::hasSameArray ( const Pointer A,
const Pointer B 
)
static

Checks if two pointers can be subtracted.

Definition at line 191 of file Pointer.cpp.

References getFieldDesc(), and clang::interp::Descriptor::IsArray.

Referenced by elem().

◆ hasSameBase()

bool Pointer::hasSameBase ( const Pointer A,
const Pointer B 
)
static

Checks if two pointers are comparable.

Definition at line 187 of file Pointer.cpp.

Referenced by elem().

◆ inArray()

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

Checks if the innermost field is an array.

Definition at line 206 of file Pointer.h.

References getFieldDesc(), and clang::interp::Descriptor::IsArray.

◆ initialize()

void Pointer::initialize ( ) const

◆ inPrimitiveArray()

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

Checks if the structure is a primitive array.

Definition at line 208 of file Pointer.h.

References getFieldDesc(), and clang::interp::Descriptor::isPrimitiveArray().

Referenced by expand(), and narrow().

◆ isActive()

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

Checks if the object is active.

Definition at line 242 of file Pointer.h.

References clang::interp::InlineDescriptor::IsActive.

Referenced by clang::interp::EvalEmitter::fallthrough().

◆ isArrayElement()

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

Checks if the pointer points to an array.

Definition at line 214 of file Pointer.h.

Referenced by toAPValue().

◆ isBaseClass()

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

Checks if a structure is a base class.

Definition at line 244 of file Pointer.h.

References clang::interp::InlineDescriptor::IsBase, and isField().

Referenced by clang::interp::VirtBaseHelper(), and clang::interp::InterpFrame::~InterpFrame().

◆ isConst()

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

Checks if an object or a subfield is mutable.

Definition at line 247 of file Pointer.h.

References getDeclDesc(), clang::interp::Descriptor::IsConst, and clang::interp::InlineDescriptor::IsConst.

◆ isElementPastEnd()

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

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

Definition at line 277 of file Pointer.h.

Referenced by expand(), getIndex(), and isOnePastEnd().

◆ isExtern()

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

Checks if the storage is extern.

Definition at line 229 of file Pointer.h.

References clang::interp::Block::isExtern().

◆ isField()

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

Checks if the item is a field in an object.

Definition at line 144 of file Pointer.h.

Referenced by isBaseClass(), and toAPValue().

◆ isInitialized()

bool Pointer::isInitialized ( ) const

◆ isLive()

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

Checks if the pointer is live.

Definition at line 142 of file Pointer.h.

References clang::interp::Block::IsDead.

Referenced by deref().

◆ isMutable()

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

Checks if the field is mutable.

Definition at line 238 of file Pointer.h.

References isInitialized(), and clang::interp::InlineDescriptor::IsMutable.

◆ isOnePastEnd()

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

Checks if the index is one past end.

Definition at line 272 of file Pointer.h.

References getOffset(), getSize(), and isElementPastEnd().

Referenced by narrow(), and toAPValue().

◆ isRoot()

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

Pointer points directly to a block.

Definition at line 216 of file Pointer.h.

Referenced by print().

◆ isStatic()

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

Checks if the storage is static.

Definition at line 231 of file Pointer.h.

References clang::interp::Block::isStatic().

Referenced by isStaticTemporary().

◆ isStaticTemporary()

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

Checks if the storage is a static temporary.

Definition at line 235 of file Pointer.h.

References isStatic(), and isTemporary().

◆ isTemporary()

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

Checks if the storage is temporary.

Definition at line 233 of file Pointer.h.

References clang::interp::Block::isTemporary().

Referenced by isStaticTemporary().

◆ isUnion()

bool clang::interp::Pointer::isUnion ( ) const

Checks if the object is a union.

Referenced by getField().

◆ isUnknownSizeArray()

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

Checks if the structure is an array of unknown size.

Definition at line 210 of file Pointer.h.

References getFieldDesc(), and clang::interp::Descriptor::isUnknownSizeArray().

Referenced by narrow(), and toAPValue().

◆ isZero()

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

Checks if the pointer is null.

Definition at line 140 of file Pointer.h.

Referenced by narrow(), print(), and toAPValue().

◆ narrow()

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

Restricts the scope of an array element pointer.

Definition at line 76 of file Pointer.h.

References getFieldDesc(), inPrimitiveArray(), isOnePastEnd(), isUnknownSizeArray(), isZero(), and Pointer().

Referenced by clang::interp::EvalEmitter::fallthrough(), and clang::interp::NarrowPtr().

◆ operator=() [1/2]

void Pointer::operator= ( const Pointer P)

◆ operator=() [2/2]

void Pointer::operator= ( Pointer &&  P)

◆ print()

void clang::interp::Pointer::print ( llvm::raw_ostream &  OS) const
inline

Prints the pointer.

Definition at line 303 of file Pointer.h.

References clang::interp::Block::getSize().

Referenced by clang::interp::operator<<().

◆ toAPValue()

APValue Pointer::toAPValue ( ) const

Friends And Related Function Documentation

◆ Block

friend class Block
friend

Definition at line 313 of file Pointer.h.

◆ DeadBlock

friend class DeadBlock
friend

Definition at line 314 of file Pointer.h.


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