clang  14.0.0git
Public Member Functions | List of all members
clang::ento::MemRegionManager Class Reference

#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"

Public Member Functions

 MemRegionManager (ASTContext &c, llvm::BumpPtrAllocator &a)
 
 ~MemRegionManager ()
 
ASTContextgetContext ()
 
llvm::BumpPtrAllocator & getAllocator ()
 
DefinedOrUnknownSVal getStaticSize (const MemRegion *MR, SValBuilder &SVB) const
 
const StackLocalsSpaceRegiongetStackLocalsRegion (const StackFrameContext *STC)
 getStackLocalsRegion - Retrieve the memory region associated with the specified stack frame. More...
 
const StackArgumentsSpaceRegiongetStackArgumentsRegion (const StackFrameContext *STC)
 getStackArgumentsRegion - Retrieve the memory region associated with function/method arguments of the specified stack frame. More...
 
const GlobalsSpaceRegiongetGlobalsRegion (MemRegion::Kind K=MemRegion::GlobalInternalSpaceRegionKind, const CodeTextRegion *R=nullptr)
 getGlobalsRegion - Retrieve the memory region associated with global variables. More...
 
const HeapSpaceRegiongetHeapRegion ()
 getHeapRegion - Retrieve the memory region associated with the generic "heap". More...
 
const UnknownSpaceRegiongetUnknownRegion ()
 getUnknownRegion - Retrieve the memory region associated with unknown memory space. More...
 
const CodeSpaceRegiongetCodeRegion ()
 
const AllocaRegiongetAllocaRegion (const Expr *Ex, unsigned Cnt, const LocationContext *LC)
 getAllocaRegion - Retrieve a region associated with a call to alloca(). More...
 
const CompoundLiteralRegiongetCompoundLiteralRegion (const CompoundLiteralExpr *CL, const LocationContext *LC)
 getCompoundLiteralRegion - Retrieve the region associated with a given CompoundLiteral. More...
 
const CXXThisRegiongetCXXThisRegion (QualType thisPointerTy, const LocationContext *LC)
 getCXXThisRegion - Retrieve the [artificial] region associated with the parameter 'this'. More...
 
const SymbolicRegiongetSymbolicRegion (SymbolRef Sym)
 Retrieve or create a "symbolic" memory region. More...
 
const SymbolicRegiongetSymbolicHeapRegion (SymbolRef sym)
 Return a unique symbolic region belonging to heap memory space. More...
 
const StringRegiongetStringRegion (const StringLiteral *Str)
 
const ObjCStringRegiongetObjCStringRegion (const ObjCStringLiteral *Str)
 
const VarRegiongetVarRegion (const VarDecl *VD, const LocationContext *LC)
 getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationContext. More...
 
const NonParamVarRegiongetNonParamVarRegion (const VarDecl *VD, const MemRegion *superR)
 getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationContext. More...
 
const ParamVarRegiongetParamVarRegion (const Expr *OriginExpr, unsigned Index, const LocationContext *LC)
 getParamVarRegion - Retrieve or create the memory region associated with a specified CallExpr, Index and LocationContext. More...
 
const ElementRegiongetElementRegion (QualType elementType, NonLoc Idx, const SubRegion *superRegion, ASTContext &Ctx)
 getElementRegion - Retrieve the memory region associated with the associated element type, index, and super region. More...
 
const ElementRegiongetElementRegionWithSuper (const ElementRegion *ER, const SubRegion *superRegion)
 
const FieldRegiongetFieldRegion (const FieldDecl *fd, const SubRegion *superRegion)
 getFieldRegion - Retrieve or create the memory region associated with a specified FieldDecl. More...
 
const FieldRegiongetFieldRegionWithSuper (const FieldRegion *FR, const SubRegion *superRegion)
 
const ObjCIvarRegiongetObjCIvarRegion (const ObjCIvarDecl *ivd, const SubRegion *superRegion)
 getObjCIvarRegion - Retrieve or create the memory region associated with a specified Objective-c instance variable. More...
 
