clang
8.0.0
|
#include "clang/StaticAnalyzer/Core/PathSensitive/Store.h"
Classes | |
class | BindingsHandler |
class | FindUniqueBinding |
Public Types | |
using | InvalidatedRegions = SmallVector< const MemRegion *, 8 > |
Public Member Functions | |
virtual | ~StoreManager ()=default |
virtual SVal | getBinding (Store store, Loc loc, QualType T=QualType())=0 |
Return the value bound to specified location in a given state. More... | |
virtual Optional< SVal > | getDefaultBinding (Store store, const MemRegion *R)=0 |
Return the default value bound to a region in a given store. More... | |
Optional< SVal > | getDefaultBinding (nonloc::LazyCompoundVal lcv) |
Return the default value bound to a LazyCompoundVal. More... | |
virtual StoreRef | Bind (Store store, Loc loc, SVal val)=0 |
Return a store with the specified value bound to the given location. More... | |
virtual StoreRef | BindDefaultInitial (Store store, const MemRegion *R, SVal V)=0 |
Return a store with the specified value bound to all sub-regions of the region. More... | |
virtual StoreRef | BindDefaultZero (Store store, const MemRegion *R)=0 |
Return a store with in which all values within the given region are reset to zero. More... | |
virtual StoreRef | killBinding (Store ST, Loc L)=0 |
Create a new store with the specified binding removed. More... | |
virtual StoreRef | getInitialStore (const LocationContext *InitLoc)=0 |
getInitialStore - Returns the initial "empty" store representing the value bindings upon entry to an analyzed function. More... | |
MemRegionManager & | getRegionManager () |
getRegionManager - Returns the internal RegionManager object that is used to query and manipulate MemRegion objects. More... | |
SValBuilder & | getSValBuilder () |
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 |
ArrayToPointer - Used by ExprEngine::VistCast to handle implicit conversions between arrays and pointers. More... | |
SVal | evalDerivedToBase (SVal Derived, const CastExpr *Cast) |
Evaluates a chain of derived-to-base casts through the path specified in Cast . More... | |
SVal | evalDerivedToBase (SVal Derived, const CXXBasePath &CastPath) |
Evaluates a chain of derived-to-base casts through the specified path. More... | |
SVal | evalDerivedToBase (SVal Derived, QualType DerivedPtrType, bool IsVirtual) |
Evaluates a derived-to-base cast through a single level of derivation. More... | |
SVal | attemptDownCast (SVal Base, QualType DerivedPtrType, bool &Failed) |
Attempts to do a down cast. More... | |
const ElementRegion * | GetElementZeroRegion (const SubRegion *R, QualType T) |
const MemRegion * | castRegion (const MemRegion *region, QualType CastToTy) |
castRegion - Used by ExprEngine::VisitCast to handle casts from a MemRegion* to a specific location type. More... | |
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) |
If the StoreManager supports it, increment the reference count of the specified Store object. More... | |
virtual void | decrementReferenceCount (Store store) |
If the StoreManager supports it, decrement the reference count of the specified Store object. More... | |
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 |
invalidateRegions - Clears out the specified regions from the store, marking their values as unknown. More... | |
StoreRef | 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. More... | |
virtual bool | scanReachableSymbols (Store S, const MemRegion *R, ScanReachableSymbols &Visitor)=0 |
Finds the transitive closure of symbols within the given region. More... | |
virtual void | print (Store store, raw_ostream &Out, const char *nl)=0 |
virtual void | iterBindings (Store store, BindingsHandler &f)=0 |
iterBindings - Iterate over the bindings in the Store. More... | |
Protected Member Functions | |
StoreManager (ProgramStateManager &stateMgr) | |
const ElementRegion * | MakeElementRegion (const SubRegion *baseRegion, QualType pointeeTy, uint64_t index=0) |
SVal | CastRetrievedVal (SVal val, const TypedValueRegion *region, QualType castTy) |
CastRetrievedVal - Used by subclasses of StoreManager to implement implicit casts that arise from loads from regions that are reinterpreted as another region. More... | |
Protected Attributes | |
SValBuilder & | svalBuilder |
ProgramStateManager & | StateMgr |
MemRegionManager & | MRMgr |
MRMgr - Manages region objects associated with this StoreManager. More... | |
ASTContext & | Ctx |
using clang::ento::StoreManager::InvalidatedRegions = SmallVector<const MemRegion *, 8> |
|
protected |
|
virtualdefault |
|
pure virtual |
ArrayToPointer - Used by ExprEngine::VistCast to handle implicit conversions between arrays and pointers.
Referenced by getSizeInElements().
Attempts to do a down cast.
Used to model BaseToDerived and C++ dynamic_cast. The callback may result in the following 3 scenarios:
Definition at line 315 of file Store.cpp.
References clang::Type::getAsCXXRecordDecl(), clang::ento::SVal::getAsRegion(), getCXXRecordType(), clang::Type::getPointeeType(), clang::QualType::isNull(), and clang::Type::isVoidType().
Referenced by getSizeInElements(), and clang::ento::ExprEngine::VisitCast().
Return a store with the specified value bound to the given location.
[in] | store | The store in which to make the binding. |
[in] | loc | The symbolic memory location. |
[in] | val | The value to bind to location loc . |
store
with the addition of having the value specified by val
bound to the location given for loc
. Referenced by enterStackFrame(), and getDefaultBinding().
|
pure virtual |
Return a store with the specified value bound to all sub-regions of the region.
The region must not have previous bindings. If you need to invalidate existing bindings, consider invalidateRegions().
Referenced by getDefaultBinding().
|
pure virtual |
Return a store with in which all values within the given region are reset to zero.
This method is allowed to overwrite previous bindings.
Referenced by getDefaultBinding().
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 75 of file Store.cpp.
References clang::ASTContext::CharTy, Ctx, 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::Type::isBlockPointerType(), clang::ento::MemRegion::isBoundable(), clang::Type::isIncompleteType(), clang::Type::isObjCObjectPointerType(), clang::CharUnits::isZero(), MakeElementRegion(), StateMgr, clang::ento::MemRegion::StripCasts(), and clang::ASTContext::VoidTy.
Referenced by CastRetrievedVal(), clang::ento::SValBuilder::evalCast(), and getSizeInElements().
|
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 400 of file Store.cpp.
References clang::ento::SVal::castAs(), castRegion(), clang::ento::SValBuilder::dispatchCast(), clang::ento::SVal::getAsRegion(), clang::ento::SVal::getAsSymbol(), clang::QualType::getCanonicalType(), clang::ento::MemRegionManager::getFieldRegion(), clang::ento::MemRegionManager::getObjCIvarRegion(), clang::ento::SVal::getSubKind(), clang::ento::SymExpr::getType(), clang::Type::isFloatingType(), clang::QualType::isNull(), clang::Type::isPointerType(), clang::ento::SVal::isUnknownOrUndef(), clang::Type::isVoidPointerType(), MRMgr, and svalBuilder.
Referenced by clang::ento::StoreManager::FindUniqueBinding::getRegion().
|
inlinevirtual |
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 208 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 47 of file Store.cpp.
References Bind(), clang::ento::CallEvent::getInitialStackFrameContents(), and clang::ento::StoreRef::getStore().
Evaluates a chain of derived-to-base casts through the path specified in Cast
.
Definition at line 249 of file Store.cpp.
References clang::Type::getAsCXXRecordDecl(), clang::ento::SVal::getAsRegion(), clang::ento::MemRegionManager::getCXXBaseObjectRegion(), clang::Type::getPointeeCXXRecordDecl(), clang::CastExpr::getSubExpr(), clang::Expr::getType(), MRMgr, clang::CastExpr::path_begin(), clang::CastExpr::path_end(), and regionMatchesCXXRecordType().
Referenced by clang::ento::ExprEngine::getInitialState(), getSizeInElements(), clang::ento::ExprEngine::ProcessBaseDtor(), clang::ento::ExprEngine::VisitCast(), and clang::ento::ExprEngine::VisitCXXConstructExpr().
SVal clang::ento::StoreManager::evalDerivedToBase | ( | SVal | Derived, |
const CXXBasePath & | CastPath | ||
) |
Evaluates a chain of derived-to-base casts through the specified path.
SVal clang::ento::StoreManager::evalDerivedToBase | ( | SVal | Derived, |
QualType | DerivedPtrType, | ||
bool | IsVirtual | ||
) |
Evaluates a derived-to-base cast through a single level of derivation.
|
pure virtual |
Return the value bound to specified location in a given state.
[in] | store | The store in which to make the lookup. |
[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
.
|
pure virtual |
Return the default value bound to a region in a given store.
The default binding is the value of sub-regions that were not initialized separately from their base region. For example, if the structure is zero-initialized upon construction, this method retrieves the concrete zero value, even if some or all fields were later overwritten manually. Default binding may be an unknown, undefined, concrete, or symbolic value.
[in] | store | The store in which to make the lookup. |
[in] | R | The region to find the default binding for. |
Referenced by getDefaultBinding().
|
inline |
Return the default value bound to a LazyCompoundVal.
The default binding is used to represent the value of any fields or elements within the structure represented by the LazyCompoundVal which were not initialized explicitly separately from the whole structure. Default binding may be an unknown, undefined, concrete, or symbolic value.
[in] | lcv | The lazy compound value. |
lcv
, if a default binding exists. Definition at line 97 of file Store.h.
References Bind(), BindDefaultInitial(), BindDefaultZero(), getDefaultBinding(), getInitialStore(), clang::ento::nonloc::LazyCompoundVal::getRegion(), clang::ento::nonloc::LazyCompoundVal::getStore(), and killBinding().
const ElementRegion * StoreManager::GetElementZeroRegion | ( | const SubRegion * | R, |
QualType | T | ||
) |
Definition at line 68 of file Store.cpp.
References Ctx, clang::ento::MemRegionManager::getElementRegion(), clang::QualType::isNull(), clang::ento::SValBuilder::makeZeroArrayIndex(), MRMgr, and svalBuilder.
Referenced by getSizeInElements(), clang::ento::ExprEngine::ProcessDeleteDtor(), and clang::ento::ExprEngine::VisitCXXNewExpr().
|
pure virtual |
getInitialStore - Returns the initial "empty" store representing the value bindings upon entry to an analyzed function.
Referenced by getDefaultBinding().
|
inline |
Definition at line 139 of file Store.h.
References clang::ast_matchers::decl, clang::ento::MemRegionManager::getCompoundLiteralRegion(), and getLValueIvar().
Definition at line 478 of file Store.cpp.
References clang::ento::SVal::castAs(), clang::ento::SValBuilder::convertToArrayIndex(), Ctx, clang::ento::SVal::getAs(), clang::ento::SValBuilder::getBasicValueFactory(), clang::ento::MemRegionManager::getElementRegion(), getValue(), clang::ento::SVal::isUnknownOrUndef(), MRMgr, clang::ento::MemRegion::StripCasts(), svalBuilder, and clang::ento::StoreManager::BindingsHandler::~BindingsHandler().
Referenced by getLValueField().
|
inlinevirtual |
Definition at line 146 of file Store.h.
References getLValueElement().
Referenced by clang::ento::ExprEngine::getInitialState(), and clang::ento::ProgramState::getLValue().
|
virtual |
Definition at line 474 of file Store.cpp.
Referenced by getLValueCompoundLiteral().
|
inlinevirtual |
Definition at line 135 of file Store.h.
References clang::ento::MemRegionManager::getVarRegion(), and clang::ento::SValBuilder::makeLoc().
|
inline |
|
inlinevirtual |
Definition at line 154 of file Store.h.
References ArrayToPointer(), attemptDownCast(), castRegion(), evalDerivedToBase(), GetElementZeroRegion(), includedInBindings(), and removeDeadBindings().
Referenced by clang::ento::mpi::MPIChecker::checkMissingWaits().
|
inline |
Definition at line 133 of file Store.h.
References svalBuilder.
|
pure virtual |
Referenced by getSizeInElements().
|
inlinevirtual |
If the StoreManager supports it, increment the reference count of the specified Store object.
Definition at line 203 of file Store.h.
Referenced by clang::ento::StoreRef::operator=(), clang::ento::ProgramState::ProgramState(), and clang::ento::StoreRef::StoreRef().
|
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. |
|
pure virtual |
iterBindings - Iterate over the bindings in the Store.
Referenced by clang::ento::StoreManager::FindUniqueBinding::getRegion().
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. |
Referenced by getDefaultBinding().
|
protected |
Definition at line 61 of file Store.cpp.
References clang::ento::SValBuilder::getContext(), clang::ento::MemRegionManager::getElementRegion(), clang::ento::SValBuilder::makeArrayIndex(), MRMgr, and svalBuilder.
Referenced by castRegion(), and clang::ento::StoreManager::FindUniqueBinding::getRegion().
|
pure virtual |
|
pure virtual |
Referenced by getSizeInElements().
|
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().
|
protected |
Definition at line 61 of file Store.h.
Referenced by castRegion(), GetElementZeroRegion(), and getLValueElement().
|
protected |
MRMgr - Manages region objects associated with this StoreManager.
Definition at line 60 of file Store.h.
Referenced by CastRetrievedVal(), evalDerivedToBase(), GetElementZeroRegion(), getLValueElement(), getRegionManager(), and MakeElementRegion().
|
protected |
Definition at line 57 of file Store.h.
Referenced by castRegion().
|
protected |
Definition at line 56 of file Store.h.
Referenced by CastRetrievedVal(), GetElementZeroRegion(), getLValueElement(), getSValBuilder(), and MakeElementRegion().