clang API Documentation
#include <Store.h>
Classes | |
class | BindingsHandler |
class | FindUniqueBinding |
Public Types | |
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 | killBinding (Store ST, Loc L)=0 |
Create a new store with the specified binding removed. | |
virtual StoreRef | getInitialStore (const LocationContext *InitLoc)=0 |
MemRegionManager & | getRegionManager () |
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, QualType ElementTy)=0 |
SVal | evalDerivedToBase (SVal Derived, const CastExpr *Cast) |
SVal | evalDerivedToBase (SVal Derived, const CXXBasePath &CastPath) |
Evaluates a chain of derived-to-base casts through the specified path. | |
SVal | evalDerivedToBase (SVal Derived, QualType DerivedPtrType, bool IsVirtual) |
Evaluates a derived-to-base cast through a single level of derivation. | |
SVal | evalDynamicCast (SVal Base, QualType DerivedPtrType, bool &Failed) |
Evaluates C++ dynamic_cast cast. The callback may result in the following 3 scenarios: | |
const ElementRegion * | GetElementZeroRegion (const MemRegion *R, QualType T) |
const MemRegion * | castRegion (const MemRegion *region, QualType CastToTy) |
virtual StoreRef | removeDeadBindings (Store store, const StackFrameContext *LCtx, SymbolReaper &SymReaper)=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< SVal > Values, const Expr *E, unsigned Count, const LocationContext *LCtx, const CallEvent *Call, InvalidatedSymbols &IS, RegionAndSymbolInvalidationTraits &ITraits, InvalidatedRegions *InvalidatedTopLevel, InvalidatedRegions *Invalidated)=0 |
StoreRef | enterStackFrame (Store store, const CallEvent &Call, const StackFrameContext *CalleeCtx) |
virtual bool | scanReachableSymbols (Store S, const MemRegion *R, ScanReachableSymbols &Visitor)=0 |
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 MemRegion * | MakeElementRegion (const MemRegion *baseRegion, QualType pointeeTy, uint64_t index=0) |
SVal | CastRetrievedVal (SVal val, const TypedValueRegion *region, QualType castTy, bool performTestOnly=true) |
Protected Attributes | |
SValBuilder & | svalBuilder |
ProgramStateManager & | StateMgr |
MemRegionManager & | MRMgr |
MRMgr - Manages region objects associated with this StoreManager. | |
ASTContext & | Ctx |
typedef SmallVector<const MemRegion *, 8> clang::ento::StoreManager::InvalidatedRegions |
StoreManager::StoreManager | ( | ProgramStateManager & | stateMgr | ) | [protected] |
virtual clang::ento::StoreManager::~StoreManager | ( | ) | [inline, virtual] |
virtual SVal clang::ento::StoreManager::ArrayToPointer | ( | Loc | Array, |
QualType | ElementTy | ||
) | [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.
[in] | store | The analysis state. |
[in] | loc | The symbolic memory location. |
[in] | val | The value to bind to location loc . |
state
with the addition of having the value specified by val
bound to the location given for loc
. Referenced by enterStackFrame().
StoreRef StoreManager::BindDefault | ( | Store | store, |
const MemRegion * | R, | ||
SVal | V | ||
) | [virtual] |
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 62 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::Type::getPointeeType(), clang::CharUnits::getQuantity(), clang::ASTContext::getTypeSizeInChars(), clang::ento::MemRegion::GlobalImmutableSpaceRegionKind, clang::ento::MemRegion::GlobalInternalSpaceRegionKind, clang::ento::MemRegion::GlobalSystemSpaceRegionKind, clang::ento::MemRegion::HeapSpaceRegionKind, clang::Type::isBlockPointerType(), clang::ento::MemRegion::isBoundable(), clang::Type::isIncompleteType(), clang::Type::isObjCObjectPointerType(), clang::CharUnits::isZero(), MakeElementRegion(), 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 367 of file Store.cpp.
References Ctx, clang::ento::SValBuilder::dispatchCast(), clang::Type::getAs(), 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 157 of file Store.h.
Referenced by clang::ento::StoreRef::operator=(), clang::ento::ProgramState::~ProgramState(), and clang::ento::StoreRef::~StoreRef().
StoreRef StoreManager::enterStackFrame | ( | Store | store, |
const CallEvent & | Call, | ||
const StackFrameContext * | CalleeCtx | ||
) |
enterStackFrame - Let the StoreManager to do something when execution engine is about to execute into a callee.
Definition at line 28 of file Store.cpp.
References Bind(), clang::ento::CallEvent::getInitialStackFrameContents(), and clang::ento::StoreRef::getStore().
SVal StoreManager::evalDerivedToBase | ( | SVal | Derived, |
const CastExpr * | Cast | ||
) |
Evaluates a chain of derived-to-base casts through the path specified in Cast
.
Definition at line 235 of file Store.cpp.
References clang::CastExpr::getSubExpr(), clang::Expr::getType(), clang::CastExpr::path_begin(), clang::CastExpr::path_end(), and regionMatchesCXXRecordType().
Referenced by adjustReturnValue(), evalDerivedToBase(), evalDynamicCast(), clang::ento::ExprEngine::ProcessBaseDtor(), clang::ento::ExprEngine::VisitCast(), and clang::ento::ExprEngine::VisitCXXConstructExpr().
SVal StoreManager::evalDerivedToBase | ( | SVal | Derived, |
const CXXBasePath & | CastPath | ||
) |
Evaluates a chain of derived-to-base casts through the specified path.
Definition at line 251 of file Store.cpp.
References evalDerivedToBase().
SVal StoreManager::evalDerivedToBase | ( | SVal | Derived, |
QualType | DerivedPtrType, | ||
bool | IsVirtual | ||
) |
Evaluates a derived-to-base cast through a single level of derivation.
Definition at line 262 of file Store.cpp.
References clang::ento::SVal::getAs(), clang::Type::getAsCXXRecordDecl(), clang::ento::MemRegionManager::getCXXBaseObjectRegion(), clang::Type::getPointeeCXXRecordDecl(), and MRMgr.
SVal StoreManager::evalDynamicCast | ( | SVal | Base, |
QualType | DerivedPtrType, | ||
bool & | Failed | ||
) |
Evaluates C++ dynamic_cast cast. The callback may result in the following 3 scenarios:
Definition at line 295 of file Store.cpp.
References evalDerivedToBase(), clang::CXXBasePaths::front(), clang::Type::getAsCXXRecordDecl(), clang::ento::SVal::getAsRegion(), getCXXRecordType(), clang::Type::getPointeeType(), clang::QualType::isNull(), clang::Type::isVoidType(), and clang::ento::MemRegion::StripCasts().
Referenced by clang::CXXInstanceCall::getInitialStackFrameContents(), and 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.
[in] | store | The analysis state. |
[in] | loc | The symbolic memory location. |
[in] | T | An optional type that provides a hint indicating the expected type of the returned value. This is used if the value is lazily computed. |
loc
. Referenced by getAsPointeeSymbol().
const ElementRegion * StoreManager::GetElementZeroRegion | ( | const MemRegion * | R, |
QualType | T | ||
) |
Definition at line 55 of file Store.cpp.
References Ctx, clang::ento::MemRegionManager::getElementRegion(), clang::QualType::isNull(), clang::ento::SValBuilder::makeZeroArrayIndex(), MRMgr, and svalBuilder.
Referenced by clang::ento::ExprEngine::VisitCXXNewExpr().
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 91 of file Store.h.
References clang::ento::MemRegionManager::getCompoundLiteralRegion(), and MRMgr.
SVal StoreManager::getLValueElement | ( | QualType | elementType, |
NonLoc | offset, | ||
SVal | Base | ||
) | [virtual] |
Definition at line 427 of file Store.cpp.
References clang::CodeGen::Base, clang::ento::SVal::castAs(), clang::ento::SValBuilder::convertToArrayIndex(), Ctx, clang::ento::SVal::getAs(), clang::ento::SValBuilder::getBasicValueFactory(), clang::ento::MemRegionManager::getElementRegion(), clang::ento::ElementRegion::getIndex(), clang::ento::SubRegion::getSuperRegion(), getValue(), clang::ento::SVal::isUnknownOrUndef(), MRMgr, clang::ento::MemRegion::StripCasts(), and svalBuilder.
virtual SVal clang::ento::StoreManager::getLValueField | ( | const FieldDecl * | D, |
SVal | Base | ||
) | [inline, virtual] |
Definition at line 98 of file Store.h.
Referenced by clang::ento::ProgramState::getLValue().
SVal StoreManager::getLValueIvar | ( | const ObjCIvarDecl * | decl, |
SVal | base | ||
) | [virtual] |
virtual Loc clang::ento::StoreManager::getLValueVar | ( | const VarDecl * | VD, |
const LocationContext * | LC | ||
) | [inline, virtual] |
Definition at line 87 of file Store.h.
References clang::ento::MemRegionManager::getVarRegion(), clang::ento::SValBuilder::makeLoc(), MRMgr, and svalBuilder.
MemRegionManager& clang::ento::StoreManager::getRegionManager | ( | ) | [inline] |
virtual DefinedOrUnknownSVal clang::ento::StoreManager::getSizeInElements | ( | ProgramStateRef | state, |
const MemRegion * | region, | ||
QualType | EleTy | ||
) | [inline, virtual] |
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 152 of file Store.h.
Referenced by clang::ento::StoreRef::operator=(), clang::ento::ProgramState::ProgramState(), and clang::ento::StoreRef::StoreRef().
virtual StoreRef clang::ento::StoreManager::invalidateRegions | ( | Store | store, |
ArrayRef< SVal > | Values, | ||
const Expr * | E, | ||
unsigned | Count, | ||
const LocationContext * | LCtx, | ||
const CallEvent * | Call, | ||
InvalidatedSymbols & | IS, | ||
RegionAndSymbolInvalidationTraits & | ITraits, | ||
InvalidatedRegions * | InvalidatedTopLevel, | ||
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.
[in] | store | The initial store |
[in] | Values | The values to invalidate. |
[in] | E | The current statement being evaluated. Used to conjure symbols to mark the values of invalidated regions. |
[in] | Count | The current block count. Used to conjure symbols to mark the values of invalidated regions. |
[in] | Call | The call expression which will be used to determine which globals should get invalidated. |
[in,out] | IS | A set to fill with any symbols that are no longer accessible. Pass NULL if this information will not be used. |
[in] | ITraits | Information about invalidation for a particular region/symbol. |
[in,out] | InvalidatedTopLevel | A vector to fill with regions explicitly being invalidated. Pass NULL if this information will not be used. |
[in,out] | Invalidated | A 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. |
virtual void clang::ento::StoreManager::iterBindings | ( | Store | store, |
BindingsHandler & | f | ||
) | [pure virtual] |
iterBindings - Iterate over the bindings in the Store.
virtual StoreRef clang::ento::StoreManager::killBinding | ( | Store | ST, |
Loc | L | ||
) | [pure virtual] |
Create a new store with the specified binding removed.
ST | the original store, that is the basis for the new store. |
L | the location whose binding should be removed. |
const MemRegion * StoreManager::MakeElementRegion | ( | const MemRegion * | baseRegion, |
QualType | pointeeTy, | ||
uint64_t | index = 0 |
||
) | [protected] |
Definition at line 45 of file Store.cpp.
References clang::ento::SValBuilder::getContext(), clang::ento::MemRegionManager::getElementRegion(), clang::ento::SValBuilder::makeArrayIndex(), MRMgr, and svalBuilder.
Referenced by castRegion().
virtual void clang::ento::StoreManager::print | ( | Store | store, |
raw_ostream & | Out, | ||
const char * | nl, | ||
const char * | sep | ||
) | [pure virtual] |
Referenced by clang::ento::ProgramState::print().
virtual StoreRef clang::ento::StoreManager::removeDeadBindings | ( | Store | store, |
const StackFrameContext * | LCtx, | ||
SymbolReaper & | SymReaper | ||
) | [pure virtual] |
virtual bool clang::ento::StoreManager::scanReachableSymbols | ( | Store | S, |
const MemRegion * | R, | ||
ScanReachableSymbols & | Visitor | ||
) | [pure virtual] |
Finds the transitive closure of symbols within the given region.
Returns false if the visitor aborted the scan.
Referenced by clang::ento::ScanReachableSymbols::scan().
ASTContext& clang::ento::StoreManager::Ctx [protected] |
Definition at line 47 of file Store.h.
Referenced by castRegion(), CastRetrievedVal(), GetElementZeroRegion(), and getLValueElement().
MemRegionManager& clang::ento::StoreManager::MRMgr [protected] |
MRMgr - Manages region objects associated with this StoreManager.
Definition at line 46 of file Store.h.
Referenced by evalDerivedToBase(), GetElementZeroRegion(), getLValueCompoundLiteral(), getLValueElement(), getLValueVar(), getRegionManager(), and MakeElementRegion().
ProgramStateManager& clang::ento::StoreManager::StateMgr [protected] |
Definition at line 43 of file Store.h.
Referenced by castRegion().
SValBuilder& clang::ento::StoreManager::svalBuilder [protected] |
Definition at line 42 of file Store.h.
Referenced by CastRetrievedVal(), GetElementZeroRegion(), getLValueElement(), getLValueVar(), and MakeElementRegion().