const CXXTempObjectRegiongetCXXTempObjectRegion (Expr const *Ex, LocationContext const *LC)
 
const CXXBaseObjectRegiongetCXXBaseObjectRegion (const CXXRecordDecl *BaseClass, const SubRegion *Super, bool IsVirtual)
 Create a CXXBaseObjectRegion with the given base class for region Super. More...
 
const CXXBaseObjectRegiongetCXXBaseObjectRegionWithSuper (const CXXBaseObjectRegion *baseReg, const SubRegion *superRegion)
 Create a CXXBaseObjectRegion with the same CXXRecordDecl but a different super region. More...
 
const CXXDerivedObjectRegiongetCXXDerivedObjectRegion (const CXXRecordDecl *BaseClass, const SubRegion *Super)
 Create a CXXDerivedObjectRegion with the given derived class for region Super. More...
 
const FunctionCodeRegiongetFunctionCodeRegion (const NamedDecl *FD)
 
const BlockCodeRegiongetBlockCodeRegion (const BlockDecl *BD, CanQualType locTy, AnalysisDeclContext *AC)
 
const BlockDataRegiongetBlockDataRegion (const BlockCodeRegion *bc, const LocationContext *lc, unsigned blockCount)
 getBlockDataRegion - Get the memory region associated with an instance of a block. More...
 
const CXXTempObjectRegiongetCXXStaticTempObjectRegion (const Expr *Ex)
 Create a CXXTempObjectRegion for temporaries which are lifetime-extended by static references. More...
 
template<typename RegionTy , typename SuperTy , typename Arg1Ty >
RegionTy * getSubRegion (const Arg1Ty arg1, const SuperTy *superRegion)
 
template<typename RegionTy , typename SuperTy , typename Arg1Ty , typename Arg2Ty >
RegionTy * getSubRegion (const Arg1Ty arg1, const Arg2Ty arg2, const SuperTy *superRegion)
 
template<typename RegionTy , typename SuperTy , typename Arg1Ty , typename Arg2Ty , typename Arg3Ty >
RegionTy * getSubRegion (const Arg1Ty arg1, const Arg2Ty arg2, const Arg3Ty arg3, const SuperTy *superRegion)
 
template<typename REG >
const REG * LazyAllocate (REG *&region)
 
template<typename REG , typename ARG >
const REG * LazyAllocate (REG *&region, ARG a)
 

Detailed Description

Definition at line 1302 of file MemRegion.h.

Constructor & Destructor Documentation

◆ MemRegionManager()

clang::ento::MemRegionManager::MemRegionManager ( ASTContext c,
llvm::BumpPtrAllocator &  a 
)
inline

Definition at line 1324 of file MemRegion.h.

◆ ~MemRegionManager()

MemRegionManager::~MemRegionManager ( )
default

Member Function Documentation

◆ getAllocaRegion()

const AllocaRegion * MemRegionManager::getAllocaRegion ( const Expr Ex,
unsigned  Cnt,
const LocationContext LC 
)

getAllocaRegion - Retrieve a region associated with a call to alloca().

Definition at line 1255 of file MemRegion.cpp.

References clang::LocationContext::getStackFrame(), and getStackLocalsRegion().

◆ getAllocator()

llvm::BumpPtrAllocator& clang::ento::MemRegionManager::getAllocator ( )
inline

Definition at line 1329 of file MemRegion.h.

◆ getBlockCodeRegion()

const BlockCodeRegion * MemRegionManager::getBlockCodeRegion ( const BlockDecl BD,
CanQualType  locTy,
AnalysisDeclContext AC 
)

Definition at line 1151 of file MemRegion.cpp.

References getCodeRegion().

Referenced by clang::ento::SValBuilder::getBlockPointer().

◆ getBlockDataRegion()

const BlockDataRegion * MemRegionManager::getBlockDataRegion ( const BlockCodeRegion bc,
const LocationContext lc,
unsigned  blockCount 
)

getBlockDataRegion - Get the memory region associated with an instance of a block.

Unlike many other MemRegions, the LocationContext* argument is allowed to be NULL for cases where we have no known context.

