clang 20.0.0git
|
#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
Public Member Functions | |
MemRegionManager (ASTContext &c, llvm::BumpPtrAllocator &a) | |
~MemRegionManager () | |
ASTContext & | getContext () |
const ASTContext & | getContext () const |
llvm::BumpPtrAllocator & | getAllocator () |
DefinedOrUnknownSVal | getStaticSize (const MemRegion *MR, SValBuilder &SVB) const |
const StackLocalsSpaceRegion * | getStackLocalsRegion (const StackFrameContext *STC) |
getStackLocalsRegion - Retrieve the memory region associated with the specified stack frame. | |
const StackArgumentsSpaceRegion * | getStackArgumentsRegion (const StackFrameContext *STC) |
getStackArgumentsRegion - Retrieve the memory region associated with function/method arguments of the specified stack frame. | |
const GlobalsSpaceRegion * | getGlobalsRegion (MemRegion::Kind K=MemRegion::GlobalInternalSpaceRegionKind, const CodeTextRegion *R=nullptr) |
getGlobalsRegion - Retrieve the memory region associated with global variables. | |
const HeapSpaceRegion * | getHeapRegion () |
getHeapRegion - Retrieve the memory region associated with the generic "heap". | |
const UnknownSpaceRegion * | getUnknownRegion () |
getUnknownRegion - Retrieve the memory region associated with unknown memory space. | |
const CodeSpaceRegion * | getCodeRegion () |
const AllocaRegion * | getAllocaRegion (const Expr *Ex, unsigned Cnt, const LocationContext *LC) |
getAllocaRegion - Retrieve a region associated with a call to alloca(). | |
const CompoundLiteralRegion * | getCompoundLiteralRegion (const CompoundLiteralExpr *CL, const LocationContext *LC) |
getCompoundLiteralRegion - Retrieve the region associated with a given CompoundLiteral. | |
const CXXThisRegion * | getCXXThisRegion (QualType thisPointerTy, const LocationContext *LC) |
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 SymbolicRegion * | getSymbolicHeapRegion (SymbolRef sym) |
Return a unique symbolic region belonging to heap memory space. | |
const StringRegion * | getStringRegion (const StringLiteral *Str) |
const ObjCStringRegion * | getObjCStringRegion (const ObjCStringLiteral *Str) |
const VarRegion * | getVarRegion (const VarDecl *VD, const LocationContext *LC) |
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationContext. | |
const NonParamVarRegion * | getNonParamVarRegion (const VarDecl *VD, const MemRegion *superR) |
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationContext. | |
const ParamVarRegion * | getParamVarRegion (const Expr *OriginExpr, unsigned Index, const LocationContext *LC) |
getParamVarRegion - Retrieve or create the memory region associated with a specified CallExpr, Index and LocationContext. | |
const ElementRegion * | 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. | |
const ElementRegion * | getElementRegionWithSuper (const ElementRegion *ER, const SubRegion *superRegion) |
const FieldRegion * | getFieldRegion (const FieldDecl *fd, const SubRegion *superRegion) |
getFieldRegion - Retrieve or create the memory region associated with a specified FieldDecl. | |
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 instance variable. | |
const CXXTempObjectRegion * | getCXXTempObjectRegion (Expr const *Ex, LocationContext const *LC) |
const CXXLifetimeExtendedObjectRegion * | getCXXLifetimeExtendedObjectRegion (Expr const *Ex, ValueDecl const *VD, LocationContext const *LC) |
Create a CXXLifetimeExtendedObjectRegion for temporaries which are lifetime-extended by local references. | |
const CXXLifetimeExtendedObjectRegion * | getCXXStaticLifetimeExtendedObjectRegion (const Expr *Ex, ValueDecl const *VD) |
Create a CXXLifetimeExtendedObjectRegion for temporaries which are lifetime-extended by static references. | |
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. | |
const CXXDerivedObjectRegion * | getCXXDerivedObjectRegion (const CXXRecordDecl *BaseClass, const SubRegion *Super) |
Create a CXXDerivedObjectRegion with the given derived class for region Super . | |
const FunctionCodeRegion * | getFunctionCodeRegion (const NamedDecl *FD) |
const BlockCodeRegion * | getBlockCodeRegion (const BlockDecl *BD, CanQualType locTy, AnalysisDeclContext *AC) |
const BlockDataRegion * | getBlockDataRegion (const BlockCodeRegion *bc, const LocationContext *lc, unsigned blockCount) |
getBlockDataRegion - Get the memory region associated with an instance of a block. | |
Definition at line 1404 of file MemRegion.h.
|
inline |
Definition at line 1426 of file MemRegion.h.
|
default |
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 1321 of file MemRegion.cpp.
References E, clang::LocationContext::getStackFrame(), and getStackLocalsRegion().
Referenced by clang::ento::SValBuilder::getAllocaRegionVal().
|
inline |
Definition at line 1432 of file MemRegion.h.
const BlockCodeRegion * MemRegionManager::getBlockCodeRegion | ( | const BlockDecl * | BD, |
CanQualType | locTy, | ||
AnalysisDeclContext * | AC | ||
) |
Definition at line 1197 of file MemRegion.cpp.
References getCodeRegion().
Referenced by clang::ento::SValBuilder::getBlockPointer(), and getVarRegion().
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 1122 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().
const CodeSpaceRegion * MemRegionManager::getCodeRegion | ( | ) |
Definition at line 954 of file MemRegion.cpp.
Referenced by getBlockCodeRegion(), and getFunctionCodeRegion().
const CompoundLiteralRegion * MemRegionManager::getCompoundLiteralRegion | ( | const CompoundLiteralExpr * | CL, |
const LocationContext * | LC | ||
) |
getCompoundLiteralRegion - Retrieve the region associated with a given CompoundLiteral.
Definition at line 1154 of file MemRegion.cpp.
References getGlobalsRegion(), clang::LocationContext::getStackFrame(), getStackLocalsRegion(), and clang::CompoundLiteralExpr::isFileScope().
Referenced by clang::ento::StoreManager::getLValueCompoundLiteral().
|
inline |
Definition at line 1429 of file MemRegion.h.
Referenced by clang::ento::MemRegion::getContext(), and getVarRegion().
|
inline |
Definition at line 1430 of file MemRegion.h.
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 1274 of file MemRegion.cpp.
References isValidBaseClass().
Referenced by clang::ento::ExprEngine::computeObjectUnderConstruction(), clang::ento::StoreManager::evalDerivedToBase(), and getCXXBaseObjectRegionWithSuper().
|
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().
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 1294 of file MemRegion.cpp.
Referenced by clang::ento::StoreManager::evalBaseToDerived().
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 1235 of file MemRegion.cpp.
References clang::LocationContext::getStackFrame(), and getStackLocalsRegion().
Referenced by clang::ento::ExprEngine::computeObjectUnderConstruction().
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 1244 of file MemRegion.cpp.
References getGlobalsRegion().
Referenced by clang::ento::ExprEngine::computeObjectUnderConstruction().
const CXXTempObjectRegion * MemRegionManager::getCXXTempObjectRegion | ( | Expr const * | Ex, |
LocationContext const * | LC | ||
) |
Definition at line 1227 of file MemRegion.cpp.
References E, clang::LocationContext::getStackFrame(), and getStackLocalsRegion().
Referenced by clang::ento::ExprEngine::computeObjectUnderConstruction(), clang::ento::ExprEngine::VisitCXXDestructor(), and clang::ento::ExprEngine::VisitLambdaExpr().
const CXXThisRegion * MemRegionManager::getCXXThisRegion | ( | QualType | thisPointerTy, |
const LocationContext * | LC | ||
) |
getCXXThisRegion - Retrieve the [artificial] region associated with the parameter 'this'.
Definition at line 1300 of file MemRegion.cpp.
References D, clang::Type::getAs(), clang::LocationContext::getDecl(), clang::LocationContext::getParent(), getStackArgumentsRegion(), clang::LocationContext::getStackFrame(), and clang::LocationContext::inTopFrame().
Referenced by clang::ento::getWidenedLoopState(), and clang::ento::ExprEngine::VisitCXXThisExpr().
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 1170 of file MemRegion.cpp.
References clang::ASTContext::getCanonicalType(), clang::CanQual< T >::getUnqualifiedType(), and clang::T.
Referenced by clang::ento::ExprEngine::computeObjectUnderConstruction(), getElementRegionWithSuper(), clang::ento::StoreManager::GetElementZeroRegion(), clang::ento::StoreManager::getLValueElement(), clang::ento::StoreManager::MakeElementRegion(), and clang::ento::ExprEngine::VisitCXXNewExpr().
|
inline |
Definition at line 1513 of file MemRegion.h.
References clang::ento::MemRegion::getContext(), getElementRegion(), clang::ento::ElementRegion::getElementType(), and clang::ento::ElementRegion::getIndex().
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 1215 of file MemRegion.cpp.
Referenced by getFieldRegionWithSuper().
|
inline |
Definition at line 1526 of file MemRegion.h.
References clang::ento::FieldRegion::getDecl(), and getFieldRegion().
const FunctionCodeRegion * MemRegionManager::getFunctionCodeRegion | ( | const NamedDecl * | FD | ) |
Definition at line 1191 of file MemRegion.cpp.
References getCodeRegion().
Referenced by clang::ento::SValBuilder::getFunctionPointer(), and getVarRegion().
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 926 of file MemRegion.cpp.
Referenced by getBlockDataRegion(), getCompoundLiteralRegion(), getCXXStaticLifetimeExtendedObjectRegion(), getObjCStringRegion(), getStringRegion(), getVarRegion(), and clang::ento::getWidenedLoopState().
const HeapSpaceRegion * MemRegionManager::getHeapRegion | ( | ) |
getHeapRegion - Retrieve the memory region associated with the generic "heap".
Definition at line 946 of file MemRegion.cpp.
Referenced by getSymbolicHeapRegion().
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 1103 of file MemRegion.cpp.
References D, and clang::Decl::getCanonicalDecl().
Referenced by getVarRegion().
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 1221 of file MemRegion.cpp.
const ObjCStringRegion * MemRegionManager::getObjCStringRegion | ( | const ObjCStringLiteral * | Str | ) |
Definition at line 968 of file MemRegion.cpp.
References getGlobalsRegion().
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 1113 of file MemRegion.cpp.
References getStackArgumentsRegion(), and clang::LocationContext::getStackFrame().
Referenced by addParameterValuesToBindings().
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 914 of file MemRegion.cpp.
Referenced by getCXXThisRegion(), getParamVarRegion(), getVarRegion(), and clang::ento::getWidenedLoopState().
const StackLocalsSpaceRegion * MemRegionManager::getStackLocalsRegion | ( | const StackFrameContext * | STC | ) |
getStackLocalsRegion - Retrieve the memory region associated with the specified stack frame.
Definition at line 902 of file MemRegion.cpp.
Referenced by getAllocaRegion(), getBlockDataRegion(), getCompoundLiteralRegion(), getCXXLifetimeExtendedObjectRegion(), getCXXTempObjectRegion(), getVarRegion(), and clang::ento::getWidenedLoopState().
DefinedOrUnknownSVal MemRegionManager::getStaticSize | ( | const MemRegion * | MR, |
SValBuilder & | SVB | ||
) | const |
MR
. MR
must be a 'SubRegion'. Definition at line 783 of file MemRegion.cpp.
References clang::ento::SValBuilder::getArrayIndexType(), clang::ASTContext::getAsArrayType(), clang::ento::getElementExtent(), clang::ento::SymbolManager::getExtentSymbol(), clang::ASTContext::getLangOpts(), clang::ento::SValBuilder::getSymbolManager(), clang::Type::isIncompleteType(), and clang::ento::SValBuilder::makeIntVal().
Referenced by collectSubRegionBindings().
const StringRegion * MemRegionManager::getStringRegion | ( | const StringLiteral * | Str | ) |
Definition at line 962 of file MemRegion.cpp.
References getGlobalsRegion().
const SymbolicRegion * MemRegionManager::getSymbolicHeapRegion | ( | SymbolRef | sym | ) |
Return a unique symbolic region belonging to heap memory space.
Definition at line 1210 of file MemRegion.cpp.
References getHeapRegion().
Referenced by clang::ento::SValBuilder::getConjuredHeapSymbolVal().
const SymbolicRegion * MemRegionManager::getSymbolicRegion | ( | SymbolRef | Sym, |
const MemSpaceRegion * | MemSpace = nullptr |
||
) |
Retrieve or create a "symbolic" memory region.
If no memory space is specified, UnknownSpaceRegion
will be used.
Definition at line 1203 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().
const UnknownSpaceRegion * MemRegionManager::getUnknownRegion | ( | ) |
getUnknownRegion - Retrieve the memory region associated with unknown memory space.
Definition at line 950 of file MemRegion.cpp.
Referenced by getBlockDataRegion(), getSymbolicRegion(), and getVarRegion().
const VarRegion * MemRegionManager::getVarRegion | ( | const VarDecl * | VD, |
const LocationContext * | LC | ||
) |
getVarRegion - Retrieve or create the memory region associated with a specified VarDecl and LocationContext.
Definition at line 1002 of file MemRegion.cpp.
References D, clang::Type::getAs(), getBlockCodeRegion(), clang::ASTContext::getBlockPointerType(), clang::StackFrameContext::getCallSite(), clang::Decl::getCanonicalDecl(), clang::ASTContext::getCanonicalType(), getContext(), clang::LocationContext::getDecl(), clang::ento::VarRegion::getDecl(), clang::Decl::getDeclContext(), getFunctionCodeRegion(), clang::ASTContext::getFunctionType(), getGlobalsRegion(), clang::Decl::getLocation(), getNonParamVarRegion(), clang::BlockDecl::getSignatureAsWritten(), clang::ASTContext::getSourceManager(), getStackArgumentsRegion(), clang::LocationContext::getStackFrame(), getStackLocalsRegion(), getStackOrCaptureRegionForDeclContext(), getUnknownRegion(), clang::QualType::isConstQualified(), clang::SourceManager::isInSystemHeader(), clang::QualType::isNull(), clang::BlockDecl::parameters(), clang::T, V, and clang::ASTContext::VoidTy.
Referenced by clang::ento::retaincountchecker::RetainCountChecker::checkPostStmt(), clang::ento::ObjCMethodCall::getInitialStackFrameContents(), clang::ento::StoreManager::getLValueVar(), clang::ento::ProgramState::getRegion(), and clang::ento::getWidenedLoopState().