clang  8.0.0
Classes | Public Types | Public Member Functions | List of all members
clang::APValue Class Reference

APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat], [Complex APSInt] [Complex APFloat], [Expr + Offset], [Vector: N * APValue], [Array: N * APValue]. More...

#include "clang/AST/APValue.h"

Classes

struct  LV
 
class  LValueBase
 
union  LValuePathEntry
 
struct  MemberPointerData
 
struct  NoLValuePath
 
struct  UninitArray
 
struct  UninitStruct
 

Public Types

enum  ValueKind {
  Uninitialized, Int, Float, ComplexInt,
  ComplexFloat, LValue, Vector, Array,
  Struct, Union, MemberPointer, AddrLabelDiff
}
 
typedef llvm::PointerIntPair< const Decl *, 1, boolBaseOrMemberType
 

Public Member Functions

 APValue ()
 
 APValue (APSInt I)
 
 APValue (APFloat F)
 
 APValue (const APValue *E, unsigned N)
 
 APValue (APSInt R, APSInt I)
 
 APValue (APFloat R, APFloat I)
 
 APValue (const APValue &RHS)
 
 APValue (APValue &&RHS)
 
 APValue (LValueBase B, const CharUnits &O, NoLValuePath N, bool IsNullPtr=false)
 
 APValue (LValueBase B, const CharUnits &O, ArrayRef< LValuePathEntry > Path, bool OnePastTheEnd, bool IsNullPtr=false)
 
 APValue (UninitArray, unsigned InitElts, unsigned Size)
 
 APValue (UninitStruct, unsigned B, unsigned M)
 
 APValue (const FieldDecl *D, const APValue &V=APValue())
 
 APValue (const ValueDecl *Member, bool IsDerivedMember, ArrayRef< const CXXRecordDecl *> Path)
 
 APValue (const AddrLabelExpr *LHSExpr, const AddrLabelExpr *RHSExpr)
 
 ~APValue ()
 
bool needsCleanup () const
 Returns whether the object performed allocations. More...
 
void swap (APValue &RHS)
 Swaps the contents of this and the given APValue. More...
 
ValueKind getKind () const
 
bool isUninit () const
 
bool isInt () const
 
bool isFloat () const
 
bool isComplexInt () const
 
bool isComplexFloat () const
 
bool isLValue () const
 
bool isVector () const
 
bool isArray () const
 
bool isStruct () const
 
bool isUnion () const
 
bool isMemberPointer () const
 
bool isAddrLabelDiff () const
 
void dump () const
 
void dump (raw_ostream &OS) const
 
void printPretty (raw_ostream &OS, ASTContext &Ctx, QualType Ty) const
 
std::string getAsString (ASTContext &Ctx, QualType Ty) const
 
APSInt & getInt ()
 
const APSInt & getInt () const
 
bool toIntegralConstant (APSInt &Result, QualType SrcTy, const ASTContext &Ctx) const
 Try to convert this value to an integral constant. More...
 
APFloat & getFloat ()
 
const APFloat & getFloat () const
 
APSInt & getComplexIntReal ()
 
const APSInt & getComplexIntReal () const
 
APSInt & getComplexIntImag ()
 
const APSInt & getComplexIntImag () const
 
APFloat & getComplexFloatReal ()
 
const APFloat & getComplexFloatReal () const
 
APFloat & getComplexFloatImag ()
 
const APFloat & getComplexFloatImag () const
 
const LValueBase getLValueBase () const
 
CharUnitsgetLValueOffset ()
 
const CharUnitsgetLValueOffset () const
 
bool isLValueOnePastTheEnd () const
 
bool hasLValuePath () const
 
ArrayRef< LValuePathEntrygetLValuePath () const
 
unsigned getLValueCallIndex () const
 
unsigned getLValueVersion () const
 
bool isNullPointer () const
 
APValuegetVectorElt (unsigned I)
 
const APValuegetVectorElt (unsigned I) const
 