Definition at line 1073 of file MemRegion.cpp.

References clang::ento::BlockCodeRegion::getDecl(), getGlobalsRegion(), clang::LocationContext::getStackFrame(), getStackLocalsRegion(), getUnknownRegion(), and clang::BlockDecl::hasCaptures().

Referenced by clang::ento::SValBuilder::getBlockPointer().

◆ getCodeRegion()

const CodeSpaceRegion * MemRegionManager::getCodeRegion ( )

Definition at line 896 of file MemRegion.cpp.

Referenced by getBlockCodeRegion(), and getFunctionCodeRegion().

◆ getCompoundLiteralRegion()

const CompoundLiteralRegion * MemRegionManager::getCompoundLiteralRegion ( const CompoundLiteralExpr CL,
const LocationContext LC 
)

getCompoundLiteralRegion - Retrieve the region associated with a given CompoundLiteral.

Definition at line 1107 of file MemRegion.cpp.

References getGlobalsRegion(), clang::LocationContext::getStackFrame(), getStackLocalsRegion(), and clang::CompoundLiteralExpr::isFileScope().

Referenced by clang::ento::StoreManager::getLValueCompoundLiteral().

◆ getContext()

ASTContext& clang::ento::MemRegionManager::getContext ( )
inline

Definition at line 1327 of file MemRegion.h.

Referenced by clang::ento::MemRegion::getContext().

◆ getCXXBaseObjectRegion()

const CXXBaseObjectRegion * MemRegionManager::getCXXBaseObjectRegion ( const CXXRecordDecl BaseClass,
const SubRegion Super,
bool  IsVirtual 
)

Create a CXXBaseObjectRegion with the given base class for region Super.

The type of Super is assumed be a class deriving from BaseClass.

Definition at line 1208 of file MemRegion.cpp.

References isValidBaseClass().

Referenced by clang::ento::ExprEngine::computeObjectUnderConstruction(), and getCXXBaseObjectRegionWithSuper().

◆ getCXXBaseObjectRegionWithSuper()

const CXXBaseObjectRegion* clang::ento::MemRegionManager::getCXXBaseObjectRegionWithSuper ( const CXXBaseObjectRegion baseReg,
const SubRegion superRegion 
)
inline

Create a CXXBaseObjectRegion with the same CXXRecordDecl but a different super region.

Definition at line 1447 of file MemRegion.h.

References getCXXBaseObjectRegion(), clang::ento::CXXBaseObjectRegion::getDecl(), and clang::ento::CXXBaseObjectRegion::isVirtual().

◆ getCXXDerivedObjectRegion()

const CXXDerivedObjectRegion * MemRegionManager::getCXXDerivedObjectRegion ( const CXXRecordDecl BaseClass,
const SubRegion Super 
)

Create a CXXDerivedObjectRegion with the given derived class for region Super.

This should not be used for casting an existing CXXBaseObjectRegion back to the derived type; instead, CXXBaseObjectRegion should be removed.

Definition at line 1228 of file MemRegion.cpp.

◆ getCXXStaticTempObjectRegion()

const CXXTempObjectRegion * MemRegionManager::getCXXStaticTempObjectRegion ( const Expr Ex)

Create a CXXTempObjectRegion for temporaries which are lifetime-extended by static references.

This differs from getCXXTempObjectRegion in the super-region used.

Definition at line 1101 of file MemRegion.cpp.

References getGlobalsRegion().

Referenced by clang::ento::ExprEngine::computeObjectUnderConstruction().

◆ getCXXTempObjectRegion()

const CXXTempObjectRegion * MemRegionManager::getCXXTempObjectRegion ( Expr const *  Ex,
LocationContext const *  LC 
)

◆ getCXXThisRegion()

const CXXThisRegion * MemRegionManager::getCXXThisRegion ( QualType  thisPointerTy,
const LocationContext LC 
)

◆ getElementRegion()

const ElementRegion * MemRegionManager::getElementRegion ( QualType  elementType,
NonLoc  Idx,
const SubRegion superRegion,
ASTContext Ctx 
)

