clang 20.0.0git
Classes | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
clang::ento::StoreManager Class Referenceabstract

#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.
 
virtual std::optional< SValgetDefaultBinding (Store store, const MemRegion *R)=0
 Return the default value bound to a region in a given store.
 
std::optional< SValgetDefaultBinding (nonloc::LazyCompoundVal lcv)
 Return the default value bound to a LazyCompoundVal.
 
virtual StoreRef Bind (Store store, Loc loc, SVal val)=0
 Return a store with the specified value bound to the given location.
 
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.
 
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.
 
virtual StoreRef killBinding (Store ST, Loc L)=0
 Create a new store with the specified binding removed.
 
virtual StoreRef getInitialStore (const LocationContext *InitLoc)=0
 getInitialStore - Returns the initial "empty" store representing the value bindings upon entry to an analyzed function.
 
MemRegionManagergetRegionManager ()
 getRegionManager - Returns the internal RegionManager object that is used to query and manipulate MemRegion objects.
 
SValBuildergetSValBuilder ()
 
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 SVal ArrayToPointer (Loc Array, QualType ElementTy)=0
 ArrayToPointer - Used by ExprEngine::VistCast to handle implicit conversions between arrays and pointers.
 
SVal evalDerivedToBase (SVal Derived, const CastExpr *Cast)
 Evaluates a chain of derived-to-base casts through the path specified in 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.
 
std::optional< SValevalBaseToDerived (SVal Base, QualType DerivedPtrType)
 Attempts to do a down cast.
 
const ElementRegionGetElementZeroRegion (const SubRegion *R, QualType T)
 
std::optional< const MemRegion * > castRegion (const MemRegion *region, QualType CastToTy)
 castRegion - Used by ExprEngine::VisitCast to handle casts from a MemRegion* to a specific location type.
 
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.
 
virtual void decrementReferenceCount (Store store)
 If the StoreManager supports it, decrement the reference count of the specified Store object.
 
virtual StoreRef invalidateRegions (Store store, ArrayRef< SVal > Values, const Stmt *S, unsigned Count, const LocationContext *LCtx, const CallEvent *Call, InvalidatedSymbols &IS, RegionAndSymbolInvalidationTraits &ITraits, InvalidatedRegions *TopLevelRegions, InvalidatedRegions *Invalidated)=0
 invalidateRegions - Clears out the specified regions from the store, marking their values as unknown.
 
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.
 
virtual bool scanReachableSymbols (Store S, const MemRegion *R, ScanReachableSymbols &Visitor)=0
 Finds the transitive closure of symbols within the given region.
 
virtual void printJson (raw_ostream &Out, Store S, const char *NL, unsigned int Space, bool IsDot) const =0
 
virtual void iterBindings (Store store, BindingsHandler &f)=0
 iterBindings - Iterate over the bindings in the Store.
 

Protected Member Functions

 StoreManager (ProgramStateManager &stateMgr)
 
const ElementRegionMakeElementRegion (const SubRegion *baseRegion, QualType pointeeTy, uint64_t index=0)
 

Protected Attributes

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

Detailed Description

Definition at line 53 of file Store.h.

Member Typedef Documentation

◆ InvalidatedRegions

Definition at line 203 of file Store.h.

Constructor & Destructor Documentation

◆ StoreManager()

StoreManager::StoreManager ( ProgramStateManager stateMgr)
protected

Definition at line 42 of file Store.cpp.

◆ ~StoreManager()

virtual clang::ento::StoreManager::~StoreManager ( )
virtualdefault

Member Function Documentation

◆ ArrayToPointer()

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.

◆ Bind()

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

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

Parameters
[in]storeThe store in which to make the binding.
[in]locThe symbolic memory location.
[in]valThe value to bind to location loc.
Returns
A StoreRef object that contains the same bindings as store with the addition of having the value specified by val bound to the location given for loc.

◆ BindDefaultInitial()

virtual StoreRef clang::ento::StoreManager::BindDefaultInitial ( Store  store,
const MemRegion R,
SVal  V 
)
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().

◆ BindDefaultZero()

virtual StoreRef clang::ento::StoreManager::BindDefaultZero ( Store  store,
const MemRegion R 
)
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.

◆ castRegion()

std::optional< const MemRegion * > StoreManager::castRegion ( const MemRegion region,
QualType  CastToTy 
)

◆ decrementReferenceCount()

virtual void clang::ento::StoreManager::decrementReferenceCount ( Store  store)
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 201 of file Store.h.

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

◆ enterStackFrame()

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 46 of file Store.cpp.

References clang::Bind, and clang::Call.

◆ evalBaseToDerived()

std::optional< SVal > StoreManager::evalBaseToDerived ( SVal  Base,
QualType  DerivedPtrType 
)

Attempts to do a down cast.

Used to model BaseToDerived and C++ dynamic_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). The distinction of this case from the next one is necessary to model dynamic_cast.
  • 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 optional with SVal representing the derived class in case of a successful cast and std::nullopt otherwise.

Definition at line 316 of file Store.cpp.

References evalDerivedToBase(), clang::Type::getAsCXXRecordDecl(), clang::ento::MemRegionManager::getCXXDerivedObjectRegion(), getCXXRecordType(), GetElementZeroRegion(), clang::Type::getPointeeCXXRecordDecl(), clang::Type::getPointeeType(), clang::CXXRecordDecl::isDerivedFrom(), clang::QualType::isNull(), clang::Type::isVoidType(), MRMgr,