clang API Documentation

Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
clang::ento::StoreManager Class Reference

#include <Store.h>

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

List of all members.

Classes

class  BindingsHandler
class  CastResult
class  FindUniqueBinding

Public Types

typedef llvm::DenseSet< SymbolRefInvalidatedSymbols
typedef SmallVector< const
MemRegion *, 8 > 
InvalidatedRegions

Public Member Functions

virtual ~StoreManager ()
virtual SVal getBinding (Store store, Loc loc, QualType T=QualType())=0
virtual StoreRef Bind (Store store, Loc loc, SVal val)=0
virtual StoreRef BindDefault (Store store, const MemRegion *R, SVal V)
virtual StoreRef Remove (Store St, Loc L)=0
virtual StoreRef BindCompoundLiteral (Store store, const CompoundLiteralExpr *cl, const LocationContext *LC, SVal v)=0
virtual StoreRef getInitialStore (const LocationContext *InitLoc)=0
MemRegionManagergetRegionManager ()
virtual SubRegionMapgetSubRegionMap (Store store)=0
virtual Loc getLValueVar (const VarDecl *VD, const LocationContext *LC)
Loc getLValueCompoundLiteral (const CompoundLiteralExpr *CL, const LocationContext *LC)
virtual SVal getLValueIvar (const ObjCIvarDecl *decl, SVal base)
virtual SVal getLValueField (const FieldDecl *D, SVal Base)
virtual SVal getLValueElement (QualType elementType, NonLoc offset, SVal Base)
virtual DefinedOrUnknownSVal getSizeInElements (ProgramStateRef state, const MemRegion *region, QualType EleTy)
virtual SVal ArrayToPointer (Loc Array)=0
virtual SVal evalDerivedToBase (SVal derived, QualType basePtrType)=0
 Evaluates DerivedToBase casts.
virtual SVal evalDynamicCast (SVal base, QualType derivedPtrType, bool &Failed)=0
 Evaluates C++ dynamic_cast cast. The callback may result in the following 3 scenarios:
const ElementRegionGetElementZeroRegion (const MemRegion *R, QualType T)
const MemRegioncastRegion (const MemRegion *region, QualType CastToTy)
virtual StoreRef removeDeadBindings (Store store, const StackFrameContext *LCtx, SymbolReaper &SymReaper)=0
virtual StoreRef BindDecl (Store store, const VarRegion *VR, SVal initVal)=0
virtual StoreRef BindDeclWithNoInit (Store store, const VarRegion *VR)=0
virtual bool includedInBindings (Store store, const MemRegion *region) const =0
virtual void incrementReferenceCount (Store store)
virtual void decrementReferenceCount (Store store)
virtual StoreRef invalidateRegions (Store store, ArrayRef< const MemRegion * > Regions, const Expr *E, unsigned Count, const LocationContext *LCtx, InvalidatedSymbols &IS, const CallOrObjCMessage *Call, InvalidatedRegions *Invalidated)=0
virtual StoreRef enterStackFrame (ProgramStateRef state, const LocationContext *callerCtx, const StackFrameContext *calleeCtx)
virtual void print (Store store, raw_ostream &Out, const char *nl, const char *sep)=0
virtual void iterBindings (Store store, BindingsHandler &f)=0
 iterBindings - Iterate over the bindings in the Store.

Protected Member Functions

 StoreManager (ProgramStateManager &stateMgr)
const MemRegionMakeElementRegion (const MemRegion *baseRegion, QualType pointeeTy, uint64_t index=0)
SVal CastRetrievedVal (SVal val, const TypedValueRegion *region, QualType castTy, bool performTestOnly=true)

Protected Attributes

SValBuildersvalBuilder
ProgramStateManagerStateMgr
MemRegionManagerMRMgr
 MRMgr - Manages region objects associated with this StoreManager.
ASTContextCtx

Detailed Description

Definition at line 37 of file Store.h.


Member Typedef Documentation

Definition at line 172 of file Store.h.

Definition at line 171 of file Store.h.


Constructor & Destructor Documentation

