clang  3.9.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
clang::ento::SValBuilder Class Referenceabstract

#include <SValBuilder.h>

Collaboration diagram for clang::ento::SValBuilder:
[legend]

Public Member Functions

virtual SVal dispatchCast (SVal val, QualType castTy)=0
 
 SValBuilder (llvm::BumpPtrAllocator &alloc, ASTContext &context, ProgramStateManager &stateMgr)
 
virtual ~SValBuilder ()
 
bool haveSameType (const SymExpr *Sym1, const SymExpr *Sym2)
 
bool haveSameType (QualType Ty1, QualType Ty2)
 
SVal evalCast (SVal val, QualType castTy, QualType originalType)
 
SVal evalIntegralCast (ProgramStateRef state, SVal val, QualType castTy, QualType originalType)
 
virtual SVal evalMinus (NonLoc val)=0
 
virtual SVal evalComplement (NonLoc val)=0
 
virtual SVal evalBinOpNN (ProgramStateRef state, BinaryOperator::Opcode op, NonLoc lhs, NonLoc rhs, QualType resultTy)=0
 Create a new value which represents a binary expression with two non- location operands. More...
 
virtual SVal evalBinOpLL (ProgramStateRef state, BinaryOperator::Opcode op, Loc lhs, Loc rhs, QualType resultTy)=0
 Create a new value which represents a binary expression with two memory location operands. More...
 
virtual SVal evalBinOpLN (ProgramStateRef state, BinaryOperator::Opcode op, Loc lhs, NonLoc rhs, QualType resultTy)=0
 Create a new value which represents a binary expression with a memory location and non-location operands. More...
 
virtual const llvm::APSInt * getKnownValue (ProgramStateRef state, SVal val)=0
 Evaluates a given SVal. More...
 
SVal makeSymExprValNN (ProgramStateRef state, BinaryOperator::Opcode op, NonLoc lhs, NonLoc rhs, QualType resultTy)
 Constructs a symbolic expression for two non-location values. More...
 
SVal evalBinOp (ProgramStateRef state, BinaryOperator::Opcode op, SVal lhs, SVal rhs, QualType type)
 
DefinedOrUnknownSVal evalEQ (ProgramStateRef state, DefinedOrUnknownSVal lhs, DefinedOrUnknownSVal rhs)
 
ASTContextgetContext ()
 
const ASTContextgetContext () const
 
ProgramStateManagergetStateManager ()
 
QualType getConditionType () const
 
QualType getArrayIndexType () const
 
BasicValueFactorygetBasicValueFactory ()
 
const BasicValueFactorygetBasicValueFactory () const
 
SymbolManagergetSymbolManager ()
 
const SymbolManagergetSymbolManager () const
 
MemRegionManagergetRegionManager ()
 
const MemRegionManagergetRegionManager () const
 
const SymbolConjuredconjureSymbol (const Stmt *stmt, const LocationContext *LCtx, QualType type, unsigned visitCount, const void *symbolTag=nullptr)
 
const SymbolConjuredconjureSymbol (const Expr *expr, const LocationContext *LCtx, unsigned visitCount, const void *symbolTag=nullptr)
 
DefinedOrUnknownSVal makeZeroVal (QualType type)
 Construct an SVal representing '0' for the specified type. More...
 
DefinedOrUnknownSVal getRegionValueSymbolVal (const TypedValueRegion *region)
 Make a unique symbol for value of region. More...
 
DefinedOrUnknownSVal conjureSymbolVal (const void *symbolTag, const Expr *expr, const LocationContext *LCtx, unsigned count)
 Create a new symbol with a unique 'name'. More...
 
DefinedOrUnknownSVal conjureSymbolVal (const void *symbolTag, const Expr *expr, const LocationContext *LCtx, QualType type, unsigned count)
 
DefinedOrUnknownSVal conjureSymbolVal (const Stmt *stmt, const LocationContext *LCtx, QualType type, unsigned visitCount)
 
DefinedOrUnknownSVal getConjuredHeapSymbolVal (const Expr *E, const LocationContext *LCtx, unsigned Count)
 Conjure a symbol representing heap allocated memory region. More...
 
DefinedOrUnknownSVal getDerivedRegionValueSymbolVal (SymbolRef parentSymbol, const TypedValueRegion *region)
 
DefinedSVal getMetadataSymbolVal (const void *symbolTag, const MemRegion *region, const Expr *expr, QualType type, unsigned count)
 
