clang 20.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 ()
 
const ASTContextgetContext () const
 
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.
 
const StackArgumentsSpaceRegiongetStackArgumentsRegion (const StackFrameContext *STC)
 getStackArgumentsRegion - Retrieve the memory region associated with function/method arguments of the specified stack frame.
 
const GlobalsSpaceRegiongetGlobalsRegion (MemRegion::Kind K=MemRegion::GlobalInternalSpaceRegionKind, const CodeTextRegion *R=nullptr)
 getGlobalsRegion - Retrieve the memory region associated with global variables.
 
const HeapSpaceRegiongetHeapRegion ()
 getHeapRegion - Retrieve the memory region associated with the generic "heap".
 
const UnknownSpaceRegiongetUnknownRegion ()
 getUnknownRegion - Retrieve the memory region associated with unknown memory space.
 
const CodeSpaceRegiongetCodeRegion ()
 
const AllocaRegiongetAllocaRegion (const Expr *Ex, unsigned Cnt, const LocationContext *LC)
 getAllocaRegion - Retrieve a region associated with a call to alloca().
 
const CompoundLiteralRegiongetCompoundLiteralRegion (const CompoundLiteralExpr *CL, const LocationContext *LC)
 getCompoundLiteralRegion - Retrieve the region associated with a given CompoundLiteral.
 
const CXXThisRegiongetCXXThisRegion (QualType thisPointerTy, const LocationContext *LC)
 getCXXThisRegion - Retrieve the [artificial] region associated with the parameter 'this'.
 
const SymbolicRegiongetSymbolicRegion (SymbolRef Sym, const MemSpaceRegion *MemSpace=nullptr)
 Retrieve or create a "symbolic" memory region.
 
const SymbolicRegiongetSymbolicHeapRegion (SymbolRef sym)
 Return a unique symbolic region belonging to heap memory space.
 
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.
 
const NonParamVarRegiongetNonParamVarRegion (const VarDecl *VD, const MemRegion *superR)
 getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationContext.
 
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.
 
const ElementRegiongetElementRegion (QualType elementType, NonLoc Idx, const SubRegion *superRegion, const ASTContext &Ctx)
 getElementRegion - Retrieve the memory region associated with the associated element type, index, and super region.
 
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.
 
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.
 
const CXXTempObjectRegiongetCXXTempObjectRegion (Expr const *Ex, LocationContext const *LC)
 
const CXXLifetimeExtendedObjectRegiongetCXXLifetimeExtendedObjectRegion (Expr const *Ex, ValueDecl const *VD, LocationContext const *LC)
 Create a CXXLifetimeExtendedObjectRegion for temporaries which are lifetime-extended by local references.
 
const CXXLifetimeExtendedObjectRegiongetCXXStaticLifetimeExtendedObjectRegion (const Expr *Ex, ValueDecl const *VD)
 Create a CXXLifetimeExtendedObjectRegion for temporaries which are lifetime-extended by static references.
 
const CXXBaseObjectRegiongetCXXBaseObjectRegion (const CXXRecordDecl *BaseClass, const SubRegion *Super, bool IsVirtual)
 Create a CXXBaseObjectRegion with the given base class for region Super.
 
const CXXBaseObjectRegiongetCXXBaseObjectRegionWithSuper (const CXXBaseObjectRegion *baseReg, const SubRegion *superRegion)
 Create a CXXBaseObjectRegion with the same CXXRecordDecl but a different super region.
 
const CXXDerivedObjectRegiongetCXXDerivedObjectRegion (const CXXRecordDecl *BaseClass, const SubRegion *Super)
 Create a CXXDerivedObjectRegion with the given derived class for region Super.
 
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.
 

Detailed Description

Definition at line 1404 of file MemRegion.h.

Constructor & Destructor Documentation

◆ MemRegionManager()

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

Definition at line 1426 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 1344 of file MemRegion.cpp.

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

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

◆ getAllocator()

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

Definition at line 1432 of file MemRegion.h.

◆ getBlockCodeRegion()

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

Definition at line 1220 of file MemRegion.cpp.

References getCodeRegion().

Referenced by clang::ento::SValBuilder::getBlockPointer(), and getVarRegion().

◆ 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 1145 of file MemRegion.cpp.

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

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

◆ getCodeRegion()

const CodeSpaceRegion * MemRegionManager::getCodeRegion ( )

Definition at line 977 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 1177 of file MemRegion.cpp.

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

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

◆ getContext() [1/2]

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

Definition at line 1429 of file MemRegion.h.

Referenced by clang::ento::MemRegion::getContext(), and getVarRegion().

◆ getContext() [2/2]

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

Definition at line 1430 of file MemRegion.h.

◆ 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 1297 of file MemRegion.cpp.

References isValidBaseClass().

Referenced by clang::ento::ExprEngine::computeObjectUnderConstruction(), clang::ento::StoreManager::evalDerivedToBase(), 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 1565 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 1317 of file MemRegion.cpp.

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

◆ getCXXLifetimeExtendedObjectRegion()

const CXXLifetimeExtendedObjectRegion * MemRegionManager::getCXXLifetimeExtendedObjectRegion ( Expr const *  Ex,
ValueDecl const *  VD,
LocationContext const *  LC 
)

Create a CXXLifetimeExtendedObjectRegion for temporaries which are lifetime-extended by local references.

Definition at line 1258 of file MemRegion.cpp.

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

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

◆ getCXXStaticLifetimeExtendedObjectRegion()

const CXXLifetimeExtendedObjectRegion * MemRegionManager::getCXXStaticLifetimeExtendedObjectRegion ( const Expr Ex,
ValueDecl const *  VD 
)

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

This differs from getCXXLifetimeExtendedObjectRegion(Expr const *, ValueDecl const *, LocationContext const *) in the super-region used.

Definition at line 1267 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,
const ASTContext Ctx 
)

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

Definition at line 1193 of file MemRegion.cpp.

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

Referenced by bindRequiredArrayElementToEnvironment(), clang::ento::ExprEngine::computeObjectUnderConstruction(),