unsigned getVectorLength () const
 
APValuegetArrayInitializedElt (unsigned I)
 
const APValuegetArrayInitializedElt (unsigned I) const
 
bool hasArrayFiller () const
 
APValuegetArrayFiller ()
 
const APValuegetArrayFiller () const
 
unsigned getArrayInitializedElts () const
 
unsigned getArraySize () const
 
unsigned getStructNumBases () const
 
unsigned getStructNumFields () const
 
APValuegetStructBase (unsigned i)
 
APValuegetStructField (unsigned i)
 
const APValuegetStructBase (unsigned i) const
 
const APValuegetStructField (unsigned i) const
 
const FieldDeclgetUnionField () const
 
APValuegetUnionValue ()
 
const APValuegetUnionValue () const
 
const ValueDeclgetMemberPointerDecl () const
 
bool isMemberPointerToDerivedMember () const
 
ArrayRef< const CXXRecordDecl * > getMemberPointerPath () const
 
const AddrLabelExprgetAddrLabelDiffLHS () const
 
const AddrLabelExprgetAddrLabelDiffRHS () const
 
void setInt (APSInt I)
 
void setFloat (APFloat F)
 
void setVector (const APValue *E, unsigned N)
 
void setComplexInt (APSInt R, APSInt I)
 
void setComplexFloat (APFloat R, APFloat I)
 
void setLValue (LValueBase B, const CharUnits &O, NoLValuePath, bool IsNullPtr)
 
void setLValue (LValueBase B, const CharUnits &O, ArrayRef< LValuePathEntry > Path, bool OnePastTheEnd, bool IsNullPtr)
 
void setUnion (const FieldDecl *Field, const APValue &Value)
 
void setAddrLabelDiff (const AddrLabelExpr *LHSExpr, const AddrLabelExpr *RHSExpr)
 
APValueoperator= (APValue RHS)
 Assign by swapping from a copy of the RHS. More...
 

Detailed Description

APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat], [Complex APSInt] [Complex APFloat], [Expr + Offset], [Vector: N * APValue], [Array: N * APValue].

Definition at line 38 of file APValue.h.

Member Typedef Documentation

◆ BaseOrMemberType

typedef llvm::PointerIntPair<const Decl *, 1, bool> clang::APValue::BaseOrMemberType

Definition at line 108 of file APValue.h.

Member Enumeration Documentation

◆ ValueKind

Enumerator
Uninitialized 
Int 
Float 
ComplexInt 
ComplexFloat 
LValue 
Vector 
Array 
Struct 
Union 
MemberPointer 
AddrLabelDiff 

Definition at line 42 of file APValue.h.

Constructor & Destructor Documentation

◆ APValue() [1/15]

clang::APValue::APValue ( )
inline

Definition at line 171 of file APValue.h.

Referenced by APValue().

◆ APValue() [2/15]

clang::APValue::APValue ( APSInt  I)
inlineexplicit

Definition at line 172 of file APValue.h.

References setInt().

◆ APValue() [3/15]

clang::APValue::APValue ( APFloat  F)
inlineexplicit

Definition at line 175 of file APValue.h.

References setFloat().

◆ APValue() [4/15]

clang::APValue::APValue ( const APValue E,
unsigned  N 
)
inlineexplicit

Definition at line 178 of file APValue.h.

References setVector().

◆ APValue() [5/15]

clang::APValue::APValue ( APSInt  R,
APSInt  I 
)
inline

Definition at line 181 of file APValue.h.

References setComplexInt().

◆ APValue() [6/15]

clang::APValue::APValue ( APFloat  R,
APFloat  I 
)
inline

Definition at line 184 of file APValue.h.

References APValue(), and setComplexFloat().

◆ APValue() [7/15]

APValue::APValue ( const APValue RHS)

◆ APValue() [8/15]

clang::APValue::APValue ( APValue &&  RHS)
inline

Definition at line 188 of file APValue.h.

References swap().