DefinedSVal getFunctionPointer (const FunctionDecl *func)
 
DefinedSVal getBlockPointer (const BlockDecl *block, CanQualType locTy, const LocationContext *locContext, unsigned blockCount)
 
Optional< SValgetConstantVal (const Expr *E)
 Returns the value of E, if it can be determined in a non-path-sensitive manner. More...
 
NonLoc makeCompoundVal (QualType type, llvm::ImmutableList< SVal > vals)
 
NonLoc makeLazyCompoundVal (const StoreRef &store, const TypedValueRegion *region)
 
NonLoc makeZeroArrayIndex ()
 
NonLoc makeArrayIndex (uint64_t idx)
 
SVal convertToArrayIndex (SVal val)
 
nonloc::ConcreteInt makeIntVal (const IntegerLiteral *integer)
 
nonloc::ConcreteInt makeBoolVal (const ObjCBoolLiteralExpr *boolean)
 
nonloc::ConcreteInt makeBoolVal (const CXXBoolLiteralExpr *boolean)
 
nonloc::ConcreteInt makeIntVal (const llvm::APSInt &integer)
 
loc::ConcreteInt makeIntLocVal (const llvm::APSInt &integer)
 
NonLoc makeIntVal (const llvm::APInt &integer, bool isUnsigned)
 
DefinedSVal makeIntVal (uint64_t integer, QualType type)
 
NonLoc makeIntVal (uint64_t integer, bool isUnsigned)
 
NonLoc makeIntValWithPtrWidth (uint64_t integer, bool isUnsigned)
 
NonLoc makeLocAsInteger (Loc loc, unsigned bits)
 
NonLoc makeNonLoc (const SymExpr *lhs, BinaryOperator::Opcode op, const llvm::APSInt &rhs, QualType type)
 
NonLoc makeNonLoc (const llvm::APSInt &rhs, BinaryOperator::Opcode op, const SymExpr *lhs, QualType type)
 
NonLoc makeNonLoc (const SymExpr *lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType type)
 
NonLoc makeNonLoc (const SymExpr *operand, QualType fromTy, QualType toTy)
 Create a NonLoc value for cast. More...
 
nonloc::ConcreteInt makeTruthVal (bool b, QualType type)
 
nonloc::ConcreteInt makeTruthVal (bool b)
 
Loc makeNull ()
 
Loc makeLoc (SymbolRef sym)
 
Loc makeLoc (const MemRegion *region)
 
Loc makeLoc (const AddrLabelExpr *expr)
 
Loc makeLoc (const llvm::APSInt &integer)
 
loc::MemRegionVal getCXXThis (const CXXMethodDecl *D, const StackFrameContext *SFC)
 Return a memory region for the 'this' object reference. More...
 
loc::MemRegionVal getCXXThis (const CXXRecordDecl *D, const StackFrameContext *SFC)
 Return a memory region for the 'this' object reference. More...
 

Protected Member Functions

virtual SVal evalCastFromNonLoc (NonLoc val, QualType castTy)=0
 
virtual SVal evalCastFromLoc (Loc val, QualType castTy)=0
 

Protected Attributes

ASTContextContext
 
BasicValueFactory BasicVals
 Manager of APSInt values. More...
 
SymbolManager SymMgr
 Manages the creation of symbols. More...
 
MemRegionManager MemMgr
 Manages the creation of memory regions. More...
 
ProgramStateManagerStateMgr
 
const QualType ArrayIndexTy
 The scalar type to use for array indices. More...
 
const unsigned ArrayIndexWidth
 The width of the scalar type used for array indices. More...
 

Detailed Description

Definition at line 32 of file SValBuilder.h.

Constructor & Destructor Documentation

clang::ento::SValBuilder::SValBuilder ( llvm::BumpPtrAllocator &  alloc,
ASTContext context,
ProgramStateManager stateMgr 
)
inline

Definition at line 63 of file SValBuilder.h.

virtual clang::ento::SValBuilder::~SValBuilder ( )
inlinevirtual

Definition at line 72 of file SValBuilder.h.

Member Function Documentation

const SymbolConjured* clang::ento::SValBuilder::conjureSymbol ( const Stmt stmt,
const LocationContext LCtx,
QualType  type,
unsigned  visitCount,
const void *  symbolTag = nullptr 
)
inline