StoreManager::StoreManager ( ProgramStateManager stateMgr) [protected]

Definition at line 22 of file Store.cpp.

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

Definition at line 49 of file Store.h.


Member Function Documentation

virtual SVal clang::ento::StoreManager::ArrayToPointer ( Loc  Array) [pure virtual]

ArrayToPointer - Used by ExprEngine::VistCast to handle implicit conversions between arrays and pointers.

virtual StoreRef clang::ento::StoreManager::Bind ( Store  store,
Loc  loc,
SVal  val 
) [pure virtual]

Return a state with the specified value bound to the given location.

Parameters:
[in]stateThe analysis state.
[in]locThe symbolic memory location.
[in]valThe value to bind to location loc.
Returns:
A pointer to a ProgramState object that contains the same bindings as state with the addition of having the value specified by val bound to the location given for loc.
virtual StoreRef clang::ento::StoreManager::BindCompoundLiteral ( Store  store,
const CompoundLiteralExpr cl,
const LocationContext LC,
SVal  v 
) [pure virtual]

BindCompoundLiteral - Return the store that has the bindings currently in 'store' plus the bindings for the CompoundLiteral. 'R' is the region for the compound literal and 'BegInit' and 'EndInit' represent an array of initializer values.

virtual StoreRef clang::ento::StoreManager::BindDecl ( Store  store,
const VarRegion VR,
SVal  initVal 
) [pure virtual]
virtual StoreRef clang::ento::StoreManager::BindDeclWithNoInit ( Store  store,
const VarRegion VR 
) [pure virtual]
StoreRef StoreManager::BindDefault ( Store  store,
const MemRegion R,
SVal  V 
) [virtual]

Definition at line 49 of file Store.cpp.

const MemRegion * StoreManager::castRegion ( const MemRegion region,
QualType  CastToTy 
)

castRegion - Used by ExprEngine::VisitCast to handle casts from a MemRegion* to a specific location type. 'R' is the region being casted and 'CastToTy' the result type of the cast.

Definition at line 60 of file Store.cpp.

References clang::ento::MemRegion::AllocaRegionKind, clang::ento::MemRegion::BlockDataRegionKind, clang::ento::MemRegion::BlockTextRegionKind, clang::ASTContext::CharTy, clang::ento::MemRegion::CompoundLiteralRegionKind, Ctx, clang::ento::MemRegion::CXXBaseObjectRegionKind, clang::ento::MemRegion::CXXTempObjectRegionKind, clang::ento::MemRegion::CXXThisRegionKind, clang::ento::MemRegion::ElementRegionKind, clang::ento::MemRegion::FieldRegionKind, clang::ento::MemRegion::FunctionTextRegionKind, clang::ento::MemRegion::GenericMemSpaceRegionKind, clang::ento::ElementRegion::getAsArrayOffset(), clang::ASTContext::getCanonicalType(), clang::ento::ProgramStateManager::getContext(), clang::ento::MemRegion::getKind(), clang::QualType::getLocalUnqualifiedType(), clang::CharUnits::getQuantity(), clang::ASTContext::getTypeSizeInChars(), clang::ento::MemRegion::GlobalImmutableSpaceRegionKind, clang::ento::MemRegion::GlobalInternalSpaceRegionKind, clang::ento::MemRegion::GlobalSystemSpaceRegionKind, clang::ento::MemRegion::HeapSpaceRegionKind, clang::ento::MemRegion::isBoundable(), IsCompleteType(), clang::CharUnits::isZero(), MakeElementRegion(), NULL, clang::ento::MemRegion::ObjCIvarRegionKind, clang::ento::MemRegion::ObjCStringRegionKind, clang::ento::MemRegion::StackArgumentsSpaceRegionKind, clang::ento::MemRegion::StackLocalsSpaceRegionKind, StateMgr, clang::ento::MemRegion::StaticGlobalSpaceRegionKind, clang::ento::MemRegion::StringRegionKind, clang::ento::MemRegion::StripCasts(), clang::ento::MemRegion::SymbolicRegionKind, clang::ento::MemRegion::UnknownSpaceRegionKind, clang::ento::MemRegion::VarRegionKind, and clang::ASTContext::VoidTy.