◆ APValue() [9/15]

clang::APValue::APValue ( LValueBase  B,
const CharUnits O,
NoLValuePath  N,
bool  IsNullPtr = false 
)
inline

Definition at line 189 of file APValue.h.

References setLValue().

◆ APValue() [10/15]

clang::APValue::APValue ( LValueBase  B,
const CharUnits O,
ArrayRef< LValuePathEntry Path,
bool  OnePastTheEnd,
bool  IsNullPtr = false 
)
inline

Definition at line 194 of file APValue.h.

References setLValue().

◆ APValue() [11/15]

clang::APValue::APValue ( UninitArray  ,
unsigned  InitElts,
unsigned  Size 
)
inline

Definition at line 199 of file APValue.h.

◆ APValue() [12/15]

clang::APValue::APValue ( UninitStruct  ,
unsigned  B,
unsigned  M 
)
inline

Definition at line 202 of file APValue.h.

◆ APValue() [13/15]

clang::APValue::APValue ( const FieldDecl D,
const APValue V = APValue() 
)
inlineexplicit

Definition at line 205 of file APValue.h.

References setUnion().

◆ APValue() [14/15]

clang::APValue::APValue ( const ValueDecl Member,
bool  IsDerivedMember,
ArrayRef< const CXXRecordDecl *>  Path 
)
inline

Definition at line 209 of file APValue.h.

◆ APValue() [15/15]

clang::APValue::APValue ( const AddrLabelExpr LHSExpr,
const AddrLabelExpr RHSExpr 
)
inline

Definition at line 213 of file APValue.h.

References setAddrLabelDiff().

◆ ~APValue()

clang::APValue::~APValue ( )
inline

Definition at line 218 of file APValue.h.

References needsCleanup(), and swap().

Member Function Documentation

◆ dump() [1/2]

LLVM_DUMP_METHOD void APValue::dump ( ) const

Definition at line 300 of file APValue.cpp.

Referenced by dump(), and isAddrLabelDiff().

◆ dump() [2/2]

void APValue::dump ( raw_ostream &  OS) const

◆ getAddrLabelDiffLHS()

const AddrLabelExpr* clang::APValue::getAddrLabelDiffLHS ( ) const
inline

Definition at line 398 of file APValue.h.

References isAddrLabelDiff().

Referenced by APValue(), and clang::CodeGen::ConstantEmitter::tryEmitPrivate().

◆ getAddrLabelDiffRHS()

const AddrLabelExpr* clang::APValue::getAddrLabelDiffRHS ( ) const
inline

Definition at line 402 of file APValue.h.

References isAddrLabelDiff().

Referenced by APValue(), and clang::CodeGen::ConstantEmitter::tryEmitPrivate().

◆ getArrayFiller() [1/2]

APValue& clang::APValue::getArrayFiller ( )
inline

◆ getArrayFiller() [2/2]

const APValue& clang::APValue::getArrayFiller ( ) const
inline

Definition at line 347 of file APValue.h.

References getArrayFiller().

◆ getArrayInitializedElt() [1/2]

APValue& clang::APValue::getArrayInitializedElt ( unsigned  I)
inline

◆ getArrayInitializedElt() [2/2]

const APValue& clang::APValue::getArrayInitializedElt ( unsigned  I) const
inline

Definition at line 336 of file APValue.h.

References getArrayInitializedElt().

◆ getArrayInitializedElts()

unsigned clang::APValue::getArrayInitializedElts ( ) const
inline

◆ getArraySize()

unsigned clang::APValue::getArraySize ( ) const
inline

Definition at line 354 of file APValue.h.

References isArray().

Referenced by APValue(), dump(), hasArrayFiller(), and clang::CodeGen::ConstantEmitter::tryEmitPrivate().

◆ getAsString()

std::string APValue::getAsString ( ASTContext Ctx,
QualType  Ty 
) const

◆ getComplexFloatImag() [1/2]

