clang API Documentation

Public Member Functions | Protected Member Functions | Protected Attributes
clang::ento::SValBuilder Class Reference

#include <SValBuilder.h>

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

List of all members.

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)
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
virtual SVal evalBinOpLL (ProgramStateRef state, BinaryOperator::Opcode op, Loc lhs, Loc rhs, QualType resultTy)=0
virtual SVal evalBinOpLN (ProgramStateRef state, BinaryOperator::Opcode op, Loc lhs, NonLoc rhs, QualType resultTy)=0
virtual const llvm::APSInt * getKnownValue (ProgramStateRef state, SVal val)=0
SVal makeSymExprValNN (ProgramStateRef state, BinaryOperator::Opcode op, NonLoc lhs, NonLoc rhs, QualType resultTy)
 Constructs a symbolic expression for two non-location values.
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 SymbolConjuredgetConjuredSymbol (const Stmt *stmt, const LocationContext *LCtx, QualType type, unsigned visitCount, const void *symbolTag=0)
const SymbolConjuredgetConjuredSymbol (const Expr *expr, const LocationContext *LCtx, unsigned visitCount, const void *symbolTag=0)
DefinedOrUnknownSVal makeZeroVal (QualType type)
 Construct an SVal representing '0' for the specified type.
DefinedOrUnknownSVal getRegionValueSymbolVal (const TypedValueRegion *region)
 Make a unique symbol for value of region.
DefinedOrUnknownSVal getConjuredSymbolVal (const void *symbolTag, const Expr *expr, const LocationContext *LCtx, unsigned count)
 Create a new symbol with a unique 'name'.
DefinedOrUnknownSVal getConjuredSymbolVal (const void *symbolTag, const Expr *expr, const LocationContext *LCtx, QualType type, unsigned count)
DefinedOrUnknownSVal getConjuredSymbolVal (const Stmt *stmt, const LocationContext *LCtx, QualType type, unsigned visitCount)
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)
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 makeIntVal (uint64_t integer, unsigned bitWidth, 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.
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)

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.
SymbolManager SymMgr
 Manages the creation of symbols.
MemRegionManager MemMgr
 Manages the creation of memory regions.
ProgramStateManagerStateMgr
const QualType ArrayIndexTy
 The scalar type to use for array indices.
const unsigned ArrayIndexWidth
 The width of the scalar type used for array indices.

Detailed Description

Definition at line 31 of file SValBuilder.h.


Constructor & Destructor Documentation

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

Definition at line 62 of file SValBuilder.h.

virtual clang::ento::SValBuilder::~SValBuilder ( ) [inline, virtual]

Definition at line 71 of file SValBuilder.h.


Member Function Documentation

SVal SValBuilder::convertToArrayIndex ( SVal  val)
virtual SVal clang::ento::SValBuilder::dispatchCast ( SVal  val,
QualType  castTy 
) [pure virtual]
SVal clang::ento::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 clang::ento::loc::ConcreteInt::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 clang::ento::loc::ConcreteInt::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 clang::ento::ProgramState::assumeInBound(), clang::ento::ExprEngine::evalBinOp(), and clang::ento::loc::ConcreteInt::evalBinOp().

SVal SValBuilder::evalCast ( SVal  val,
QualType  castTy,
QualType  originalType 
)
virtual SVal clang::ento::SValBuilder::evalCastFromLoc ( Loc  val,
QualType  castTy 
) [protected, pure virtual]

Referenced by evalCast().

virtual SVal clang::ento::SValBuilder::evalCastFromNonLoc ( NonLoc  val,
QualType  castTy 
) [protected, pure virtual]

Referenced by convertToArrayIndex().

virtual SVal clang::ento::SValBuilder::evalComplement ( NonLoc  val) [pure virtual]
DefinedOrUnknownSVal SValBuilder::evalEQ ( ProgramStateRef  state,
DefinedOrUnknownSVal  lhs,
DefinedOrUnknownSVal  rhs 
)
virtual SVal clang::ento::SValBuilder::evalMinus ( NonLoc  val) [pure virtual]
QualType clang::ento::SValBuilder::getArrayIndexType ( ) const [inline]

Definition at line 129 of file SValBuilder.h.

References ArrayIndexTy.

Referenced by clang::ento::FieldRegion::getExtent().

BasicValueFactory& clang::ento::SValBuilder::getBasicValueFactory ( ) [inline]
const BasicValueFactory& clang::ento::SValBuilder::getBasicValueFactory ( ) const [inline]

Definition at line 134 of file SValBuilder.h.

References BasicVals.

DefinedSVal SValBuilder::getBlockPointer ( const BlockDecl block,
CanQualType  locTy,
const LocationContext locContext 
)
QualType clang::ento::SValBuilder::getConditionType ( ) const [inline]

Definition at line 125 of file SValBuilder.h.

References getContext(), and clang::ASTContext::IntTy.

