15#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_MEMREGION_H
16#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_MEMREGION_H
31#include "llvm/ADT/DenseMap.h"
32#include "llvm/ADT/FoldingSet.h"
33#include "llvm/ADT/PointerIntPair.h"
34#include "llvm/Support/Allocator.h"
35#include "llvm/Support/Casting.h"
45class AnalysisDeclContext;
49class StackFrameContext;
55class MemRegionManager;
72 static const int64_t
Symbolic = std::numeric_limits<int64_t>::max();
98#define REGION(Id, Parent) Id ## Kind,
99#define REGION_RANGE(Id, First, Last) BEGIN_##Id = First, END_##Id = Last,
100#include "clang/StaticAnalyzer/Core/PathSensitive/Regions.def"
105 mutable std::optional<RegionOffset> cachedOffset;
114 virtual void Profile(llvm::FoldingSetNodeID& ID)
const = 0;
124 LLVM_ATTRIBUTE_RETURNS_NONNULL
131 LLVM_ATTRIBUTE_RETURNS_NONNULL
175 template<
typename RegionTy>
const RegionTy*
getAs()
const;
176 template <
typename RegionTy>
177 LLVM_ATTRIBUTE_RETURNS_NONNULL
const RegionTy *
castAs()
const;
217 void Profile(llvm::FoldingSetNodeID &ID)
const override;
221 return k >= BEGIN_MEMSPACES && k <= END_MEMSPACES;
237 return R->
getKind() == CodeSpaceRegionKind;
242 virtual void anchor();
252 return k >= BEGIN_GLOBAL_MEMSPACES && k <= END_GLOBAL_MEMSPACES;
272 void Profile(llvm::FoldingSetNodeID &ID)
const override;
276 LLVM_ATTRIBUTE_RETURNS_NONNULL
280 return R->
getKind() == StaticGlobalSpaceRegionKind;
291 void anchor()
override;
302 return k >= BEGIN_NON_STATIC_GLOBAL_MEMSPACES &&
303 k <= END_NON_STATIC_GLOBAL_MEMSPACES;
319 return R->
getKind() == GlobalSystemSpaceRegionKind;
338 return R->
getKind() == GlobalImmutableSpaceRegionKind;
355 return R->
getKind() == GlobalInternalSpaceRegionKind;
369 return R->
getKind() == HeapSpaceRegionKind;
383 return R->
getKind() == UnknownSpaceRegionKind;
388 virtual void anchor();
400 LLVM_ATTRIBUTE_RETURNS_NONNULL
403 void Profile(llvm::FoldingSetNodeID &ID)
const override;
407 return k >= BEGIN_STACK_MEMSPACES && k <= END_STACK_MEMSPACES;
421 return R->
getKind() == StackLocalsSpaceRegionKind;
436 return R->
getKind() == StackArgumentsSpaceRegionKind;
443 virtual void anchor();
454 LLVM_ATTRIBUTE_RETURNS_NONNULL
464 return R->
getKind() > END_MEMSPACES;
488 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
const Expr *Ex,
492 LLVM_ATTRIBUTE_RETURNS_NONNULL
497 void Profile(llvm::FoldingSetNodeID& ID)
const override;
502 return R->
getKind() == AllocaRegionKind;
508 void anchor()
override;
526 return k >= BEGIN_TYPED_REGIONS && k <= END_TYPED_REGIONS;
532 void anchor()
override;
558 return k >= BEGIN_TYPED_VALUE_REGIONS && k <= END_TYPED_VALUE_REGIONS;
563 void anchor()
override;
575 return k >= BEGIN_CODE_TEXT_REGIONS && k <= END_CODE_TEXT_REGIONS;
587 assert(isa<ObjCMethodDecl>(fd) || isa<FunctionDecl>(fd));
590 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
const NamedDecl *FD,
596 if (
const auto *D = dyn_cast<FunctionDecl>(FD)) {
600 assert(isa<ObjCMethodDecl>(FD));
601 assert(
false &&
"Getting the type of ObjCMethod is not supported yet");
614 void Profile(llvm::FoldingSetNodeID& ID)
const override;
617 return R->
getKind() == FunctionCodeRegionKind;
636 :
CodeTextRegion(sreg, BlockCodeRegionKind), BD(bd), AC(ac), locTy(lTy) {
642 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
const BlockDecl *BD,
651 LLVM_ATTRIBUTE_RETURNS_NONNULL
656 LLVM_ATTRIBUTE_RETURNS_NONNULL
661 void Profile(llvm::FoldingSetNodeID& ID)
const override;
664 return R->
getKind() == BlockCodeRegionKind;
680 void *ReferencedVars =
nullptr;
681 void *OriginalVars =
nullptr;
685 :
TypedRegion(sreg, BlockDataRegionKind), BC(bc), LC(lc),
690 assert(isa<GlobalImmutableSpaceRegion>(sreg) ||
691 isa<StackLocalsSpaceRegion>(sreg) ||
692 isa<UnknownSpaceRegion>(sreg));
695 static void ProfileRegion(llvm::FoldingSetNodeID&,
const BlockCodeRegion *,
700 LLVM_ATTRIBUTE_RETURNS_NONNULL
703 LLVM_ATTRIBUTE_RETURNS_NONNULL
715 : R(r), OriginalR(originalR) {}
717 LLVM_ATTRIBUTE_RETURNS_NONNULL
719 return cast<VarRegion>(*R);
722 LLVM_ATTRIBUTE_RETURNS_NONNULL
724 return cast<VarRegion>(*OriginalR);
728 assert((R ==
nullptr) == (I.R ==
nullptr));
733 assert((R ==
nullptr) == (I.R ==
nullptr));
753 void Profile(llvm::FoldingSetNodeID& ID)
const override;
756 return R->
getKind() == BlockDataRegionKind;
760 void LazyInitializeReferencedVars();
761 std::pair<const VarRegion *, const VarRegion *>
762 getCaptureRegions(
const VarDecl *VD);
776 :
SubRegion(sreg, SymbolicRegionKind), sym(
s) {
779 assert(
s && isa<SymbolData>(
s));
780 assert(
s->getType()->isAnyPointerType() ||
781 s->getType()->isReferenceType() ||
782 s->getType()->isBlockPointerType());
783 assert(isa<UnknownSpaceRegion>(sreg) || isa<HeapSpaceRegion>(sreg) ||
784 isa<GlobalSystemSpaceRegion>(sreg));
805 void Profile(llvm::FoldingSetNodeID& ID)
const override;
814 return R->
getKind() == SymbolicRegionKind;
829 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
834 LLVM_ATTRIBUTE_RETURNS_NONNULL
841 void Profile(llvm::FoldingSetNodeID& ID)
const override {
848 return R->
getKind() == StringRegionKind;
864 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
869 LLVM_ATTRIBUTE_RETURNS_NONNULL
876 void Profile(llvm::FoldingSetNodeID& ID)
const override {
883 return R->
getKind() == ObjCStringRegionKind;
899 assert(isa<GlobalInternalSpaceRegion>(sReg) ||
900 isa<StackLocalsSpaceRegion>(sReg));
903 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
912 void Profile(llvm::FoldingSetNodeID& ID)
const override;
916 LLVM_ATTRIBUTE_RETURNS_NONNULL
920 return R->
getKind() == CompoundLiteralRegionKind;
936 return k >= BEGIN_DECL_REGIONS && k <= END_DECL_REGIONS;
950 assert(isa<GlobalsSpaceRegion>(sReg) || isa<StackSpaceRegion>(sReg) ||
951 isa<BlockDataRegion>(sReg) || isa<UnknownSpaceRegion>(sReg));
968 return k >= BEGIN_VAR_REGIONS && k <= END_VAR_REGIONS;
979 :
VarRegion(sReg, NonParamVarRegionKind), VD(vd) {
984 assert(isa<GlobalsSpaceRegion>(sReg) || isa<StackSpaceRegion>(sReg) ||
985 isa<BlockDataRegion>(sReg) || isa<UnknownSpaceRegion>(sReg));
989 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
const VarDecl *VD,
993 void Profile(llvm::FoldingSetNodeID &ID)
const override;
995 LLVM_ATTRIBUTE_RETURNS_NONNULL
1010 return R->
getKind() == NonParamVarRegionKind;
1027 const Expr *OriginExpr;
1031 :
VarRegion(SReg, ParamVarRegionKind), OriginExpr(OE), Index(Idx) {
1032 assert(!cast<StackSpaceRegion>(SReg)->
getStackFrame()->inTopFrame());
1036 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
const Expr *OE,
1040 LLVM_ATTRIBUTE_RETURNS_NONNULL
1044 void Profile(llvm::FoldingSetNodeID& ID)
const override;
1057 return R->
getKind() == ParamVarRegionKind;
1070 ThisPointerTy(thisPointerTy) {
1072 "Invalid region type!");
1075 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
1080 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1089 return R->
getKind() == CXXThisRegionKind;
1102 :
DeclRegion(sReg, FieldRegionKind), FD(fd) {
1106 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
const FieldDecl *FD,
1108 ID.AddInteger(
static_cast<unsigned>(FieldRegionKind));
1114 LLVM_ATTRIBUTE_RETURNS_NONNULL
1117 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1132 return R->
getKind() == FieldRegionKind;
1143 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
const ObjCIvarDecl *ivd,
1147 LLVM_ATTRIBUTE_RETURNS_NONNULL
1150 void Profile(llvm::FoldingSetNodeID& ID)
const override;
1160 return R->
getKind() == ObjCIvarRegionKind;
1175 : Region(reg),
Offset(offset) {}
1198 assert((!isa<nonloc::ConcreteInt>(Idx) ||
1200 "The index must be signed");
1202 "Invalid region type!");
1205 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
QualType elementType,
1220 void Profile(llvm::FoldingSetNodeID& ID)
const override;
1223 return R->
getKind() == ElementRegionKind;
1236 assert(isa<StackLocalsSpaceRegion>(sReg) ||
1237 isa<GlobalInternalSpaceRegion>(sReg));
1240 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
1244 LLVM_ATTRIBUTE_RETURNS_NONNULL
1251 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1254 return R->
getKind() == CXXTempObjectRegionKind;
1263 llvm::PointerIntPair<const CXXRecordDecl *, 1, bool>
Data;
1271 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
const CXXRecordDecl *RD,
1275 LLVM_ATTRIBUTE_RETURNS_NONNULL
1283 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1290 return region->
getKind() == CXXBaseObjectRegionKind;
1311 "Should have unwrapped a base region instead!");
1314 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
const CXXRecordDecl *RD,
1318 LLVM_ATTRIBUTE_RETURNS_NONNULL
1325 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1332 return region->
getKind() == CXXDerivedObjectRegionKind;
1336template<
typename RegionTy>
1338 if (
const auto *RT = dyn_cast<RegionTy>(
this))
1344template <
typename RegionTy>
1346 return cast<RegionTy>(
this);
1355 llvm::BumpPtrAllocator& A;
1357 llvm::FoldingSet<MemRegion> Regions;
1363 llvm::DenseMap<const StackFrameContext *, StackLocalsSpaceRegion *>
1364 StackLocalsSpaceRegions;
1365 llvm::DenseMap<const StackFrameContext *, StackArgumentsSpaceRegion *>
1366 StackArgumentsSpaceRegions;
1367 llvm::DenseMap<const CodeTextRegion *, StaticGlobalSpaceRegion *>
1368 StaticsGlobalSpaceRegions;
1526 unsigned blockCount);
1534 template <
typename RegionTy,
typename SuperTy,
1536 RegionTy* getSubRegion(
const Arg1Ty arg1,
1537 const SuperTy* superRegion);
1539 template <
typename RegionTy,
typename SuperTy,
1540 typename Arg1Ty,
typename Arg2Ty>
1541 RegionTy* getSubRegion(
const Arg1Ty arg1,
const Arg2Ty arg2,
1542 const SuperTy* superRegion);
1544 template <
typename RegionTy,
typename SuperTy,
1545 typename Arg1Ty,
typename Arg2Ty,
typename Arg3Ty>
1546 RegionTy* getSubRegion(
const Arg1Ty arg1,
const Arg2Ty arg2,
1548 const SuperTy* superRegion);
1550 template <
typename REG>
1551 const REG* LazyAllocate(REG*& region);
1553 template <
typename REG,
typename ARG>
1554 const REG* LazyAllocate(REG*& region, ARG a);
1571 using StorageTypeForKinds =
unsigned char;
1573 llvm::DenseMap<const MemRegion *, StorageTypeForKinds> MRTraitsMap;
1574 llvm::DenseMap<SymbolRef, StorageTypeForKinds> SymTraitsMap;
1576 using const_region_iterator =
1577 llvm::DenseMap<const MemRegion *, StorageTypeForKinds>::const_iterator;
1578 using const_symbol_iterator =
1579 llvm::DenseMap<SymbolRef, StorageTypeForKinds>::const_iterator;
Defines the clang::ASTContext interface.
This file defines AnalysisDeclContext, a class that manages the analysis context data for context sen...
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::SourceLocation class and associated facilities.
C Language Family Type Representation.
__device__ __2f16 float c
__device__ __2f16 float bool s
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
AnalysisDeclContext contains the context data for the function, method or block under analysis.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Represents a C++ struct/union/class.
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
CharUnits - This is an opaque type for sizes expressed in character units.
static CharUnits Zero()
Zero - Construct a CharUnits quantity of zero.
CompoundLiteralExpr - [C99 6.5.2.5].
This represents one expression.
Represents a member of a struct/union/class.
It wraps the AnalysisDeclContext to represent both the call stack with the help of StackFrameContext ...
This represents a decl that may have a name.
ObjCIvarDecl - Represents an ObjC instance variable.
Represents a class type in Objective C.
ObjCStringLiteral, used for Objective-C string literals i.e.
Represents a parameter to a function.
PointerType - C99 6.7.5.1 - Pointer Declarators.
QualType getPointeeType() const
A (possibly-)qualified type.
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
const Type * getTypePtrOrNull() const
A trivial tuple used to represent a source range.
It represents a stack frame of the call stack (based on CallEvent).
StringLiteral - This represents a string literal expression, e.g.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isBlockPointerType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
const T * getAs() const
Member-template getAs<specific type>'.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Represents a variable declaration or definition.
AllocaRegion - A region that represents an untyped blob of bytes created by a call to 'alloca'.
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
void Profile(llvm::FoldingSetNodeID &ID) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const Expr * getExpr() const
bool isBoundable() const override
BlockCodeRegion - A region that represents code texts of blocks (closures).
QualType getLocationType() const override
LLVM_ATTRIBUTE_RETURNS_NONNULL AnalysisDeclContext * getAnalysisDeclContext() const
void dumpToStream(raw_ostream &os) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const BlockDecl * getDecl() const
static bool classof(const MemRegion *R)
void Profile(llvm::FoldingSetNodeID &ID) const override
bool operator==(const referenced_vars_iterator &I) const
bool operator!=(const referenced_vars_iterator &I) const
LLVM_ATTRIBUTE_RETURNS_NONNULL const VarRegion * getCapturedRegion() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const VarRegion * getOriginalRegion() const
referenced_vars_iterator & operator++()
referenced_vars_iterator(const MemRegion *const *r, const MemRegion *const *originalR)
BlockDataRegion - A region that represents a block instance.
const VarRegion * getOriginalRegion(const VarRegion *VR) const
Return the original region for a captured region, if one exists.
QualType getLocationType() const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const BlockDecl * getDecl() const
static bool classof(const MemRegion *R)
referenced_vars_iterator referenced_vars_begin() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const BlockCodeRegion * getCodeRegion() const
void Profile(llvm::FoldingSetNodeID &ID) const override
referenced_vars_iterator referenced_vars_end() const
void dumpToStream(raw_ostream &os) const override
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
LLVM_ATTRIBUTE_RETURNS_NONNULL const CXXRecordDecl * getDecl() const
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
void Profile(llvm::FoldingSetNodeID &ID) const override
static bool classof(const MemRegion *region)
void dumpToStream(raw_ostream &os) const override
QualType getValueType() const override
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
void Profile(llvm::FoldingSetNodeID &ID) const override
QualType getValueType() const override
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *region)
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
LLVM_ATTRIBUTE_RETURNS_NONNULL const CXXRecordDecl * getDecl() const
QualType getValueType() const override
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
LLVM_ATTRIBUTE_RETURNS_NONNULL const Expr * getExpr() const
CXXThisRegion - Represents the region for the implicit 'this' parameter in a call to a C++ method.
QualType getValueType() const override
static bool classof(const MemRegion *R)
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
CodeSpaceRegion - The memory space that holds the executable code of functions and blocks.
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
CodeTextRegion(const MemSpaceRegion *sreg, Kind k)
static bool classof(const MemRegion *R)
bool isBoundable() const override
CompoundLiteralRegion - A memory region representing a compound literal.
LLVM_ATTRIBUTE_RETURNS_NONNULL const CompoundLiteralExpr * getLiteralExpr() const
QualType getValueType() const override
bool isBoundable() const override
void Profile(llvm::FoldingSetNodeID &ID) const override
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
DeclRegion(const MemRegion *sReg, Kind k)
virtual const ValueDecl * getDecl() const =0
static bool classof(const MemRegion *R)
ElementRegion is used to represent both array elements and casts.
static bool classof(const MemRegion *R)
QualType getValueType() const override
QualType getElementType() const
void Profile(llvm::FoldingSetNodeID &ID) const override
RegionRawOffset getAsArrayOffset() const
Compute the offset within the array. The array might also be a subobject.
void dumpToStream(raw_ostream &os) const override
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
static bool classof(const MemRegion *R)
bool canPrintPretty() const override
Returns true if this region can be printed in a user-friendly way.
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
void dumpToStream(raw_ostream &os) const override
QualType getValueType() const override
void printPretty(raw_ostream &os) const override
Print the region for use in diagnostics.
void Profile(llvm::FoldingSetNodeID &ID) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const FieldDecl * getDecl() const override
FunctionCodeRegion - A region that represents code texts of function.
static bool classof(const MemRegion *R)
QualType getLocationType() const override
const NamedDecl * getDecl() const
void dumpToStream(raw_ostream &os) const override
void Profile(llvm::FoldingSetNodeID &ID) const override
The region containing globals which are considered not to be modified or point to data which could be...
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
The region containing globals which can be modified by calls to "internally" defined functions - (for...
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
The region containing globals which are defined in system/external headers and are considered modifia...
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
GlobalsSpaceRegion(MemRegionManager &mgr, Kind k)
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
const HeapSpaceRegion * getHeapRegion()
getHeapRegion - Retrieve the memory region associated with the generic "heap".
const StackArgumentsSpaceRegion * getStackArgumentsRegion(const StackFrameContext *STC)
getStackArgumentsRegion - Retrieve the memory region associated with function/method arguments of the...
const CXXThisRegion * getCXXThisRegion(QualType thisPointerTy, const LocationContext *LC)
getCXXThisRegion - Retrieve the [artificial] region associated with the parameter 'this'.
llvm::BumpPtrAllocator & getAllocator()
const BlockCodeRegion * getBlockCodeRegion(const BlockDecl *BD, CanQualType locTy, AnalysisDeclContext *AC)
const ASTContext & getContext() const
const UnknownSpaceRegion * getUnknownRegion()
getUnknownRegion - Retrieve the memory region associated with unknown memory space.
const CXXDerivedObjectRegion * getCXXDerivedObjectRegion(const CXXRecordDecl *BaseClass, const SubRegion *Super)
Create a CXXDerivedObjectRegion with the given derived class for region Super.
const CompoundLiteralRegion * getCompoundLiteralRegion(const CompoundLiteralExpr *CL, const LocationContext *LC)
getCompoundLiteralRegion - Retrieve the region associated with a given CompoundLiteral.
const FieldRegion * getFieldRegion(const FieldDecl *fd, const SubRegion *superRegion)
getFieldRegion - Retrieve or create the memory region associated with a specified FieldDecl.
const AllocaRegion * getAllocaRegion(const Expr *Ex, unsigned Cnt, const LocationContext *LC)
getAllocaRegion - Retrieve a region associated with a call to alloca().
const VarRegion * getVarRegion(const VarDecl *VD, const LocationContext *LC)
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationC...
const NonParamVarRegion * getNonParamVarRegion(const VarDecl *VD, const MemRegion *superR)
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationC...
const FieldRegion * getFieldRegionWithSuper(const FieldRegion *FR, const SubRegion *superRegion)
const StackLocalsSpaceRegion * getStackLocalsRegion(const StackFrameContext *STC)
getStackLocalsRegion - Retrieve the memory region associated with the specified stack frame.
const ObjCIvarRegion * getObjCIvarRegion(const ObjCIvarDecl *ivd, const SubRegion *superRegion)
getObjCIvarRegion - Retrieve or create the memory region associated with a specified Objective-c inst...
const CXXTempObjectRegion * getCXXStaticTempObjectRegion(const Expr *Ex)
Create a CXXTempObjectRegion for temporaries which are lifetime-extended by static references.
const SymbolicRegion * getSymbolicHeapRegion(SymbolRef sym)
Return a unique symbolic region belonging to heap memory space.
const ObjCStringRegion * getObjCStringRegion(const ObjCStringLiteral *Str)
MemRegionManager(ASTContext &c, llvm::BumpPtrAllocator &a)
const StringRegion * getStringRegion(const StringLiteral *Str)
ASTContext & getContext()
DefinedOrUnknownSVal getStaticSize(const MemRegion *MR, SValBuilder &SVB) const
const ParamVarRegion * getParamVarRegion(const Expr *OriginExpr, unsigned Index, const LocationContext *LC)
getParamVarRegion - Retrieve or create the memory region associated with a specified CallExpr,...
const CodeSpaceRegion * getCodeRegion()
const ElementRegion * getElementRegion(QualType elementType, NonLoc Idx, const SubRegion *superRegion, ASTContext &Ctx)
getElementRegion - Retrieve the memory region associated with the associated element type,...
const CXXTempObjectRegion * getCXXTempObjectRegion(Expr const *Ex, LocationContext const *LC)
const GlobalsSpaceRegion * getGlobalsRegion(MemRegion::Kind K=MemRegion::GlobalInternalSpaceRegionKind, const CodeTextRegion *R=nullptr)
getGlobalsRegion - Retrieve the memory region associated with global variables.
const SymbolicRegion * getSymbolicRegion(SymbolRef Sym, const MemSpaceRegion *MemSpace=nullptr)
Retrieve or create a "symbolic" memory region.
const ElementRegion * getElementRegionWithSuper(const ElementRegion *ER, const SubRegion *superRegion)
const FunctionCodeRegion * getFunctionCodeRegion(const NamedDecl *FD)
const BlockDataRegion * getBlockDataRegion(const BlockCodeRegion *bc, const LocationContext *lc, unsigned blockCount)
getBlockDataRegion - Get the memory region associated with an instance of a block.
const CXXBaseObjectRegion * getCXXBaseObjectRegion(const CXXRecordDecl *BaseClass, const SubRegion *Super, bool IsVirtual)
Create a CXXBaseObjectRegion with the given base class for region Super.
const CXXBaseObjectRegion * getCXXBaseObjectRegionWithSuper(const CXXBaseObjectRegion *baseReg, const SubRegion *superRegion)
Create a CXXBaseObjectRegion with the same CXXRecordDecl but a different super region.
MemRegion - The root abstract class for all memory regions.
bool hasGlobalsOrParametersStorage() const
virtual bool canPrintPrettyAsExpr() const
Returns true if this region's textual representation can be used as part of a larger expression.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemSpaceRegion * getMemorySpace() const
virtual void Profile(llvm::FoldingSetNodeID &ID) const =0
bool hasStackParametersStorage() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const RegionTy * castAs() const
virtual bool isBoundable() const
RegionOffset getAsOffset() const
Compute the offset within the top level memory object.
bool hasStackStorage() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * StripCasts(bool StripBaseAndDerivedCasts=true) const
ASTContext & getContext() const
std::string getDescriptiveName(bool UseQuotes=true) const
Get descriptive name for memory region.
virtual bool isSubRegionOf(const MemRegion *R) const
Check if the region is a subregion of the given region.
virtual void dumpToStream(raw_ostream &os) const
const SymbolicRegion * getSymbolicBase() const
If this is a symbolic region, returns the region.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getBaseRegion() const
virtual void printPretty(raw_ostream &os) const
Print the region for use in diagnostics.
virtual void printPrettyAsExpr(raw_ostream &os) const
Print the region as expression.
bool hasStackNonParametersStorage() const
std::string getString() const
Get a string representation of a region for debug use.
const RegionTy * getAs() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getMostDerivedObjectRegion() const
Recursively retrieve the region of the most derived class instance of regions of C++ base class insta...
virtual MemRegionManager & getMemRegionManager() const =0
virtual bool canPrintPretty() const
Returns true if this region can be printed in a user-friendly way.
SourceRange sourceRange() const
Retrieve source range from memory region.
MemSpaceRegion - A memory region that represents a "memory space"; for example, the set of global var...
MemRegionManager & getMemRegionManager() const override
static bool classof(const MemRegion *R)
void Profile(llvm::FoldingSetNodeID &ID) const override
bool isBoundable() const override
MemSpaceRegion(MemRegionManager &mgr, Kind k)
QualType getValueType() const override
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
void Profile(llvm::FoldingSetNodeID &ID) const override
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
void dumpToStream(raw_ostream &os) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const VarDecl * getDecl() const override
static bool classof(const MemRegion *R)
The region for all the non-static global variables.
NonStaticGlobalSpaceRegion(MemRegionManager &mgr, Kind k)
static bool classof(const MemRegion *R)
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
void Profile(llvm::FoldingSetNodeID &ID) const override
QualType getValueType() const override
static bool classof(const MemRegion *R)
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
LLVM_ATTRIBUTE_RETURNS_NONNULL const ObjCIvarDecl * getDecl() const override
void dumpToStream(raw_ostream &os) const override
The region associated with an ObjCStringLiteral.
QualType getValueType() const override
bool isBoundable() const override
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
LLVM_ATTRIBUTE_RETURNS_NONNULL const ObjCStringLiteral * getObjCStringLiteral() const
void Profile(llvm::FoldingSetNodeID &ID) const override
ParamVarRegion - Represents a region for paremters.
bool canPrintPrettyAsExpr() const override
Returns true if this region's textual representation can be used as part of a larger expression.
LLVM_ATTRIBUTE_RETURNS_NONNULL const Expr * getOriginExpr() const
static bool classof(const MemRegion *R)
const ParmVarDecl * getDecl() const override
TODO: What does this return?
unsigned getIndex() const
void Profile(llvm::FoldingSetNodeID &ID) const override
QualType getValueType() const override
void dumpToStream(raw_ostream &os) const override
void printPrettyAsExpr(raw_ostream &os) const override
Print the region as expression.
Information about invalidation for a particular region/symbol.
InvalidationKinds
Describes different invalidation traits.
@ TK_PreserveContents
Tells that a region's contents is not changed.
@ TK_DoNotInvalidateSuperRegion
@ TK_EntireMemSpace
When applied to a MemSpaceRegion, indicates the entire memory space should be invalidated.
@ TK_SuppressEscape
Suppress pointer-escaping of a region.
bool hasTrait(SymbolRef Sym, InvalidationKinds IK) const
void setTrait(SymbolRef Sym, InvalidationKinds IK)
Represent a region's offset within the top level base region.
static const int64_t Symbolic
bool hasSymbolicOffset() const
const MemRegion * getRegion() const
It might return null.
RegionOffset(const MemRegion *r, int64_t off)
int64_t getOffset() const
CharUnits getOffset() const
void dumpToStream(raw_ostream &os) const
const MemRegion * getRegion() const
SVal - This represents a symbolic expression, which can be either an L-value or an R-value.
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
StackSpaceRegion(MemRegionManager &mgr, Kind k, const StackFrameContext *sfc)
static bool classof(const MemRegion *R)
LLVM_ATTRIBUTE_RETURNS_NONNULL const StackFrameContext * getStackFrame() const
void Profile(llvm::FoldingSetNodeID &ID) const override
The region of the static variables within the current CodeTextRegion scope.
void Profile(llvm::FoldingSetNodeID &ID) const override
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const CodeTextRegion * getCodeRegion() const
StringRegion - Region associated with a StringLiteral.
static bool classof(const MemRegion *R)
QualType getValueType() const override
void Profile(llvm::FoldingSetNodeID &ID) const override
bool isBoundable() const override
void dumpToStream(raw_ostream &os) const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const StringLiteral * getStringLiteral() const
SubRegion - A region that subsets another larger region.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * getSuperRegion() const
static bool classof(const MemRegion *R)
bool isSubRegionOf(const MemRegion *R) const override
Check if the region is a subregion of the given region.
SubRegion(const MemRegion *sReg, Kind k)
const MemRegion * superRegion
MemRegionManager & getMemRegionManager() const override
virtual QualType getType() const =0
SymbolicRegion - A special, "non-concrete" region.
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
bool isBoundable() const override
void Profile(llvm::FoldingSetNodeID &ID) const override
SymbolRef getSymbol() const
It might return null.
static void ProfileRegion(llvm::FoldingSetNodeID &ID, SymbolRef sym, const MemRegion *superRegion)
QualType getPointeeStaticType() const
Gets the type of the wrapped symbol.
TypedRegion - An abstract class representing regions that are typed.
QualType getDesugaredLocationType(ASTContext &Context) const
bool isBoundable() const override
virtual QualType getLocationType() const =0
TypedRegion(const MemRegion *sReg, Kind k)
static bool classof(const MemRegion *R)
TypedValueRegion - An abstract class representing regions having a typed value.
virtual QualType getValueType() const =0
QualType getLocationType() const override
static bool classof(const MemRegion *R)
QualType getDesugaredValueType(ASTContext &Context) const
TypedValueRegion(const MemRegion *sReg, Kind k)
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
QualType getValueType() const override
const VarDecl * getDecl() const override=0
const StackFrameContext * getStackFrame() const
It might return null.
VarRegion(const MemRegion *sReg, Kind k)
static bool classof(const MemRegion *R)
Value representing integer constant.
const llvm::APSInt & getValue() const
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
raw_ostream & operator<<(raw_ostream &Out, const CheckerBase &Checker)
Dump checker name to stream.