APFloat& clang::APValue::getComplexFloatImag ( )
inline

◆ getComplexFloatImag() [2/2]

const APFloat& clang::APValue::getComplexFloatImag ( ) const
inline

Definition at line 302 of file APValue.h.

References getComplexFloatImag(), getLValueBase(), and getLValueOffset().

◆ getComplexFloatReal() [1/2]

APFloat& clang::APValue::getComplexFloatReal ( )
inline

◆ getComplexFloatReal() [2/2]

const APFloat& clang::APValue::getComplexFloatReal ( ) const
inline

Definition at line 294 of file APValue.h.

References getComplexFloatReal().

◆ getComplexIntImag() [1/2]

APSInt& clang::APValue::getComplexIntImag ( )
inline

◆ getComplexIntImag() [2/2]

const APSInt& clang::APValue::getComplexIntImag ( ) const
inline

Definition at line 286 of file APValue.h.

References getComplexIntImag().

◆ getComplexIntReal() [1/2]

APSInt& clang::APValue::getComplexIntReal ( )
inline

◆ getComplexIntReal() [2/2]

const APSInt& clang::APValue::getComplexIntReal ( ) const
inline

Definition at line 278 of file APValue.h.

References getComplexIntReal().

◆ getFloat() [1/2]

APFloat& clang::APValue::getFloat ( )
inline

◆ getFloat() [2/2]

const APFloat& clang::APValue::getFloat ( ) const
inline

Definition at line 270 of file APValue.h.

References getFloat().

◆ getInt() [1/2]

APSInt& clang::APValue::getInt ( )
inline

◆ getInt() [2/2]

const APSInt& clang::APValue::getInt ( ) const
inline

Definition at line 256 of file APValue.h.

References getInt(), clang::Result, and toIntegralConstant().

◆ getKind()

ValueKind clang::APValue::getKind ( ) const
inline

◆ getLValueBase()

const APValue::LValueBase APValue::getLValueBase ( ) const

◆ getLValueCallIndex()

unsigned APValue::getLValueCallIndex ( ) const

Definition at line 649 of file APValue.cpp.

References isLValue().

Referenced by getLValueOffset().

◆ getLValueOffset() [1/2]

CharUnits & APValue::getLValueOffset ( )

◆ getLValueOffset() [2/2]

const CharUnits& clang::APValue::getLValueOffset ( ) const
inline

◆ getLValuePath()

ArrayRef< APValue::LValuePathEntry > APValue::getLValuePath ( ) const

Definition at line 643 of file APValue.cpp.

References clang::APValue::LV::getPath(), hasLValuePath(), and isLValue().

Referenced by APValue(), and getLValueOffset().

◆ getLValueVersion()

unsigned APValue::getLValueVersion ( ) const

Definition at line 654 of file APValue.cpp.

References isLValue().

Referenced by getLValueOffset().

◆ getMemberPointerDecl()

const ValueDecl * APValue::getMemberPointerDecl ( ) const

◆ getMemberPointerPath()

ArrayRef< const CXXRecordDecl * > APValue::getMemberPointerPath ( ) const

◆ getStructBase() [1/2]

APValue& clang::APValue::getStructBase ( unsigned  i)
inline

Definition at line 367 of file APValue.h.

References isStruct().

Referenced by APValue(), CheckConstantExpression(), dump(), getStructBase(), and HandleConstructorCall().

◆ getStructBase() [2/2]

const APValue& clang::APValue::getStructBase ( unsigned  i) const
inline

Definition at line 375 of file APValue.h.

References getStructBase().

◆ getStructField() [1/2]

APValue& clang::APValue::getStructField ( unsigned  i)
inline

◆ getStructField() [2/2]

const APValue& clang::APValue::getStructField ( unsigned  i) const
inline

Definition at line 378 of file APValue.h.

References getStructField().

◆ getStructNumBases()

unsigned clang::APValue::getStructNumBases ( ) const
inline

Definition at line 359 of file APValue.h.