getElementRegion - Retrieve the memory region associated with the associated element type, index, and super region.

Definition at line 1123 of file MemRegion.cpp.

References clang::ASTContext::getCanonicalType(), and clang::CanQual< T >::getUnqualifiedType().

Referenced by getElementRegionWithSuper(), clang::ento::StoreManager::GetElementZeroRegion(), and clang::ento::StoreManager::MakeElementRegion().

◆ getElementRegionWithSuper()

const ElementRegion* clang::ento::MemRegionManager::getElementRegionWithSuper ( const ElementRegion ER,
const SubRegion superRegion 
)
inline

◆ getFieldRegion()

const FieldRegion * MemRegionManager::getFieldRegion ( const FieldDecl fd,
const SubRegion superRegion 
)

getFieldRegion - Retrieve or create the memory region associated with a specified FieldDecl.

'superRegion' corresponds to the containing memory region (which typically represents the memory representing a structure or class).

Definition at line 1166 of file MemRegion.cpp.

Referenced by getFieldRegionWithSuper().

◆ getFieldRegionWithSuper()

const FieldRegion* clang::ento::MemRegionManager::getFieldRegionWithSuper ( const FieldRegion FR,
const SubRegion superRegion 
)
inline

Definition at line 1421 of file MemRegion.h.

References clang::ento::FieldRegion::getDecl(), and getFieldRegion().

◆ getFunctionCodeRegion()

const FunctionCodeRegion * MemRegionManager::getFunctionCodeRegion ( const NamedDecl FD)

Definition at line 1145 of file MemRegion.cpp.

References getCodeRegion().

Referenced by clang::ento::SValBuilder::getFunctionPointer().

◆ getGlobalsRegion()

const GlobalsSpaceRegion * MemRegionManager::getGlobalsRegion ( MemRegion::Kind  K = MemRegion::GlobalInternalSpaceRegionKind,
const CodeTextRegion R = nullptr 
)

getGlobalsRegion - Retrieve the memory region associated with global variables.

Definition at line 867 of file MemRegion.cpp.

Referenced by getBlockDataRegion(), getCompoundLiteralRegion(), getCXXStaticTempObjectRegion(), getObjCStringRegion(), getStringRegion(), and clang::ento::getWidenedLoopState().

◆ getHeapRegion()

const HeapSpaceRegion * MemRegionManager::getHeapRegion ( )

getHeapRegion - Retrieve the memory region associated with the generic "heap".

Definition at line 888 of file MemRegion.cpp.

Referenced by getSymbolicHeapRegion().

◆ getNonParamVarRegion()

const NonParamVarRegion * MemRegionManager::getNonParamVarRegion ( const VarDecl VD,
const MemRegion superR 
)

getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationContext.

Definition at line 1057 of file MemRegion.cpp.

References clang::VarDecl::getCanonicalDecl().

◆ getObjCIvarRegion()

const ObjCIvarRegion * MemRegionManager::getObjCIvarRegion ( const ObjCIvarDecl ivd,
const SubRegion superRegion 
)

getObjCIvarRegion - Retrieve or create the memory region associated with a specified Objective-c instance variable.

'superRegion' corresponds to the containing region (which typically represents the Objective-C object).

Definition at line 1172 of file MemRegion.cpp.

◆ getObjCStringRegion()

const ObjCStringRegion * MemRegionManager::getObjCStringRegion ( const ObjCStringLiteral Str)

Definition at line 910 of file MemRegion.cpp.

References getGlobalsRegion().

◆ getParamVarRegion()

const ParamVarRegion * MemRegionManager::getParamVarRegion ( const Expr OriginExpr,
unsigned  Index,
const LocationContext LC 
)

getParamVarRegion - Retrieve or create the memory region associated with a specified CallExpr, Index and LocationContext.

Definition at line 1064 of file MemRegion.cpp.

◆ getStackArgumentsRegion()

const StackArgumentsSpaceRegion * MemRegionManager::getStackArgumentsRegion ( const StackFrameContext STC)