const SymbolConjured* clang::ento::SValBuilder::getConjuredSymbol ( const Stmt stmt,
const LocationContext LCtx,
QualType  type,
unsigned  visitCount,
const void *  symbolTag = 0 
) [inline]

Definition at line 144 of file SValBuilder.h.

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

const SymbolConjured* clang::ento::SValBuilder::getConjuredSymbol ( const Expr expr,
const LocationContext LCtx,
unsigned  visitCount,
const void *  symbolTag = 0 
) [inline]

Definition at line 152 of file SValBuilder.h.

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

DefinedOrUnknownSVal SValBuilder::getConjuredSymbolVal ( const void *  symbolTag,
const Expr expr,
const LocationContext LCtx,
unsigned  count 
)

Create a new symbol with a unique 'name'.

We resort to conjured symbols when we cannot construct a derived symbol. The advantage of symbols derived/built from other symbols is that we preserve the relation between related(or even equivalent) expressions, so conjured symbols should be used sparingly.

Definition at line 109 of file SValBuilder.cpp.

References clang::Expr::getType().

Referenced by clang::ento::ExprEngine::evalObjCMessage(), clang::ento::ExprEngine::VisitCallExpr(), clang::ento::ExprEngine::VisitCast(), clang::ento::ExprEngine::VisitCXXCatchStmt(), clang::ento::ExprEngine::VisitCXXNewExpr(), clang::ento::ExprEngine::VisitDeclStmt(), and clang::ento::ExprEngine::VisitIncrementDecrementOperator().

DefinedOrUnknownSVal SValBuilder::getConjuredSymbolVal ( const void *  symbolTag,
const Expr expr,
const LocationContext LCtx,
QualType  type,
unsigned  count 
)
DefinedOrUnknownSVal SValBuilder::getConjuredSymbolVal ( const Stmt stmt,
const LocationContext LCtx,
QualType  type,
unsigned  visitCount 
)
ASTContext& clang::ento::SValBuilder::getContext ( ) [inline]
const ASTContext& clang::ento::SValBuilder::getContext ( ) const [inline]

Definition at line 121 of file SValBuilder.h.

References Context.

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 140 of file SValBuilder.h.

References MemMgr.

DefinedOrUnknownSVal SValBuilder::getRegionValueSymbolVal ( const TypedValueRegion region)
ProgramStateManager & GRBugReporter::getStateManager ( ) [inline]

Definition at line 123 of file SValBuilder.h.

References StateMgr.

SymbolManager& clang::ento::SValBuilder::getSymbolManager ( ) [inline]
const SymbolManager& clang::ento::SValBuilder::getSymbolManager ( ) const [inline]

Definition at line 137 of file SValBuilder.h.

References SymMgr.

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

Definition at line 73 of file SValBuilder.h.

References Context, and clang::ento::SymExpr::getType().

bool clang::ento::SValBuilder::haveSameType ( QualType  Ty1,
QualType  Ty2 
) [inline]

Definition at line 77 of file SValBuilder.h.

References Context, and clang::ASTContext::getCanonicalType().

NonLoc clang::ento::SValBuilder::makeArrayIndex ( uint64_t  idx) [inline]
nonloc::ConcreteInt clang::ento::SValBuilder::makeBoolVal ( const ObjCBoolLiteralExpr boolean) [inline]

Definition at line 224 of file SValBuilder.h.

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

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

Definition at line 89 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 234 of file SValBuilder.h.

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

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

Definition at line 230 of file SValBuilder.h.

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

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

Definition at line 238 of file SValBuilder.h.

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

DefinedSVal clang::ento::SValBuilder::makeIntVal ( uint64_t  integer,
QualType  type 
) [inline]
NonLoc clang::ento::SValBuilder::makeIntVal ( uint64_t  integer,
bool  isUnsigned 
) [inline]

Definition at line 249 of file SValBuilder.h.

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

NonLoc clang::ento::SValBuilder::makeIntVal ( uint64_t  integer,
unsigned  bitWidth,
bool  isUnsigned 
) [inline]

Definition at line 258 of file SValBuilder.h.

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

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 295 of file SValBuilder.h.

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

Definition at line 299 of file SValBuilder.h.

References clang::AddrLabelExpr::getLabel().

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

Definition at line 303 of file SValBuilder.h.

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

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 clang::ento::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 68 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 197 of file SValBuilder.cpp.

References clang::ento::SymExpr::computeComplexity(), 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 283 of file SValBuilder.h.

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

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

Construct an SVal representing '0' for the specified type.

Definition at line 31 of file SValBuilder.cpp.

References clang::ento::Loc::isLocType(), makeIntVal(), and makeNull().

Referenced by clang::ento::SubEngine::getInitialState(), and clang::ento::ExprEngine::VisitIncrementDecrementOperator().


Member Data Documentation

The scalar type to use for array indices.

Definition at line 48 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 51 of file SValBuilder.h.

Referenced by convertToArrayIndex().

Definition at line 34 of file SValBuilder.h.

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

Definition at line 45 of file SValBuilder.h.

Referenced by evalCast(), and getStateManager().


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