References isStruct().

Referenced by APValue(), dump(), and getStructField().

◆ getStructNumFields()

unsigned clang::APValue::getStructNumFields ( ) const
inline

Definition at line 363 of file APValue.h.

References isStruct().

Referenced by APValue(), and dump().

◆ getUnionField()

const FieldDecl* clang::APValue::getUnionField ( ) const
inline

Definition at line 382 of file APValue.h.

References isUnion().

Referenced by APValue(), CheckConstantExpression(), and HandleConstructorCall().

◆ getUnionValue() [1/2]

APValue& clang::APValue::getUnionValue ( )
inline

Definition at line 386 of file APValue.h.

References isUnion().

Referenced by APValue(), CheckConstantExpression(), dump(), getUnionValue(), and HandleConstructorCall().

◆ getUnionValue() [2/2]

const APValue& clang::APValue::getUnionValue ( ) const
inline

◆ getVectorElt() [1/2]

APValue& clang::APValue::getVectorElt ( unsigned  I)
inline

◆ getVectorElt() [2/2]

const APValue& clang::APValue::getVectorElt ( unsigned  I) const
inline

Definition at line 323 of file APValue.h.

References getVectorElt().

◆ getVectorLength()

unsigned clang::APValue::getVectorLength ( ) const
inline

◆ hasArrayFiller()

bool clang::APValue::hasArrayFiller ( ) const
inline

◆ hasLValuePath()

bool APValue::hasLValuePath ( ) const

Definition at line 638 of file APValue.cpp.

References isLValue().

Referenced by APValue(), getLValueOffset(), getLValuePath(), and printPretty().

◆ isAddrLabelDiff()

bool clang::APValue::isAddrLabelDiff ( ) const
inline

Definition at line 244 of file APValue.h.

References AddrLabelDiff, dump(), getAsString(), and printPretty().

Referenced by getAddrLabelDiffLHS(), getAddrLabelDiffRHS(), and GetValueRange().

◆ isArray()

bool clang::APValue::isArray ( ) const
inline

◆ isComplexFloat()

bool clang::APValue::isComplexFloat ( ) const
inline

Definition at line 237 of file APValue.h.

References ComplexFloat.

Referenced by getComplexFloatImag(), getComplexFloatReal(), IsSameFloatAfterCast(), and setComplexFloat().

◆ isComplexInt()

bool clang::APValue::isComplexInt ( ) const
inline

Definition at line 236 of file APValue.h.

References ComplexInt.

Referenced by getComplexIntImag(), getComplexIntReal(), GetValueRange(), and setComplexInt().

◆ isFloat()

bool clang::APValue::isFloat ( ) const
inline

◆ isInt()

bool clang::APValue::isInt ( ) const
inline

◆ isLValue()

bool clang::APValue::isLValue ( ) const
inline

◆ isLValueOnePastTheEnd()

bool APValue::isLValueOnePastTheEnd ( ) const

Definition at line 628 of file APValue.cpp.

References isLValue().

Referenced by APValue(), and getLValueOffset().

◆ isMemberPointer()

bool clang::APValue::isMemberPointer ( ) const
inline

◆ isMemberPointerToDerivedMember()

bool APValue::isMemberPointerToDerivedMember ( ) const

◆ isNullPointer()

bool APValue::isNullPointer ( ) const

◆ isStruct()

bool clang::APValue::isStruct ( ) const
inline

◆ isUninit()

bool clang::APValue::isUninit ( ) const
inline

◆ isUnion()

bool clang::APValue::isUnion ( ) const
inline

Definition at line 242 of file APValue.h.

References Union.

Referenced by CheckConstantExpression(), getUnionField(), getUnionValue(), HandleConstructorCall(), and setUnion().

◆ isVector()

bool clang::APValue::isVector ( ) const
inline

◆ needsCleanup()

bool APValue::needsCleanup ( ) const

Returns whether the object performed allocations.

