21 using namespace clang;
25 : svalBuilder(stateMgr.getSValBuilder()), StateMgr(stateMgr),
26 MRMgr(svalBuilder.getRegionManager()), Ctx(stateMgr.getContext()) {}
36 for (CallEvent::BindingsTy::iterator I = InitialBindings.begin(),
37 E = InitialBindings.end();
76 if (isa<CodeTextRegion>(R) || isa<SymbolicRegion>(R))
97 if (CanonPointeeTy == ObjTy)
103 case MemRegion::CXXThisRegionKind:
104 case MemRegion::CodeSpaceRegionKind:
105 case MemRegion::StackLocalsSpaceRegionKind:
106 case MemRegion::StackArgumentsSpaceRegionKind:
107 case MemRegion::HeapSpaceRegionKind:
108 case MemRegion::UnknownSpaceRegionKind:
109 case MemRegion::StaticGlobalSpaceRegionKind:
110 case MemRegion::GlobalInternalSpaceRegionKind:
111 case MemRegion::GlobalSystemSpaceRegionKind:
112 case MemRegion::GlobalImmutableSpaceRegionKind: {
113 llvm_unreachable(
"Invalid region cast");
116 case MemRegion::FunctionCodeRegionKind:
117 case MemRegion::BlockCodeRegionKind:
118 case MemRegion::BlockDataRegionKind:
119 case MemRegion::StringRegionKind:
121 case MemRegion::SymbolicRegionKind:
122 case MemRegion::AllocaRegionKind:
123 case MemRegion::CompoundLiteralRegionKind:
124 case MemRegion::FieldRegionKind:
125 case MemRegion::ObjCIvarRegionKind:
126 case MemRegion::ObjCStringRegionKind:
127 case MemRegion::VarRegionKind:
128 case MemRegion::CXXTempObjectRegionKind:
129 case MemRegion::CXXBaseObjectRegionKind:
132 case MemRegion::ElementRegionKind: {
154 const MemRegion *baseR = rawOff.getRegion();
170 if (CanonPointeeTy == ObjTy)
185 int64_t newIndex = 0;
192 if (!pointeeTySize.
isZero()) {
196 if (off % pointeeTySize == 0) {
197 newIndex = off / pointeeTySize;
214 llvm_unreachable(
"unreachable");
244 SVal Result = Derived;
255 SVal Result = Derived;
256 for (CXXBasePath::const_iterator I = Path.begin(), E = Path.end();
259 I->Base->isVirtual());
274 assert(BaseDecl &&
"not a C++ object?");
277 BaseDecl, cast<SubRegion>(DerivedRegVal->getRegion()), IsVirtual);
290 return TVR->getValueType()->getAsCXXRecordDecl();
292 return SR->getSymbol()->getType()->getPointeeCXXRecordDecl();
306 assert(!TargetType.
isNull());
308 if (!TargetClass && !TargetType->
isVoidType())
315 if (MRClass == TargetClass)
321 if (!TargetType->
isVoidType() && MRClass->hasDefinition()) {
326 if (MRClass->isDerivedFrom(TargetClass, Paths))
332 MR = BaseR->getSuperRegion();
349 if (Uncasted == MR) {
360 Failed = isa<TypedValueRegion>(MR);
369 QualType castTy,
bool performTestOnly) {
376 if (performTestOnly) {
397 case loc::MemRegionValKind:
401 case loc::GotoLabelKind:
405 case loc::ConcreteIntKind:
419 llvm_unreachable(
"Unhandled Base.");
431 return getLValueFieldOrIvar(decl, base);
475 const llvm::APSInt &BaseIdxI =
482 if (isa<ElementRegion>(BaseRegion->
StripCasts()))
490 assert(BaseIdxI.isSigned());
509 if (!SymV || SymV != Sym)
SVal attemptDownCast(SVal Base, QualType DerivedPtrType, bool &Failed)
Attempts to do a down cast.
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.
A (possibly-)qualified type.
MemRegion - The root abstract class for all memory regions.
bool isBlockPointerType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Decl - This represents one declaration (or definition), e.g.
virtual QualType getValueType() const =0
const void * Store
Store - This opaque type encapsulates an immutable mapping from locations to values.
bool isZero() const
isZero - Test whether the quantity equals zero.
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 ObjCIvarRegion * getObjCIvarRegion(const ObjCIvarDecl *ivd, const SubRegion *superRegion)
getObjCIvarRegion - Retrieve or create the memory region associated with a specified Objective-c inst...
const CXXBaseSpecifier *const * path_const_iterator
SymbolRef getAsLocSymbol(bool IncludeBaseRegions=false) const
If this SVal is a location and wraps a symbol, return that SymbolRef.
const T * getAs() const
Member-template getAs<specific type>'.
virtual SVal dispatchCast(SVal val, QualType castTy)=0
NonLoc makeArrayIndex(uint64_t idx)
const ElementRegion * GetElementZeroRegion(const SubRegion *R, QualType T)
QualType getLocalUnqualifiedType() const
Return this type with all of the instance-specific qualifiers removed, but without removing any quali...
const MemRegion * castRegion(const MemRegion *region, QualType CastToTy)
castRegion - Used by ExprEngine::VisitCast to handle casts from a MemRegion* to a specific location t...
const MemRegion * getSuperRegion() const
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)
CharUnits - This is an opaque type for sizes expressed in character units.
path_iterator path_begin()
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
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...
virtual SVal getLValueIvar(const ObjCIvarDecl *decl, SVal base)
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
unsigned getSubKind() const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
SymbolicRegion - A special, "non-concrete" region.
const FunctionProtoType * T
SValBuilder & svalBuilder
const CXXRecordDecl * getPointeeCXXRecordDecl() const
If this is a pointer or reference to a RecordType, return the CXXRecordDecl that that type refers to...
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
static SVal getValue(SVal val, SValBuilder &svalBuilder)
ProgramStateManager & StateMgr
virtual StoreRef Bind(Store store, Loc loc, SVal val)=0
Return a store with the specified value bound to the given location.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
NonLoc makeZeroArrayIndex()
Optional< T > getAs() const
Convert to the specified SVal type, returning None if this SVal is not of the desired type...
virtual bool isBoundable() const
const MemRegion * StripCasts(bool StripBaseCasts=true) const
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...
const MemRegion * getAsRegion() const
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...
bool isObjCObjectPointerType() const
virtual ~BindingsHandler()
RegionRawOffset getAsArrayOffset() const
Compute the offset within the array. The array might also be a subobject.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
const CXXBaseObjectRegion * getCXXBaseObjectRegion(const CXXRecordDecl *BaseClass, const SubRegion *Super, bool IsVirtual)
Create a CXXBaseObjectRegion with the given base class for region Super.
Dataflow Directional Tag Classes.
const ElementRegion * getElementRegion(QualType elementType, NonLoc Idx, const SubRegion *superRegion, ASTContext &Ctx)
getElementRegion - Retrieve the memory region associated with the associated element type...
Represents an abstract call to a function or method along a particular path.
SVal convertToArrayIndex(SVal val)
ASTContext & getContext()
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
BasicValueFactory & getBasicValueFactory()
SubRegion - A region that subsets another larger region.
const ElementRegion * MakeElementRegion(const SubRegion *baseRegion, QualType pointeeTy, uint64_t index=0)
Base for LValueReferenceType and RValueReferenceType.
MemRegionManager & MRMgr
MRMgr - Manages region objects associated with this StoreManager.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
virtual SVal getLValueElement(QualType elementType, NonLoc offset, SVal Base)
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
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.
ObjCIvarDecl - Represents an ObjC instance variable.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
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...
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
StoreManager(ProgramStateManager &stateMgr)
const FieldRegion * getFieldRegion(const FieldDecl *fd, const SubRegion *superRegion)
getFieldRegion - Retrieve or create the memory region associated with a specified FieldDecl...
bool isUnknownOrUndef() const