Referenced by clang::ento::SValBuilder::evalCast().

SVal StoreManager::CastRetrievedVal ( SVal  V,
const TypedValueRegion R,
QualType  castTy,
bool  performTestOnly = true 
) [protected]

CastRetrievedVal - Used by subclasses of StoreManager to implement implicit casts that arise from loads from regions that are reinterpreted as another region.

Definition at line 217 of file Store.cpp.

References Ctx, clang::ento::SValBuilder::dispatchCast(), clang::ento::SValBuilder::getContext(), clang::ASTContext::getPointerType(), clang::ento::TypedValueRegion::getValueType(), clang::ASTContext::hasSameUnqualifiedType(), clang::QualType::isNull(), clang::ento::SVal::isUnknownOrUndef(), and svalBuilder.

virtual void clang::ento::StoreManager::decrementReferenceCount ( Store  store) [inline, virtual]

If the StoreManager supports it, decrement the reference count of the specified Store object. If the reference count hits 0, the memory associated with the object is recycled.

Definition at line 169 of file Store.h.

Referenced by clang::ento::StoreRef::operator=(), clang::ento::ProgramState::~ProgramState(), and clang::ento::StoreRef::~StoreRef().

StoreRef StoreManager::enterStackFrame ( ProgramStateRef  state,
const LocationContext callerCtx,
const StackFrameContext calleeCtx 
) [virtual]

enterStackFrame - Let the StoreManager to do something when execution engine is about to execute into a callee.

Definition at line 206 of file ProgramState.cpp.

References clang::ento::ProgramState::getStateManager().

virtual SVal clang::ento::StoreManager::evalDerivedToBase ( SVal  derived,
QualType  basePtrType 
) [pure virtual]

Evaluates DerivedToBase casts.

Referenced by clang::ento::ExprEngine::ProcessInitializer(), and clang::ento::ExprEngine::VisitCast().

virtual SVal clang::ento::StoreManager::evalDynamicCast ( SVal  base,
QualType  derivedPtrType,
bool &  Failed 
) [pure virtual]

Evaluates C++ dynamic_cast cast. The callback may result in the following 3 scenarios:

  • Successful cast (ex: derived is subclass of base).
  • Failed cast (ex: derived is definitely not a subclass of base).
  • We don't know (base is a symbolic region and we don't have enough info to determine if the cast will succeed at run time). The function returns an SVal representing the derived class; it's valid only if Failed flag is set to false.

Referenced by clang::ento::ExprEngine::VisitCast().

virtual SVal clang::ento::StoreManager::getBinding ( Store  store,
Loc  loc,
QualType  T = QualType() 
) [pure virtual]

Return the value bound to specified location in a given state.

Parameters:
[in]stateThe analysis state.
[in]locThe symbolic memory location.
[in]TAn optional type that provides a hint indicating the expected type of the returned value. This is used if the value is lazily computed.
Returns:
The value bound to the location loc.
const ElementRegion * StoreManager::GetElementZeroRegion ( const MemRegion R,
QualType  T 
)
virtual StoreRef clang::ento::StoreManager::getInitialStore ( const LocationContext InitLoc) [pure virtual]

getInitialStore - Returns the initial "empty" store representing the value bindings upon entry to an analyzed function.

Loc clang::ento::StoreManager::getLValueCompoundLiteral ( const CompoundLiteralExpr CL,
const LocationContext LC 
) [inline]

Definition at line 97 of file Store.h.

References clang::ento::MemRegionManager::getCompoundLiteralRegion(), and MRMgr.

SVal StoreManager::getLValueElement ( QualType  elementType,
NonLoc  offset,
SVal  Base 
) [virtual]
virtual SVal clang::ento::StoreManager::getLValueField ( const FieldDecl D,
SVal  Base 
) [inline, virtual]

Definition at line 104 of file Store.h.