If APValues are constructed via placement new, needsCleanup() indicates whether the destructor must be called in order to correctly free all allocated memory.

Definition at line 257 of file APValue.cpp.

References AddrLabelDiff, Array, ComplexFloat, ComplexInt, Float, getComplexFloatImag(), getComplexFloatReal(), getComplexIntImag(), getComplexIntReal(), getFloat(), getInt(), getKind(), Int, LValue, MemberPointer, Struct, Uninitialized, Union, and Vector.

Referenced by clang::VarDecl::evaluateValue(), and ~APValue().

◆ operator=()

APValue& clang::APValue::operator= ( APValue  RHS)
inline

Assign by swapping from a copy of the RHS.

Definition at line 453 of file APValue.h.

References AddrLabelDiff, ComplexFloat, ComplexInt, Float, Int, isUninit(), Struct, swap(), Uninitialized, Union, and Vector.

◆ printPretty()

void APValue::printPretty ( raw_ostream &  OS,
ASTContext Ctx,
QualType  Ty 
) const

◆ setAddrLabelDiff()

void clang::APValue::setAddrLabelDiff ( const AddrLabelExpr LHSExpr,
const AddrLabelExpr RHSExpr 
)
inline

Definition at line 446 of file APValue.h.

Referenced by APValue().

◆ setComplexFloat()

void clang::APValue::setComplexFloat ( APFloat  R,
APFloat  I 
)
inline

Definition at line 429 of file APValue.h.

References isComplexFloat(), and setLValue().

Referenced by APValue().

◆ setComplexInt()

void clang::APValue::setComplexInt ( APSInt  R,
APSInt  I 
)
inline

Definition at line 422 of file APValue.h.

References isComplexInt().

Referenced by APValue().

◆ setFloat()

void clang::APValue::setFloat ( APFloat  F)
inline

Definition at line 411 of file APValue.h.

References isFloat().

Referenced by APValue().

◆ setInt()

void clang::APValue::setInt ( APSInt  I)
inline

Definition at line 407 of file APValue.h.

References isInt().

Referenced by APValue().

◆ setLValue() [1/2]

void APValue::setLValue ( LValueBase  B,
const CharUnits O,
NoLValuePath  ,
bool  IsNullPtr 
)

Definition at line 664 of file APValue.cpp.

References isLValue(), and clang::APValue::LV::resizePath().

Referenced by APValue(), and setComplexFloat().

◆ setLValue() [2/2]

void APValue::setLValue ( LValueBase  B,
const CharUnits O,
ArrayRef< LValuePathEntry Path,
bool  OnePastTheEnd,
bool  IsNullPtr 
)

◆ setUnion()

void clang::APValue::setUnion ( const FieldDecl Field,
const APValue Value 
)
inline

Definition at line 441 of file APValue.h.

References isUnion().

Referenced by APValue().

◆ setVector()

void clang::APValue::setVector ( const APValue E,
unsigned  N 
)
inline

Definition at line 415 of file APValue.h.

References isVector().

Referenced by APValue().

◆ swap()

void APValue::swap ( APValue RHS)

Swaps the contents of this and the given APValue.

Definition at line 292 of file APValue.cpp.

References memcpy().

Referenced by APValue(), extractSubobject(), isOnePastTheEndOfCompleteObject(), operator=(), and ~APValue().

◆ toIntegralConstant()

bool APValue::toIntegralConstant ( APSInt &  Result,
QualType  SrcTy,
const ASTContext Ctx 
) const

Try to convert this value to an integral constant.

This works if it's an integer, null pointer, or offset from a null pointer. Returns true on success.

Definition at line 603 of file APValue.cpp.

References getInt(), getLValueBase(), getLValueOffset(), clang::ASTContext::getTargetNullPointerValue(), isInt(), isLValue(), isNullPointer(), and clang::ASTContext::MakeIntValue().

Referenced by AddVariableConstraints(), EvaluateComparisonBinaryOperator(), and getInt().


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