getStackArgumentsRegion - Retrieve the memory region associated with function/method arguments of the specified stack frame.

Definition at line 854 of file MemRegion.cpp.

Referenced by getCXXThisRegion(), and clang::ento::getWidenedLoopState().

◆ getStackLocalsRegion()

const StackLocalsSpaceRegion * MemRegionManager::getStackLocalsRegion ( const StackFrameContext STC)

getStackLocalsRegion - Retrieve the memory region associated with the specified stack frame.

Definition at line 841 of file MemRegion.cpp.

Referenced by getAllocaRegion(), getBlockDataRegion(), getCompoundLiteralRegion(), getCXXTempObjectRegion(), and clang::ento::getWidenedLoopState().

◆ getStaticSize()

DefinedOrUnknownSVal MemRegionManager::getStaticSize ( const MemRegion MR,
SValBuilder SVB 
) const

◆ getStringRegion()

const StringRegion * MemRegionManager::getStringRegion ( const StringLiteral Str)

Definition at line 904 of file MemRegion.cpp.

References getGlobalsRegion().

◆ getSubRegion() [1/3]

template<typename RegionTy , typename SuperTy , typename Arg1Ty , typename Arg2Ty , typename Arg3Ty >
RegionTy* clang::ento::MemRegionManager::getSubRegion ( const Arg1Ty  arg1,
const Arg2Ty  arg2,
const Arg3Ty  arg3,
const SuperTy *  superRegion 
)

Definition at line 103 of file MemRegion.cpp.

◆ getSubRegion() [2/3]

template<typename RegionTy , typename SuperTy , typename Arg1Ty , typename Arg2Ty >
RegionTy* clang::ento::MemRegionManager::getSubRegion ( const Arg1Ty  arg1,
const Arg2Ty  arg2,
const SuperTy *  superRegion 
)

Definition at line 85 of file MemRegion.cpp.

◆ getSubRegion() [3/3]

template<typename RegionTy , typename SuperTy , typename Arg1Ty >
RegionTy* clang::ento::MemRegionManager::getSubRegion ( const Arg1Ty  arg1,
const SuperTy *  superRegion 
)

Definition at line 68 of file MemRegion.cpp.

◆ getSymbolicHeapRegion()

const SymbolicRegion * MemRegionManager::getSymbolicHeapRegion ( SymbolRef  sym)

Return a unique symbolic region belonging to heap memory space.

Definition at line 1161 of file MemRegion.cpp.

References getHeapRegion().

◆ getSymbolicRegion()

const SymbolicRegion * MemRegionManager::getSymbolicRegion ( SymbolRef  Sym)

Retrieve or create a "symbolic" memory region.

getSymbolicRegion - Retrieve or create a "symbolic" memory region.

Definition at line 1157 of file MemRegion.cpp.

References getUnknownRegion().

Referenced by clang::ento::SValBuilder::conjureSymbolVal(), clang::ento::SValBuilder::getDerivedRegionValueSymbolVal(), clang::ento::SValBuilder::getMetadataSymbolVal(), clang::ento::SValBuilder::getRegionValueSymbolVal(), and clang::ento::SValBuilder::makeLoc().

◆ getUnknownRegion()

const UnknownSpaceRegion * MemRegionManager::getUnknownRegion ( )

getUnknownRegion - Retrieve the memory region associated with unknown memory space.

Definition at line 892 of file MemRegion.cpp.

Referenced by getBlockDataRegion(), and getSymbolicRegion().

◆ getVarRegion()

const VarRegion * MemRegionManager::getVarRegion ( const VarDecl VD,
const LocationContext LC 
)

◆ LazyAllocate() [1/2]

template<typename REG >
const REG* clang::ento::MemRegionManager::LazyAllocate ( REG *&  region)

Definition at line 821 of file MemRegion.cpp.

◆ LazyAllocate() [2/2]

template<typename REG , typename ARG >
const REG* clang::ento::MemRegionManager::LazyAllocate ( REG *&  region,
ARG  a 
)

Definition at line 831 of file MemRegion.cpp.


The documentation for this class was generated from the following files: