clang API Documentation
MemRegion - The root abstract class for all memory regions. More...
#include <MemRegion.h>
Public Types | |
enum | Kind { GenericMemSpaceRegionKind, StackLocalsSpaceRegionKind, StackArgumentsSpaceRegionKind, HeapSpaceRegionKind, UnknownSpaceRegionKind, StaticGlobalSpaceRegionKind, GlobalInternalSpaceRegionKind, GlobalSystemSpaceRegionKind, GlobalImmutableSpaceRegionKind, BEG_NON_STATIC_GLOBAL_MEMSPACES = GlobalInternalSpaceRegionKind, END_NON_STATIC_GLOBAL_MEMSPACES = GlobalImmutableSpaceRegionKind, BEG_GLOBAL_MEMSPACES = StaticGlobalSpaceRegionKind, END_GLOBAL_MEMSPACES = GlobalImmutableSpaceRegionKind, BEG_MEMSPACES = GenericMemSpaceRegionKind, END_MEMSPACES = GlobalImmutableSpaceRegionKind, SymbolicRegionKind, AllocaRegionKind, BEG_TYPED_REGIONS, FunctionTextRegionKind = BEG_TYPED_REGIONS, BlockTextRegionKind, BlockDataRegionKind, BEG_TYPED_VALUE_REGIONS, CompoundLiteralRegionKind = BEG_TYPED_VALUE_REGIONS, CXXThisRegionKind, StringRegionKind, ObjCStringRegionKind, ElementRegionKind, BEG_DECL_REGIONS, VarRegionKind = BEG_DECL_REGIONS, FieldRegionKind, ObjCIvarRegionKind, END_DECL_REGIONS = ObjCIvarRegionKind, CXXTempObjectRegionKind, CXXBaseObjectRegionKind, END_TYPED_VALUE_REGIONS = CXXBaseObjectRegionKind, END_TYPED_REGIONS = CXXBaseObjectRegionKind } |
Public Member Functions | |
ASTContext & | getContext () const |
virtual void | Profile (llvm::FoldingSetNodeID &ID) const =0 |
virtual MemRegionManager * | getMemRegionManager () const =0 |
const MemSpaceRegion * | getMemorySpace () const |
const MemRegion * | getBaseRegion () const |
virtual bool | isSubRegionOf (const MemRegion *R) const |
Check if the region is a subregion of the given region. | |
const MemRegion * | StripCasts (bool StripBaseCasts=true) const |
const SymbolicRegion * | getSymbolicBase () const |
If this is a symbolic region, returns the region. Otherwise, goes up the base chain looking for the first symbolic base region. | |
bool | hasGlobalsOrParametersStorage () const |
bool | hasStackStorage () const |
bool | hasStackNonParametersStorage () const |
bool | hasStackParametersStorage () const |
RegionOffset | getAsOffset () const |
Compute the offset within the top level memory object. | |
std::string | getString () const |
Get a string representation of a region for debug use. | |
virtual void | dumpToStream (raw_ostream &os) const |
void | dump () const |
virtual bool | canPrintPretty () const |
Returns true if this region can be printed in a user-friendly way. | |
virtual void | printPretty (raw_ostream &os) const |
Print the region for use in diagnostics. | |
virtual bool | canPrintPrettyAsExpr () const |
Returns true if this region's textual representation can be used as part of a larger expression. | |
virtual void | printPrettyAsExpr (raw_ostream &os) const |
Print the region as expression. | |
Kind | getKind () const |
template<typename RegionTy > | |
const RegionTy * | getAs () const |
virtual bool | isBoundable () const |
Protected Member Functions | |
MemRegion (Kind k) | |
virtual | ~MemRegion () |
Friends | |
class | MemRegionManager |
MemRegion - The root abstract class for all memory regions.
Definition at line 77 of file MemRegion.h.
Definition at line 80 of file MemRegion.h.
clang::ento::MemRegion::MemRegion | ( | Kind | k | ) | [inline, protected] |
Definition at line 127 of file MemRegion.h.
MemRegion::~MemRegion | ( | ) | [protected, virtual] |
Definition at line 138 of file MemRegion.cpp.
bool MemRegion::canPrintPretty | ( | ) | const [virtual] |
Returns true if this region can be printed in a user-friendly way.
Reimplemented in clang::ento::FieldRegion.
Definition at line 568 of file MemRegion.cpp.
References canPrintPrettyAsExpr().
Referenced by printPretty(), and clang::ento::FindLastStoreBRVisitor::VisitNode().
bool MemRegion::canPrintPrettyAsExpr | ( | ) | const [virtual] |
Returns true if this region's textual representation can be used as part of a larger expression.
Reimplemented in clang::ento::CXXBaseObjectRegion, clang::ento::ObjCIvarRegion, clang::ento::FieldRegion, and clang::ento::VarRegion.
Definition at line 572 of file MemRegion.cpp.
Referenced by canPrintPretty(), clang::ento::FieldRegion::canPrintPrettyAsExpr(), and clang::ento::CXXBaseObjectRegion::canPrintPrettyAsExpr().
void MemRegion::dump | ( | ) | const |
Definition at line 441 of file MemRegion.cpp.
References dumpToStream().
void MemRegion::dumpToStream | ( | raw_ostream & | os | ) | const [virtual] |
Reimplemented in clang::ento::CXXBaseObjectRegion, clang::ento::CXXTempObjectRegion, clang::ento::ElementRegion, clang::ento::ObjCIvarRegion, clang::ento::FieldRegion, clang::ento::CXXThisRegion, clang::ento::VarRegion, clang::ento::CompoundLiteralRegion, clang::ento::ObjCStringRegion, clang::ento::StringRegion, clang::ento::SymbolicRegion, clang::ento::BlockDataRegion, clang::ento::BlockTextRegion, clang::ento::FunctionTextRegion, clang::ento::AllocaRegion, clang::ento::StackArgumentsSpaceRegion, clang::ento::StackLocalsSpaceRegion, clang::ento::UnknownSpaceRegion, clang::ento::HeapSpaceRegion, clang::ento::GlobalInternalSpaceRegion, clang::ento::GlobalImmutableSpaceRegion, clang::ento::GlobalSystemSpaceRegion, and clang::ento::StaticGlobalSpaceRegion.
Definition at line 452 of file MemRegion.cpp.
Referenced by dump(), getString(), and llvm::operator<<().
const RegionTy * clang::ento::MemRegion::getAs | ( | ) | const |
Definition at line 1110 of file MemRegion.h.
Referenced by GetAllocationSite(), clang::ento::SVal::getAsFunctionDecl(), clang::ento::ExprEngine::notifyCheckersOfPointerEscape(), and parameterTypeFromSVal().
RegionOffset MemRegion::getAsOffset | ( | ) | const |
Compute the offset within the top level memory object.
Definition at line 1176 of file MemRegion.cpp.
References AllocaRegionKind, BlockDataRegionKind, BlockTextRegionKind, CXXBaseObjectRegionKind, CXXTempObjectRegionKind, ElementRegionKind, FieldRegionKind, FunctionTextRegionKind, GenericMemSpaceRegionKind, clang::ento::SVal::getAs(), clang::Type::getAsCXXRecordDecl(), clang::ASTContext::getASTRecordLayout(), clang::ASTRecordLayout::getBaseClassOffset(), clang::ASTContext::getCharWidth(), getContext(), clang::ento::FieldRegion::getDecl(), clang::ento::CXXBaseObjectRegion::getDecl(), clang::ASTRecordLayout::getFieldOffset(), clang::ento::ElementRegion::getIndex(), getKind(), clang::FieldDecl::getParent(), clang::Type::getPointeeType(), clang::CharUnits::getQuantity(), clang::ento::SubRegion::getSuperRegion(), clang::ASTContext::getTypeSize(), clang::ento::ElementRegion::getValueType(), clang::ASTRecordLayout::getVBaseClassOffset(), GlobalImmutableSpaceRegionKind, GlobalInternalSpaceRegionKind, GlobalSystemSpaceRegionKind, HeapSpaceRegionKind, clang::TagDecl::isCompleteDefinition(), isImmediateBase(), clang::Type::isIncompleteType(), clang::TagDecl::isUnion(), clang::ento::CXXBaseObjectRegion::isVirtual(), clang::CXXRecordDecl::isVirtuallyDerivedFrom(), ObjCIvarRegionKind, ObjCStringRegionKind, StackArgumentsSpaceRegionKind, StackLocalsSpaceRegionKind, StaticGlobalSpaceRegionKind, StringRegionKind, clang::ento::RegionOffset::Symbolic, SymbolicRegionKind, UnknownSpaceRegionKind, and VarRegionKind.
const MemRegion * MemRegion::getBaseRegion | ( | ) | const |
Definition at line 1060 of file MemRegion.cpp.
References CXXBaseObjectRegionKind, ElementRegionKind, FieldRegionKind, getKind(), and ObjCIvarRegionKind.
Referenced by GetAllocationSite(), getExistingLazyBinding(), clang::ento::BugReport::isInteresting(), clang::ento::SymbolReaper::isLiveRegion(), clang::ento::BugReport::markInteresting(), and clang::ento::ScanReachableSymbols::scan().
ASTContext & clang::ento::MemRegion::getContext | ( | ) | const [inline] |
Definition at line 1311 of file MemRegion.h.
References clang::ento::MemRegionManager::getContext(), and getMemRegionManager().
Referenced by clang::ento::StringRegion::dumpToStream(), clang::ento::ObjCStringRegion::dumpToStream(), clang::ento::ElementRegion::getAsArrayOffset(), getAsOffset(), clang::ento::MemRegionManager::getElementRegionWithSuper(), clang::ento::TypedValueRegion::getLocationType(), and clang::ento::FunctionTextRegion::getLocationType().
Kind clang::ento::MemRegion::getKind | ( | ) | const [inline] |
Definition at line 184 of file MemRegion.h.
Referenced by clang::ento::StoreManager::castRegion(), clang::ento::MemSpaceRegion::classof(), clang::ento::GlobalsSpaceRegion::classof(), clang::ento::StaticGlobalSpaceRegion::classof(), clang::ento::NonStaticGlobalSpaceRegion::classof(), clang::ento::GlobalSystemSpaceRegion::classof(), clang::ento::GlobalImmutableSpaceRegion::classof(), clang::ento::GlobalInternalSpaceRegion::classof(), clang::ento::HeapSpaceRegion::classof(), clang::ento::UnknownSpaceRegion::classof(), clang::ento::StackSpaceRegion::classof(), clang::ento::StackLocalsSpaceRegion::classof(), clang::ento::StackArgumentsSpaceRegion::classof(), clang::ento::SubRegion::classof(), clang::ento::AllocaRegion::classof(), clang::ento::TypedRegion::classof(), clang::ento::TypedValueRegion::classof(), clang::ento::CodeTextRegion::classof(), clang::ento::FunctionTextRegion::classof(), clang::ento::BlockTextRegion::classof(), clang::ento::BlockDataRegion::classof(), clang::ento::SymbolicRegion::classof(), clang::ento::StringRegion::classof(), clang::ento::ObjCStringRegion::classof(), clang::ento::CompoundLiteralRegion::classof(), clang::ento::DeclRegion::classof(), clang::ento::VarRegion::classof(), clang::ento::CXXThisRegion::classof(), clang::ento::FieldRegion::classof(), clang::ento::ObjCIvarRegion::classof(), clang::ento::ElementRegion::classof(), clang::ento::CXXTempObjectRegion::classof(), clang::ento::CXXBaseObjectRegion::classof(), computeExtentBegin(), getAsOffset(), getBaseRegion(), clang::ento::MemSpaceRegion::Profile(), clang::ento::StaticGlobalSpaceRegion::Profile(), clang::ento::StackSpaceRegion::Profile(), clang::ento::DeclRegion::Profile(), and StripCasts().
const MemSpaceRegion * MemRegion::getMemorySpace | ( | ) | const |
Definition at line 1028 of file MemRegion.cpp.
References clang::ento::SubRegion::getSuperRegion().
Referenced by clang::ento::VarRegion::getStackFrame(), hasGlobalsOrParametersStorage(), hasStackNonParametersStorage(), hasStackParametersStorage(), hasStackStorage(), and isInitializationOfVar().
virtual MemRegionManager* clang::ento::MemRegion::getMemRegionManager | ( | ) | const [pure virtual] |
Implemented in clang::ento::SubRegion, and clang::ento::MemSpaceRegion.
Referenced by getContext(), and clang::ento::SubRegion::getMemRegionManager().
std::string MemRegion::getString | ( | ) | const |
Get a string representation of a region for debug use.
Definition at line 445 of file MemRegion.cpp.
References dumpToStream().
const SymbolicRegion * MemRegion::getSymbolicBase | ( | ) | const |
If this is a symbolic region, returns the region. Otherwise, goes up the base chain looking for the first symbolic base region.
Definition at line 1108 of file MemRegion.cpp.
References clang::ento::SubRegion::getSuperRegion().
Referenced by clang::ento::SVal::getAsLocSymbol().
bool MemRegion::hasGlobalsOrParametersStorage | ( | ) | const |
Definition at line 1052 of file MemRegion.cpp.
References getMemorySpace().
bool MemRegion::hasStackNonParametersStorage | ( | ) | const |
Definition at line 1044 of file MemRegion.cpp.
References getMemorySpace().
bool MemRegion::hasStackParametersStorage | ( | ) | const |
Definition at line 1048 of file MemRegion.cpp.
References getMemorySpace().
bool MemRegion::hasStackStorage | ( | ) | const |
Definition at line 1040 of file MemRegion.cpp.
References getMemorySpace().
virtual bool clang::ento::MemRegion::isBoundable | ( | ) | const [inline, virtual] |
Reimplemented in clang::ento::CompoundLiteralRegion, clang::ento::ObjCStringRegion, clang::ento::StringRegion, clang::ento::SymbolicRegion, clang::ento::CodeTextRegion, clang::ento::TypedRegion, clang::ento::AllocaRegion, and clang::ento::MemSpaceRegion.
Definition at line 188 of file MemRegion.h.
Referenced by clang::ento::StoreManager::castRegion(), clang::ento::ProgramState::getSValAsScalarOrLoc(), and clang::ento::FindLastStoreBRVisitor::VisitNode().
bool MemRegion::isSubRegionOf | ( | const MemRegion * | R | ) | const [virtual] |
Check if the region is a subregion of the given region.
Reimplemented in clang::ento::SubRegion.
Definition at line 1078 of file MemRegion.cpp.
Referenced by collectSubRegionBindings(), and clang::ento::UndefOrNullArgVisitor::VisitNode().
void MemRegion::printPretty | ( | raw_ostream & | os | ) | const [virtual] |
Print the region for use in diagnostics.
Reimplemented in clang::ento::FieldRegion.
Definition at line 576 of file MemRegion.cpp.
References canPrintPretty(), and printPrettyAsExpr().
Referenced by clang::ento::FindLastStoreBRVisitor::VisitNode().
void MemRegion::printPrettyAsExpr | ( | raw_ostream & | os | ) | const [virtual] |
Print the region as expression.
When this region represents a subexpression, the method is for printing an expression containing it.
Reimplemented in clang::ento::CXXBaseObjectRegion, clang::ento::ObjCIvarRegion, clang::ento::FieldRegion, and clang::ento::VarRegion.
Definition at line 584 of file MemRegion.cpp.
Referenced by printPretty(), clang::ento::FieldRegion::printPrettyAsExpr(), and clang::ento::CXXBaseObjectRegion::printPrettyAsExpr().
virtual void clang::ento::MemRegion::Profile | ( | llvm::FoldingSetNodeID & | ID | ) | const [pure virtual] |
Implemented in clang::ento::CXXBaseObjectRegion, clang::ento::CXXTempObjectRegion, clang::ento::ElementRegion, clang::ento::DeclRegion, clang::ento::CompoundLiteralRegion, clang::ento::ObjCStringRegion, clang::ento::StringRegion, clang::ento::SymbolicRegion, clang::ento::BlockDataRegion, clang::ento::BlockTextRegion, clang::ento::FunctionTextRegion, clang::ento::AllocaRegion, clang::ento::StackSpaceRegion, clang::ento::StaticGlobalSpaceRegion, and clang::ento::MemSpaceRegion.
const MemRegion * MemRegion::StripCasts | ( | bool | StripBaseCasts = true | ) | const |
Definition at line 1086 of file MemRegion.cpp.
References CXXBaseObjectRegionKind, ElementRegionKind, clang::ento::ElementRegion::getIndex(), getKind(), clang::ento::SubRegion::getSuperRegion(), and clang::ento::SVal::isZeroConstant().
Referenced by clang::ento::StoreManager::castRegion(), clang::ento::StoreManager::evalDynamicCast(), clang::ento::SVal::getAsLocSymbol(), clang::ento::StoreManager::getLValueElement(), clang::CXXInstanceCall::getRuntimeDefinition(), clang::ento::ExprEngine::notifyCheckersOfPointerEscape(), clang::ento::ProgramState::setDynamicTypeInfo(), clang::ento::loc::MemRegionVal::stripCasts(), and clang::ento::UndefOrNullArgVisitor::VisitNode().
friend class MemRegionManager [friend] |
Reimplemented in clang::ento::CXXBaseObjectRegion, clang::ento::CXXTempObjectRegion, clang::ento::ElementRegion, clang::ento::ObjCIvarRegion, clang::ento::FieldRegion, clang::ento::CXXThisRegion, clang::ento::VarRegion, clang::ento::CompoundLiteralRegion, clang::ento::ObjCStringRegion, clang::ento::StringRegion, clang::ento::BlockDataRegion, clang::ento::BlockTextRegion, clang::ento::AllocaRegion, clang::ento::StackArgumentsSpaceRegion, clang::ento::StackLocalsSpaceRegion, clang::ento::UnknownSpaceRegion, clang::ento::HeapSpaceRegion, clang::ento::GlobalInternalSpaceRegion, clang::ento::GlobalImmutableSpaceRegion, clang::ento::GlobalSystemSpaceRegion, clang::ento::NonStaticGlobalSpaceRegion, clang::ento::StaticGlobalSpaceRegion, and clang::ento::MemSpaceRegion.
Definition at line 78 of file MemRegion.h.