Definition at line 150 of file SValBuilder.h.

References clang::ento::SymbolManager::conjureSymbol(), and SymMgr.

const SymbolConjured* clang::ento::SValBuilder::conjureSymbol ( const Expr expr,
const LocationContext LCtx,
unsigned  visitCount,
const void *  symbolTag = nullptr 
)
inline

Definition at line 158 of file SValBuilder.h.

References clang::ento::SymbolManager::conjureSymbol(), and SymMgr.

DefinedOrUnknownSVal SValBuilder::conjureSymbolVal ( const void *  symbolTag,
const Expr expr,
const LocationContext LCtx,
unsigned  count 
)
DefinedOrUnknownSVal SValBuilder::conjureSymbolVal ( const void *  symbolTag,
const Expr expr,
const LocationContext LCtx,
QualType  type,
unsigned  count 
)
DefinedOrUnknownSVal SValBuilder::conjureSymbolVal ( const Stmt stmt,
const LocationContext LCtx,
QualType  type,
unsigned  visitCount 
)
SVal SValBuilder::convertToArrayIndex ( SVal  val)
virtual SVal clang::ento::SValBuilder::dispatchCast ( SVal  val,
QualType  castTy 
)
pure virtual
SVal SValBuilder::evalBinOp ( ProgramStateRef  state,
BinaryOperator::Opcode  op,
SVal  lhs,
SVal  rhs,
QualType  type 
)
virtual SVal clang::ento::SValBuilder::evalBinOpLL ( ProgramStateRef  state,
BinaryOperator::Opcode  op,
Loc  lhs,
Loc  rhs,
QualType  resultTy 
)
pure virtual

Create a new value which represents a binary expression with two memory location operands.

Referenced by evalBinOp().

virtual SVal clang::ento::SValBuilder::evalBinOpLN ( ProgramStateRef  state,
BinaryOperator::Opcode  op,
Loc  lhs,
NonLoc  rhs,
QualType  resultTy 
)
pure virtual

Create a new value which represents a binary expression with a memory location and non-location operands.

For example, this would be used to evaluate a pointer arithmetic operation.

Referenced by evalBinOp().

virtual SVal clang::ento::SValBuilder::evalBinOpNN ( ProgramStateRef  state,
BinaryOperator::Opcode  op,
NonLoc  lhs,
NonLoc  rhs,
QualType  resultTy 
)
pure virtual

Create a new value which represents a binary expression with two non- location operands.

Referenced by addValue(), clang::ento::ProgramState::assumeInBound(), evalBinOp(), clang::ento::ExprEngine::evalBinOp(), evalIntegralCast(), and scaleValue().

SVal SValBuilder::evalCast ( SVal  val,
QualType  castTy,
QualType  originalType 
)
virtual SVal clang::ento::SValBuilder::evalCastFromLoc ( Loc  val,
QualType  castTy 
)
protectedpure virtual

Referenced by evalCast().

virtual SVal clang::ento::SValBuilder::evalCastFromNonLoc ( NonLoc  val,
QualType  castTy 
)
protectedpure virtual

Referenced by convertToArrayIndex().

virtual SVal clang::ento::SValBuilder::evalComplement ( NonLoc  val)
pure virtual
DefinedOrUnknownSVal SValBuilder::evalEQ ( ProgramStateRef  state,
DefinedOrUnknownSVal  lhs,
DefinedOrUnknownSVal  rhs 
)
SVal SValBuilder::evalIntegralCast ( ProgramStateRef  state,
SVal  val,
QualType  castTy,
QualType  originalType 
)
virtual SVal clang::ento::SValBuilder::evalMinus ( NonLoc  val)
pure virtual
QualType clang::ento::SValBuilder::getArrayIndexType ( ) const
inline
BasicValueFactory& clang::ento::SValBuilder::getBasicValueFactory ( )
inline
const BasicValueFactory& clang::ento::SValBuilder::getBasicValueFactory ( ) const
inline

Definition at line 140 of file SValBuilder.h.

References BasicVals.

DefinedSVal SValBuilder::getBlockPointer ( const BlockDecl block,
CanQualType  locTy,
const LocationContext locContext,
unsigned  blockCount 
)
QualType clang::ento::SValBuilder::getConditionType ( ) const
inline
DefinedOrUnknownSVal SValBuilder::getConjuredHeapSymbolVal ( const Expr E,
const LocationContext LCtx,
unsigned  Count 
)
Optional< SVal > SValBuilder::getConstantVal ( const Expr E)
ASTContext& clang::ento::SValBuilder::getContext ( )
inline
const ASTContext& clang::ento::SValBuilder::getContext ( ) const
inline

