15#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_MEMREGION_H
16#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_MEMREGION_H
32#include "llvm/ADT/DenseMap.h"
33#include "llvm/ADT/FoldingSet.h"
34#include "llvm/ADT/PointerIntPair.h"
35#include "llvm/ADT/iterator_range.h"
36#include "llvm/Support/Allocator.h"
37#include "llvm/Support/Casting.h"
38#include "llvm/Support/ErrorHandling.h"
74 static const int64_t
Symbolic = std::numeric_limits<int64_t>::max();
100#define REGION(Id, Parent) Id ## Kind,
101#define REGION_RANGE(Id, First, Last) BEGIN_##Id = First, END_##Id = Last,
102#include "clang/StaticAnalyzer/Core/PathSensitive/Regions.def"
109 mutable std::optional<RegionOffset> cachedOffset;
118 virtual void Profile(llvm::FoldingSetNodeID& ID)
const = 0;
126 [[nodiscard]] LLVM_ATTRIBUTE_RETURNS_NONNULL
const MemSpaceRegion *
130 template <
class MemSpace>
138 [[nodiscard]] LLVM_ATTRIBUTE_RETURNS_NONNULL
const MemSpaceRegion *
141 template <
class MemSpace>
146 template <
typename... MemorySpaces>
148 static_assert(
sizeof...(MemorySpaces));
161 LLVM_ATTRIBUTE_RETURNS_NONNULL
168 LLVM_ATTRIBUTE_RETURNS_NONNULL
206 template<
typename RegionTy>
const RegionTy*
getAs()
const;
207 template <
typename RegionTy>
208 LLVM_ATTRIBUTE_RETURNS_NONNULL
const RegionTy *
castAs()
const;
248 void Profile(llvm::FoldingSetNodeID &ID)
const override;
251 Kind k = R->getKind();
252 return k >= BEGIN_MEMSPACES && k <= END_MEMSPACES;
268 return R->getKind() == CodeSpaceRegionKind;
273 virtual void anchor();
282 Kind k = R->getKind();
283 return k >= BEGIN_GLOBAL_MEMSPACES && k <= END_GLOBAL_MEMSPACES;
303 void Profile(llvm::FoldingSetNodeID &ID)
const override;
307 LLVM_ATTRIBUTE_RETURNS_NONNULL
311 return R->getKind() == StaticGlobalSpaceRegionKind;
322 void anchor()
override;
332 Kind k = R->getKind();
333 return k >= BEGIN_NON_STATIC_GLOBAL_MEMSPACES &&
334 k <= END_NON_STATIC_GLOBAL_MEMSPACES;
350 return R->getKind() == GlobalSystemSpaceRegionKind;
369 return R->getKind() == GlobalImmutableSpaceRegionKind;
386 return R->getKind() == GlobalInternalSpaceRegionKind;
400 return R->getKind() == HeapSpaceRegionKind;
414 return R->getKind() == UnknownSpaceRegionKind;
419 virtual void anchor();
431 LLVM_ATTRIBUTE_RETURNS_NONNULL
434 void Profile(llvm::FoldingSetNodeID &ID)
const override;
437 Kind k = R->getKind();
438 return k >= BEGIN_STACK_MEMSPACES && k <= END_STACK_MEMSPACES;
452 return R->getKind() == StackLocalsSpaceRegionKind;
467 return R->getKind() == StackArgumentsSpaceRegionKind;
474 virtual void anchor();
485 LLVM_ATTRIBUTE_RETURNS_NONNULL
495 return R->getKind() > END_MEMSPACES;
519 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
const Expr *Ex,
523 LLVM_ATTRIBUTE_RETURNS_NONNULL
528 void Profile(llvm::FoldingSetNodeID& ID)
const override;
533 return R->getKind() == AllocaRegionKind;
539 void anchor()
override;
556 unsigned k = R->getKind();
557 return k >= BEGIN_TYPED_REGIONS && k <= END_TYPED_REGIONS;
563 void anchor()
override;
584 return T.getTypePtrOrNull() ? T.getDesugaredType(Context) : T;
588 unsigned k = R->getKind();
589 return k >= BEGIN_TYPED_VALUE_REGIONS && k <= END_TYPED_VALUE_REGIONS;
594 void anchor()
override;
605 Kind k = R->getKind();
606 return k >= BEGIN_CODE_TEXT_REGIONS && k <= END_CODE_TEXT_REGIONS;
621 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
const NamedDecl *FD,
627 if (
const auto *D = dyn_cast<FunctionDecl>(FD)) {
632 assert(
false &&
"Getting the type of ObjCMethod is not supported yet");
645 void Profile(llvm::FoldingSetNodeID& ID)
const override;
648 return R->getKind() == FunctionCodeRegionKind;
667 :
CodeTextRegion(sreg, BlockCodeRegionKind), BD(bd), AC(ac), locTy(lTy) {
673 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
const BlockDecl *BD,
682 LLVM_ATTRIBUTE_RETURNS_NONNULL
687 LLVM_ATTRIBUTE_RETURNS_NONNULL
692 void Profile(llvm::FoldingSetNodeID& ID)
const override;
695 return R->getKind() == BlockCodeRegionKind;
711 void *ReferencedVars =
nullptr;
712 void *OriginalVars =
nullptr;
716 :
TypedRegion(sreg, BlockDataRegionKind), BC(bc), SF(SF),
726 static void ProfileRegion(llvm::FoldingSetNodeID &,
const BlockCodeRegion *,
730 LLVM_ATTRIBUTE_RETURNS_NONNULL
733 LLVM_ATTRIBUTE_RETURNS_NONNULL
745 : R(r), OriginalR(originalR) {}
747 LLVM_ATTRIBUTE_RETURNS_NONNULL
752 LLVM_ATTRIBUTE_RETURNS_NONNULL
758 assert((R ==
nullptr) == (I.R ==
nullptr));
763 assert((R ==
nullptr) == (I.R ==
nullptr));
785 llvm::iterator_range<referenced_vars_iterator>
referenced_vars()
const;
789 void Profile(llvm::FoldingSetNodeID& ID)
const override;
792 return R->getKind() == BlockDataRegionKind;
796 void LazyInitializeReferencedVars();
797 std::pair<const VarRegion *, const VarRegion *>
798 getCaptureRegions(
const VarDecl *VD);
812 :
SubRegion(sreg, SymbolicRegionKind), sym(
s) {
815 assert(isa_and_nonnull<SymbolData>(
s));
816 assert(
s->getType()->isAnyPointerType() ||
817 s->getType()->isReferenceType() ||
818 s->getType()->isBlockPointerType());
841 void Profile(llvm::FoldingSetNodeID& ID)
const override;
850 return R->getKind() == SymbolicRegionKind;
865 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
870 LLVM_ATTRIBUTE_RETURNS_NONNULL
877 void Profile(llvm::FoldingSetNodeID& ID)
const override {
884 return R->getKind() == StringRegionKind;
900 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
905 LLVM_ATTRIBUTE_RETURNS_NONNULL
912 void Profile(llvm::FoldingSetNodeID& ID)
const override {
919 return R->getKind() == ObjCStringRegionKind;
939 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
948 void Profile(llvm::FoldingSetNodeID& ID)
const override;
952 LLVM_ATTRIBUTE_RETURNS_NONNULL
956 return R->getKind() == CompoundLiteralRegionKind;
971 unsigned k = R->getKind();
972 return k >= BEGIN_DECL_REGIONS && k <= END_DECL_REGIONS;
1003 unsigned k = R->getKind();
1004 return k >= BEGIN_VAR_REGIONS && k <= END_VAR_REGIONS;
1019 :
VarRegion(sReg, NonParamVarRegionKind), VD(vd) {
1029 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
const VarDecl *VD,
1033 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1035 LLVM_ATTRIBUTE_RETURNS_NONNULL
1050 return R->getKind() == NonParamVarRegionKind;
1068 const Expr *OriginExpr;
1071 ParamVarRegion(
const Expr *OE,
unsigned Idx,
const MemRegion *SReg)
1072 :
VarRegion(SReg, ParamVarRegionKind), OriginExpr(OE), Index(Idx) {
1077 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
const Expr *OE,
1081 LLVM_ATTRIBUTE_RETURNS_NONNULL
1085 void Profile(llvm::FoldingSetNodeID& ID)
const override;
1098 return R->getKind() == ParamVarRegionKind;
1111 ThisPointerTy(thisPointerTy) {
1112 assert(ThisPointerTy->getPointeeType()->getAsCXXRecordDecl() &&
1113 "Invalid region type!");
1116 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
1121 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1130 return R->getKind() == CXXThisRegionKind;
1143 :
DeclRegion(sReg, FieldRegionKind), FD(fd) {
1147 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
const FieldDecl *FD,
1149 ID.AddInteger(
static_cast<unsigned>(FieldRegionKind));
1155 LLVM_ATTRIBUTE_RETURNS_NONNULL
1158 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1173 return R->getKind() == FieldRegionKind;
1184 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
const ObjCIvarDecl *ivd,
1188 LLVM_ATTRIBUTE_RETURNS_NONNULL
1191 void Profile(llvm::FoldingSetNodeID& ID)
const override;
1201 return R->getKind() == ObjCIvarRegionKind;
1209class RegionRawOffset {
1216 : Region(reg), Offset(offset) {}
1241 "The index must be signed");
1243 "Invalid region type!");
1246 static void ProfileRegion(llvm::FoldingSetNodeID& ID,
QualType elementType,
1261 void Profile(llvm::FoldingSetNodeID& ID)
const override;
1264 return R->getKind() == ElementRegionKind;
1280 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
1284 LLVM_ATTRIBUTE_RETURNS_NONNULL
1287 LLVM_ATTRIBUTE_RETURNS_NONNULL
1294 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1297 return R->getKind() == CXXTempObjectRegionKind;
1309 CXXLifetimeExtendedObjectRegion(
Expr const *E,
ValueDecl const *D,
1318 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
Expr const *E,
1322 LLVM_ATTRIBUTE_RETURNS_NONNULL
1324 LLVM_ATTRIBUTE_RETURNS_NONNULL
1333 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1336 return R->getKind() == CXXLifetimeExtendedObjectRegionKind;
1345 llvm::PointerIntPair<const CXXRecordDecl *, 1, bool> Data;
1347 CXXBaseObjectRegion(
const CXXRecordDecl *RD,
bool IsVirtual,
1353 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
const CXXRecordDecl *RD,
1357 LLVM_ATTRIBUTE_RETURNS_NONNULL
1365 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1372 return region->
getKind() == CXXBaseObjectRegionKind;
1393 "Should have unwrapped a base region instead!");
1396 static void ProfileRegion(llvm::FoldingSetNodeID &ID,
const CXXRecordDecl *RD,
1400 LLVM_ATTRIBUTE_RETURNS_NONNULL
1407 void Profile(llvm::FoldingSetNodeID &ID)
const override;
1414 return region->
getKind() == CXXDerivedObjectRegionKind;
1418template<
typename RegionTy>
1420 if (
const auto *RT = dyn_cast<RegionTy>(
this))
1426template <
typename RegionTy>
1437 llvm::BumpPtrAllocator& A;
1439 llvm::FoldingSet<MemRegion> Regions;
1445 llvm::DenseMap<const StackFrame *, StackLocalsSpaceRegion *>
1446 StackLocalsSpaceRegions;
1447 llvm::DenseMap<const StackFrame *, StackArgumentsSpaceRegion *>
1448 StackArgumentsSpaceRegions;
1449 llvm::DenseMap<const CodeTextRegion *, StaticGlobalSpaceRegion *>
1450 StaticsGlobalSpaceRegions;
1617 unsigned blockCount);
1620 template <
typename RegionTy,
typename SuperTy,
1622 RegionTy* getSubRegion(
const Arg1Ty arg1,
1623 const SuperTy* superRegion);
1625 template <
typename RegionTy,
typename SuperTy,
1626 typename Arg1Ty,
typename Arg2Ty>
1627 RegionTy* getSubRegion(
const Arg1Ty arg1,
const Arg2Ty arg2,
1628 const SuperTy* superRegion);
1630 template <
typename RegionTy,
typename SuperTy,
1631 typename Arg1Ty,
typename Arg2Ty,
typename Arg3Ty>
1632 RegionTy* getSubRegion(
const Arg1Ty arg1,
const Arg2Ty arg2,
1634 const SuperTy* superRegion);
1636 template <
typename REG>
1637 const REG* LazyAllocate(REG*& region);
1639 template <
typename REG,
typename ARG>
1640 const REG* LazyAllocate(REG*& region, ARG a);
1657 using StorageTypeForKinds =
unsigned char;
1659 llvm::DenseMap<const MemRegion *, StorageTypeForKinds> MRTraitsMap;
1660 llvm::DenseMap<SymbolRef, StorageTypeForKinds> SymTraitsMap;
1662 using const_region_iterator =
1663 llvm::DenseMap<const MemRegion *, StorageTypeForKinds>::const_iterator;
1664 using const_symbol_iterator =
1665 llvm::DenseMap<SymbolRef, StorageTypeForKinds>::const_iterator;
1697 R->dumpToStream(os);
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 __ockl_bool s
__device__ __2f16 float c
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].
Decl - This represents one declaration (or definition), e.g.
This represents one expression.
Represents a member of a struct/union/class.
This represents a decl that may have a name.
ObjCIvarDecl - Represents an ObjC instance variable.
ObjCStringLiteral, used for Objective-C string literals i.e.
Represents a parameter to a function.
PointerType - C99 6.7.5.1 - Pointer Declarators.
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.
A trivial tuple used to represent a source range.
It represents a stack frame of the call stack.
StringLiteral - This represents a string literal expression, e.g.
bool isBlockPointerType() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
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
friend class MemRegionManager
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
friend class MemRegionManager
bool operator==(const referenced_vars_iterator &I) const
const referenced_vars_iterator & operator*() 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
friend class MemRegionManager
llvm::iterator_range< referenced_vars_iterator > referenced_vars() const
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
friend class MemRegionManager
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.
friend class MemRegionManager
LLVM_ATTRIBUTE_RETURNS_NONNULL const CXXRecordDecl * getDecl() const
static bool classof(const MemRegion *R)
LLVM_ATTRIBUTE_RETURNS_NONNULL const Expr * getExpr() const
void Profile(llvm::FoldingSetNodeID &ID) const override
const StackFrame * getStackFrame() const
It might return null.
LLVM_ATTRIBUTE_RETURNS_NONNULL const ValueDecl * getExtendingDecl() const
void dumpToStream(raw_ostream &os) const override
friend class MemRegionManager
QualType getValueType() const override
QualType getValueType() const override
LLVM_ATTRIBUTE_RETURNS_NONNULL const StackFrame * getStackFrame() const
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
friend class MemRegionManager
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
friend class MemRegionManager
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)
friend class MemRegionManager
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
friend class MemRegionManager
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
friend class MemRegionManager
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
friend class MemRegionManager
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
friend class MemRegionManager
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)
friend class MemRegionManager
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)
friend class MemRegionManager
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
friend class MemRegionManager
GlobalsSpaceRegion(MemRegionManager &mgr, Kind k)
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
static bool classof(const MemRegion *R)
friend class MemRegionManager
const HeapSpaceRegion * getHeapRegion()
getHeapRegion - Retrieve the memory region associated with the generic "heap".
llvm::BumpPtrAllocator & getAllocator()
const StackLocalsSpaceRegion * getStackLocalsRegion(const StackFrame *SF)
getStackLocalsRegion - Retrieve the memory region associated with the specified stack frame.
const FieldRegion * getFieldRegion(const FieldDecl *FD, const SubRegion *SuperRegion)
getFieldRegion - Retrieve or create the memory region associated with a specified FieldDecl.
const ParamVarRegion * getParamVarRegion(const Expr *OriginExpr, unsigned Index, const StackFrame *SF)
getParamVarRegion - Retrieve or create the memory region associated with a specified CallExpr,...
const StackArgumentsSpaceRegion * getStackArgumentsRegion(const StackFrame *SF)
getStackArgumentsRegion - Retrieve the memory region associated with function/method arguments of the...
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 CXXLifetimeExtendedObjectRegion * getCXXLifetimeExtendedObjectRegion(Expr const *Ex, ValueDecl const *VD, StackFrame const *SF)
Create a CXXLifetimeExtendedObjectRegion for temporaries which are lifetime-extended by local referen...
const CompoundLiteralRegion * getCompoundLiteralRegion(const CompoundLiteralExpr *CL, const StackFrame *SF)
getCompoundLiteralRegion - Retrieve the region associated with a given CompoundLiteral.
const ElementRegion * getElementRegion(QualType elementType, NonLoc Idx, const SubRegion *superRegion, const ASTContext &Ctx)
getElementRegion - Retrieve the memory region associated with the associated element type,...
const NonParamVarRegion * getNonParamVarRegion(const VarDecl *VD, const MemRegion *superR)
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and StackFram...
const FieldRegion * getFieldRegionWithSuper(const FieldRegion *FR, const SubRegion *superRegion)
const ObjCIvarRegion * getObjCIvarRegion(const ObjCIvarDecl *ivd, const SubRegion *superRegion)
getObjCIvarRegion - Retrieve or create the memory region associated with a specified Objective-c inst...
const VarRegion * getVarRegion(const VarDecl *VD, const StackFrame *SF)
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and StackFram...
const AllocaRegion * getAllocaRegion(const Expr *Ex, unsigned Cnt, const StackFrame *SF)
getAllocaRegion - Retrieve a region associated with a call to alloca().
const SymbolicRegion * getSymbolicHeapRegion(SymbolRef sym)
Return a unique symbolic region belonging to heap memory space.
const CXXTempObjectRegion * getCXXTempObjectRegion(Expr const *Ex, StackFrame const *SF)
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 CodeSpaceRegion * getCodeRegion()
const GlobalsSpaceRegion * getGlobalsRegion(MemRegion::Kind K=MemRegion::GlobalInternalSpaceRegionKind, const CodeTextRegion *R=nullptr)
getGlobalsRegion - Retrieve the memory region associated with global variables.
const CXXThisRegion * getCXXThisRegion(QualType thisPointerTy, const StackFrame *SF)
getCXXThisRegion - Retrieve the [artificial] region associated with the parameter 'this'.
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 CXXBaseObjectRegion * getCXXBaseObjectRegion(const CXXRecordDecl *BaseClass, const SubRegion *Super, bool IsVirtual)
Create a CXXBaseObjectRegion with the given base class for region Super.
const CXXLifetimeExtendedObjectRegion * getCXXStaticLifetimeExtendedObjectRegion(const Expr *Ex, ValueDecl const *VD)
Create a CXXLifetimeExtendedObjectRegion for temporaries which are lifetime-extended by static refere...
const BlockDataRegion * getBlockDataRegion(const BlockCodeRegion *bc, const StackFrame *SF, unsigned blockCount)
getBlockDataRegion - Get the memory region associated with an instance of a block.
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.
virtual bool canPrintPrettyAsExpr() const
Returns true if this region's textual representation can be used as part of a larger expression.
virtual void Profile(llvm::FoldingSetNodeID &ID) const =0
LLVM_ATTRIBUTE_RETURNS_NONNULL const RegionTy * castAs() const
const MemSpace * getMemorySpaceAs(ProgramStateRef State) const
virtual bool isBoundable() const
StringRef getKindStr() const
RegionOffset getAsOffset() const
Compute the offset within the top level memory object.
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemRegion * StripCasts(bool StripBaseAndDerivedCasts=true) const
bool hasMemorySpace(ProgramStateRef State) const
const MemSpace * getRawMemorySpaceAs() const
Deprecated. Use getMemorySpace(ProgramStateRef) instead.
ProgramStateRef setMemorySpace(ProgramStateRef State, const MemSpaceRegion *Space) const
Set the dynamically deduced memory space of a MemRegion that currently has UnknownSpaceRegion.
ASTContext & getContext() const
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemSpaceRegion * getMemorySpace(ProgramStateRef State) const
Returns the most specific memory space for this memory region in the given ProgramStateRef.
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.
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...
LLVM_ATTRIBUTE_RETURNS_NONNULL const MemSpaceRegion * getRawMemorySpace() const
Deprecated.
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
friend class MemRegionManager
static bool classof(const MemRegion *R)
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
friend class MemRegionManager
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
friend class MemRegionManager
ParamVarRegion - Represents a region for parameters.
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
friend class MemRegionManager
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
friend class ElementRegion
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
friend class MemRegionManager
static bool classof(const MemRegion *R)
void dumpToStream(raw_ostream &os) const override
friend class MemRegionManager
static bool classof(const MemRegion *R)
LLVM_ATTRIBUTE_RETURNS_NONNULL const StackFrame * getStackFrame() const
void Profile(llvm::FoldingSetNodeID &ID) const override
StackSpaceRegion(MemRegionManager &mgr, Kind k, const StackFrame *SF)
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
friend class MemRegionManager
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
friend class MemRegionManager
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
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)
friend class MemRegionManager
QualType getPointeeStaticType() const
Gets the type of the wrapped symbol.
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)
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)
friend class MemRegionManager
QualType getValueType() const override
const VarDecl * getDecl() const override=0
VarRegion(const MemRegion *sReg, Kind k)
const StackFrame * getStackFrame() const
It might return null.
static bool classof(const MemRegion *R)
friend class MemRegionManager
Value representing integer constant.
APSIntPtr getValue() const
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
const SymExpr * SymbolRef
raw_ostream & operator<<(raw_ostream &os, const MemRegion *R)
The JSON file list parser is used to communicate input to InstallAPI.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
bool isa(CodeGen::Address addr)
U cast(CodeGen::Address addr)