SVal StoreManager::getLValueIvar ( const ObjCIvarDecl decl,
SVal  base 
) [virtual]

Definition at line 273 of file Store.cpp.

virtual Loc clang::ento::StoreManager::getLValueVar ( const VarDecl VD,
const LocationContext LC 
) [inline, virtual]
MemRegionManager& clang::ento::StoreManager::getRegionManager ( ) [inline]

getRegionManager - Returns the internal RegionManager object that is used to query and manipulate MemRegion objects.

Definition at line 86 of file Store.h.

References MRMgr.

virtual DefinedOrUnknownSVal clang::ento::StoreManager::getSizeInElements ( ProgramStateRef  state,
const MemRegion region,
QualType  EleTy 
) [inline, virtual]

Definition at line 112 of file Store.h.

virtual SubRegionMap* clang::ento::StoreManager::getSubRegionMap ( Store  store) [pure virtual]

getSubRegionMap - Returns an opaque map object that clients can query to get the subregions of a given MemRegion object. It is the

virtual bool clang::ento::StoreManager::includedInBindings ( Store  store,
const MemRegion region 
) const [pure virtual]
virtual void clang::ento::StoreManager::incrementReferenceCount ( Store  store) [inline, virtual]

If the StoreManager supports it, increment the reference count of the specified Store object.

Definition at line 164 of file Store.h.

Referenced by clang::ento::StoreRef::operator=(), clang::ento::ProgramState::ProgramState(), and clang::ento::StoreRef::StoreRef().

ProgramStateRef ProgramState::invalidateRegions ( Store  store,
ArrayRef< const MemRegion * >  Regions,
const Expr E,
unsigned  Count,
const LocationContext LCtx,
InvalidatedSymbols IS,
const CallOrObjCMessage Call,
InvalidatedRegions Invalidated 
) [pure virtual]

invalidateRegions - Clears out the specified regions from the store, marking their values as unknown. Depending on the store, this may also invalidate additional regions that may have changed based on accessing the given regions. Optionally, invalidates non-static globals as well.

Parameters:
[in]storeThe initial store
[in]BeginA pointer to the first region to invalidate.
[in]EndA pointer just past the last region to invalidate.
[in]EThe current statement being evaluated. Used to conjure symbols to mark the values of invalidated regions.
[in]CountThe current block count. Used to conjure symbols to mark the values of invalidated regions.
[in,out]ISA set to fill with any symbols that are no longer accessible. Pass NULL if this information will not be used.
[in]CallThe call expression which will be used to determine which globals should get invalidated.
[in,out]RegionsA vector to fill with any regions being invalidated. This should include any regions explicitly invalidated even if they do not currently have bindings. Pass NULL if this information will not be used.

Definition at line 156 of file ProgramState.cpp.

virtual void clang::ento::StoreManager::iterBindings ( Store  store,
BindingsHandler f 
) [pure virtual]

iterBindings - Iterate over the bindings in the Store.

const MemRegion * StoreManager::MakeElementRegion ( const MemRegion baseRegion,
QualType  pointeeTy,
uint64_t  index = 0 
) [protected]
virtual void clang::ento::StoreManager::print ( Store  store,
raw_ostream &  Out,
const char *  nl,
const char *  sep 
) [pure virtual]
virtual StoreRef clang::ento::StoreManager::Remove ( Store  St,
Loc  L 
) [pure virtual]
ProgramStateRef ProgramStateManager::removeDeadBindings ( Store  store,
const StackFrameContext LCtx,
SymbolReaper SymReaper 
) [pure virtual]

Member Data Documentation

Definition at line 44 of file Store.h.

Referenced by castRegion(), CastRetrievedVal(), GetElementZeroRegion(), and getLValueElement().

MRMgr - Manages region objects associated with this StoreManager.

Definition at line 43 of file Store.h.

Referenced by GetElementZeroRegion(), getLValueCompoundLiteral(), getLValueElement(), getLValueVar(), getRegionManager(), and MakeElementRegion().

Definition at line 40 of file Store.h.

Referenced by castRegion().


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