Definition at line 127 of file SValBuilder.h.

References Context.

loc::MemRegionVal SValBuilder::getCXXThis ( const CXXMethodDecl D,
const StackFrameContext SFC 
)
loc::MemRegionVal SValBuilder::getCXXThis ( const CXXRecordDecl D,
const StackFrameContext SFC 
)

Return a memory region for the 'this' object reference.

Definition at line 239 of file SValBuilder.cpp.

References getContext(), clang::ASTContext::getPointerType(), getRegionManager(), and clang::TypeDecl::getTypeForDecl().

DefinedOrUnknownSVal SValBuilder::getDerivedRegionValueSymbolVal ( SymbolRef  parentSymbol,
const TypedValueRegion region 
)
DefinedSVal SValBuilder::getFunctionPointer ( const FunctionDecl func)
virtual const llvm::APSInt* clang::ento::SValBuilder::getKnownValue ( ProgramStateRef  state,
SVal  val 
)
pure virtual

Evaluates a given SVal.

If the SVal has only one possible (integer) value, that value is returned. Otherwise, returns NULL.

DefinedSVal SValBuilder::getMetadataSymbolVal ( const void *  symbolTag,
const MemRegion region,
const Expr expr,
QualType  type,
unsigned  count 
)
MemRegionManager& clang::ento::SValBuilder::getRegionManager ( )
inline
const MemRegionManager& clang::ento::SValBuilder::getRegionManager ( ) const
inline

Definition at line 146 of file SValBuilder.h.

References MemMgr.

DefinedOrUnknownSVal SValBuilder::getRegionValueSymbolVal ( const TypedValueRegion region)
ProgramStateManager& clang::ento::SValBuilder::getStateManager ( )
inline
SymbolManager& clang::ento::SValBuilder::getSymbolManager ( )
inline
const SymbolManager& clang::ento::SValBuilder::getSymbolManager ( ) const
inline

Definition at line 143 of file SValBuilder.h.

References SymMgr.

bool clang::ento::SValBuilder::haveSameType ( const SymExpr Sym1,
const SymExpr Sym2 
)
inline

Definition at line 74 of file SValBuilder.h.

References clang::ento::SymExpr::getType().

bool clang::ento::SValBuilder::haveSameType ( QualType  Ty1,
QualType  Ty2 
)
inline
NonLoc clang::ento::SValBuilder::makeArrayIndex ( uint64_t  idx)
inline
nonloc::ConcreteInt clang::ento::SValBuilder::makeBoolVal ( const ObjCBoolLiteralExpr boolean)
inline

Definition at line 243 of file SValBuilder.h.

References clang::ObjCBoolLiteralExpr::getValue(), and makeTruthVal().

Referenced by getConstantVal().

nonloc::ConcreteInt SValBuilder::makeBoolVal ( const CXXBoolLiteralExpr boolean)

Definition at line 90 of file SValBuilder.cpp.

References clang::CXXBoolLiteralExpr::getValue(), and makeTruthVal().

NonLoc clang::ento::SValBuilder::makeCompoundVal ( QualType  type,
llvm::ImmutableList< SVal vals 
)
inline
loc::ConcreteInt clang::ento::SValBuilder::makeIntLocVal ( const llvm::APSInt &  integer)
inline

Definition at line 253 of file SValBuilder.h.

References BasicVals.

nonloc::ConcreteInt clang::ento::SValBuilder::makeIntVal ( const IntegerLiteral integer)
inline
nonloc::ConcreteInt clang::ento::SValBuilder::makeIntVal ( const llvm::APSInt &  integer)
inline

Definition at line 249 of file SValBuilder.h.

References BasicVals.

NonLoc clang::ento::SValBuilder::makeIntVal ( const llvm::APInt &  integer,
bool  isUnsigned 
)
inline

Definition at line 257 of file SValBuilder.h.

References BasicVals.

DefinedSVal clang::ento::SValBuilder::makeIntVal ( uint64_t  integer,
QualType  type 
)
inline

Definition at line 261 of file SValBuilder.h.

References BasicVals, and clang::ento::Loc::isLocType().

