21 using namespace clang;
25 : svalBuilder(stateMgr.getSValBuilder()), StateMgr(stateMgr),
26 MRMgr(svalBuilder.getRegionManager()), Ctx(stateMgr.getContext()) {}
37 E = InitialBindings.end();
75 if (isa<CodeTextRegion>(R) || isa<SymbolicRegion>(R))
96 if (CanonPointeeTy == ObjTy)
102 case MemRegion::CXXThisRegionKind:
103 case MemRegion::CodeSpaceRegionKind:
104 case MemRegion::StackLocalsSpaceRegionKind:
105 case MemRegion::StackArgumentsSpaceRegionKind:
106 case MemRegion::HeapSpaceRegionKind:
107 case MemRegion::UnknownSpaceRegionKind:
108 case MemRegion::StaticGlobalSpaceRegionKind:
109 case MemRegion::GlobalInternalSpaceRegionKind:
110 case MemRegion::GlobalSystemSpaceRegionKind:
111 case MemRegion::GlobalImmutableSpaceRegionKind: {
112 llvm_unreachable(
"Invalid region cast");
115 case MemRegion::FunctionCodeRegionKind:
116 case MemRegion::BlockCodeRegionKind:
117 case MemRegion::BlockDataRegionKind:
118 case MemRegion::StringRegionKind:
120 case MemRegion::SymbolicRegionKind:
121 case MemRegion::AllocaRegionKind:
122 case MemRegion::CompoundLiteralRegionKind:
123 case MemRegion::FieldRegionKind:
124 case MemRegion::ObjCIvarRegionKind:
125 case MemRegion::ObjCStringRegionKind:
126 case MemRegion::VarRegionKind:
127 case MemRegion::CXXTempObjectRegionKind:
128 case MemRegion::CXXBaseObjectRegionKind:
131 case MemRegion::ElementRegionKind: {
153 const MemRegion *baseR = rawOff.getRegion();
169 if (CanonPointeeTy == ObjTy)
184 int64_t newIndex = 0;
191 if (!pointeeTySize.
isZero()) {
195 if (off % pointeeTySize == 0) {
196 newIndex = off / pointeeTySize;
212 llvm_unreachable(
"unreachable");
254 for (CXXBasePath::const_iterator
I = Path.begin(),
E = Path.end();
257 I->Base->isVirtual());
272 assert(BaseDecl &&
"not a C++ object?");
289 return TVR->getValueType()->getAsCXXRecordDecl();
291 return SR->getSymbol()->getType()->getPointeeCXXRecordDecl();
305 assert(!TargetType.
isNull());
307 if (!TargetClass && !TargetType->
isVoidType())
314 if (MRClass == TargetClass)
320 if (!TargetType->
isVoidType() && MRClass->hasDefinition()) {
325 if (MRClass->isDerivedFrom(TargetClass, Paths))
331 MR = BaseR->getSuperRegion();
348 if (Uncasted == MR) {
359 Failed = isa<TypedValueRegion>(MR);
368 QualType castTy,
bool performTestOnly) {
375 if (performTestOnly) {
396 case loc::MemRegionValKind:
400 case loc::GotoLabelKind:
404 case loc::ConcreteIntKind:
412 llvm_unreachable(
"Unhandled Base.");
424 return getLValueFieldOrIvar(decl, base);
464 const llvm::APSInt &BaseIdxI =
471 if (isa<ElementRegion>(BaseRegion->
StripCasts()))
480 assert(BaseIdxI.isSigned());
499 if (!SymV || SymV != Sym)
TypedValueRegion - An abstract class representing regions having a typed value.
SVal evalDerivedToBase(SVal Derived, const CastExpr *Cast)
Evaluates a chain of derived-to-base casts through the path specified in Cast.
SVal evalDynamicCast(SVal Base, QualType DerivedPtrType, bool &Failed)
Evaluates C++ dynamic_cast cast.
A (possibly-)qualified type.
MemRegion - The root abstract class for all memory regions.
const FieldRegion * getFieldRegion(const FieldDecl *fd, const MemRegion *superRegion)
getFieldRegion - Retrieve or create the memory region associated with a specified FieldDecl...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
virtual QualType getValueType() const =0
virtual bool isBoundable() const
const void * Store
Store - This opaque type encapsulates an immutable mapping from locations to values.
const MemRegion * MakeElementRegion(const MemRegion *baseRegion, QualType pointeeTy, uint64_t index=0)
bool isBlockPointerType() const
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
Value representing integer constant.
const CXXBaseSpecifier *const * path_const_iterator
virtual SVal dispatchCast(SVal val, QualType castTy)=0
NonLoc makeArrayIndex(uint64_t idx)
const MemRegion * castRegion(const MemRegion *region, QualType CastToTy)
castRegion - Used by ExprEngine::VisitCast to handle casts from a MemRegion* to a specific location t...
bool HandleBinding(StoreManager &SMgr, Store store, const MemRegion *R, SVal val) override
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
static bool regionMatchesCXXRecordType(SVal V, QualType Ty)
SymbolRef getAsLocSymbol(bool IncludeBaseRegions=false) const
If this SVal is a location and wraps a symbol, return that SymbolRef.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
const ObjCIvarRegion * getObjCIvarRegion(const ObjCIvarDecl *ivd, const MemRegion *superRegion)
getObjCIvarRegion - Retrieve or create the memory region associated with a specified Objective-c inst...
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that that type refers to...
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
RegionRawOffset getAsArrayOffset() const
Compute the offset within the array. The array might also be a subobject.
CharUnits - This is an opaque type for sizes expressed in character units.
path_iterator path_begin()
bool isUnknownOrUndef() const
CXXRecordDecl * getCanonicalDecl() override
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
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...
detail::InMemoryDirectory::const_iterator I
const CXXBaseObjectRegion * getCXXBaseObjectRegion(const CXXRecordDecl *BaseClass, const MemRegion *Super, bool IsVirtual)
Create a CXXBaseObjectRegion with the given base class for region Super.
const MemRegion * getSuperRegion() const
virtual SVal getLValueIvar(const ObjCIvarDecl *decl, SVal base)
const MemRegion * StripCasts(bool StripBaseCasts=true) const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
SymbolicRegion - A special, "non-concrete" region.
SValBuilder & svalBuilder
const ElementRegion * getElementRegion(QualType elementType, NonLoc Idx, const MemRegion *superRegion, ASTContext &Ctx)
getElementRegion - Retrieve the memory region associated with the associated element type...
const ElementRegion * GetElementZeroRegion(const MemRegion *R, QualType T)
Optional< T > getAs() const
Convert to the specified SVal type, returning None if this SVal is not of the desired type...
static SVal getValue(SVal val, SValBuilder &svalBuilder)
ProgramStateManager & StateMgr
virtual StoreRef Bind(Store store, Loc loc, SVal val)=0
Return a state with the specified value bound to the given location.
The result type of a method or function.
NonLoc makeZeroArrayIndex()
const TemplateArgument * iterator
virtual void getInitialStackFrameContents(const StackFrameContext *CalleeCtx, BindingsTy &Bindings) const =0
Populates the given SmallVector with the bindings in the callee's stack frame at the start of this ca...
SVal CastRetrievedVal(SVal val, const TypedValueRegion *region, QualType castTy, bool performTestOnly=true)
CastRetrievedVal - Used by subclasses of StoreManager to implement implicit casts that arise from loa...
ASTContext & getContext()
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
virtual ~BindingsHandler()
unsigned getSubKind() const
bool isZero() const
isZero - Test whether the quantity equals zero.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
detail::InMemoryDirectory::const_iterator E
const MemRegion * getAsRegion() const
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
Represents an abstract call to a function or method along a particular path.
SVal convertToArrayIndex(SVal val)
ASTContext & getContext()
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
const T * getAs() const
Member-template getAs<specific type>'.
BasicValueFactory & getBasicValueFactory()
Base for LValueReferenceType and RValueReferenceType.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
MemRegionManager & MRMgr
MRMgr - Manages region objects associated with this StoreManager.
virtual SVal getLValueElement(QualType elementType, NonLoc offset, SVal Base)
static const CXXRecordDecl * getCXXRecordType(const MemRegion *MR)
Returns the static type of the given region, if it represents a C++ class object. ...
Represents a C++ struct/union/class.
bool isObjCObjectPointerType() const
ObjCIvarDecl - Represents an ObjC instance variable.
virtual StoreRef BindDefault(Store store, const MemRegion *R, SVal V)
ElementRegin is used to represent both array elements and casts.
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
StoreManager(ProgramStateManager &stateMgr)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.