NonLoc clang::ento::SValBuilder::makeIntVal ( uint64_t  integer,
bool  isUnsigned 
)
inline

Definition at line 268 of file SValBuilder.h.

References BasicVals, and clang::ento::BasicValueFactory::getIntValue().

NonLoc clang::ento::SValBuilder::makeIntValWithPtrWidth ( uint64_t  integer,
bool  isUnsigned 
)
inline
NonLoc clang::ento::SValBuilder::makeLazyCompoundVal ( const StoreRef store,
const TypedValueRegion region 
)
inline
Loc clang::ento::SValBuilder::makeLoc ( SymbolRef  sym)
inline
Loc clang::ento::SValBuilder::makeLoc ( const MemRegion region)
inline

Definition at line 309 of file SValBuilder.h.

Loc clang::ento::SValBuilder::makeLoc ( const AddrLabelExpr expr)
inline

Definition at line 313 of file SValBuilder.h.

References clang::AddrLabelExpr::getLabel().

Loc clang::ento::SValBuilder::makeLoc ( const llvm::APSInt &  integer)
inline

Definition at line 317 of file SValBuilder.h.

References BasicVals.

NonLoc clang::ento::SValBuilder::makeLocAsInteger ( Loc  loc,
unsigned  bits 
)
inline
NonLoc SValBuilder::makeNonLoc ( const SymExpr lhs,
BinaryOperator::Opcode  op,
const llvm::APSInt &  rhs,
QualType  type 
)
NonLoc SValBuilder::makeNonLoc ( const llvm::APSInt &  rhs,
BinaryOperator::Opcode  op,
const SymExpr lhs,
QualType  type 
)
NonLoc SValBuilder::makeNonLoc ( const SymExpr lhs,
BinaryOperator::Opcode  op,
const SymExpr rhs,
QualType  type 
)
NonLoc SValBuilder::makeNonLoc ( const SymExpr operand,
QualType  fromTy,
QualType  toTy 
)

Create a NonLoc value for cast.

Definition at line 69 of file SValBuilder.cpp.

References clang::ento::SymbolManager::getCastSymbol(), clang::ento::Loc::isLocType(), and SymMgr.

Loc clang::ento::SValBuilder::makeNull ( )
inline
SVal SValBuilder::makeSymExprValNN ( ProgramStateRef  state,
BinaryOperator::Opcode  op,
NonLoc  lhs,
NonLoc  rhs,
QualType  resultTy 
)

Constructs a symbolic expression for two non-location values.

Definition at line 332 of file SValBuilder.cpp.

References clang::ento::SymExpr::computeComplexity(), clang::ento::SVal::getAs(), clang::ento::SVal::getAsSymExpr(), and makeNonLoc().

nonloc::ConcreteInt clang::ento::SValBuilder::makeTruthVal ( bool  b,
QualType  type 
)
inline
nonloc::ConcreteInt clang::ento::SValBuilder::makeTruthVal ( bool  b)
inline

Definition at line 297 of file SValBuilder.h.

References BasicVals, and clang::ento::BasicValueFactory::getTruthValue().

NonLoc clang::ento::SValBuilder::makeZeroArrayIndex ( )
inline
DefinedOrUnknownSVal SValBuilder::makeZeroVal ( QualType  type)

Member Data Documentation

const QualType clang::ento::SValBuilder::ArrayIndexTy
protected

The scalar type to use for array indices.

Definition at line 49 of file SValBuilder.h.

Referenced by convertToArrayIndex(), getArrayIndexType(), makeArrayIndex(), and makeZeroArrayIndex().

const unsigned clang::ento::SValBuilder::ArrayIndexWidth
protected

The width of the scalar type used for array indices.

Definition at line 52 of file SValBuilder.h.

Referenced by convertToArrayIndex().

BasicValueFactory clang::ento::SValBuilder::BasicVals
protected
ASTContext& clang::ento::SValBuilder::Context
protected

Definition at line 35 of file SValBuilder.h.

Referenced by evalCast(), getConditionType(), getContext(), and haveSameType().

MemRegionManager clang::ento::SValBuilder::MemMgr
protected
ProgramStateManager& clang::ento::SValBuilder::StateMgr
protected

Definition at line 46 of file SValBuilder.h.

Referenced by evalCast(), and getStateManager().

SymbolManager clang::ento::SValBuilder::SymMgr
protected

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