clang
6.0.0
|
MemRegion - The root abstract class for all memory regions. More...
#include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
Public Types | |
enum | Kind |
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. More... | |
const MemRegion * | StripCasts (bool StripBaseCasts=true) const |
const SymbolicRegion * | getSymbolicBase () const |
If this is a symbolic region, returns the region. More... | |
bool | hasGlobalsOrParametersStorage () const |
bool | hasStackStorage () const |
bool | hasStackNonParametersStorage () const |
bool | hasStackParametersStorage () const |
RegionOffset | getAsOffset () const |
Compute the offset within the top level memory object. More... | |
std::string | getString () const |
Get a string representation of a region for debug use. More... | |
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. More... | |
virtual void | printPretty (raw_ostream &os) const |
Print the region for use in diagnostics. More... | |
virtual bool | canPrintPrettyAsExpr () const |
Returns true if this region's textual representation can be used as part of a larger expression. More... | |
virtual void | printPrettyAsExpr (raw_ostream &os) const |
Print the region as expression. More... | |
Kind | getKind () const |
template<typename RegionTy > | |
const RegionTy * | getAs () const |
virtual bool | isBoundable () const |
std::string | getDescriptiveName (bool UseQuotes=true) const |
Get descriptive name for memory region. More... | |
clang::SourceRange | sourceRange () const |
Retrieve source range from memory region. More... | |
Protected Member Functions | |
MemRegion (Kind k) | |
virtual | ~MemRegion () |
MemRegion - The root abstract class for all memory regions.
Definition at line 79 of file MemRegion.h.
Definition at line 81 of file MemRegion.h.
|
inlineprotected |
Definition at line 91 of file MemRegion.h.
References dump().
|
protectedvirtual |
Definition at line 94 of file MemRegion.cpp.
|
virtual |
Returns true if this region can be printed in a user-friendly way.
Reimplemented in clang::ento::FieldRegion.
Definition at line 528 of file MemRegion.cpp.
|
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 532 of file MemRegion.cpp.
Referenced by clang::ento::FieldRegion::canPrintPrettyAsExpr(), clang::ento::CXXBaseObjectRegion::canPrintPrettyAsExpr(), and getDescriptiveName().
LLVM_DUMP_METHOD void MemRegion::dump | ( | ) | const |
Definition at line 395 of file MemRegion.cpp.
|
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::BlockCodeRegion, clang::ento::FunctionCodeRegion, 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::StaticGlobalSpaceRegion, and clang::ento::CodeSpaceRegion.
Definition at line 406 of file MemRegion.cpp.
Referenced by clang::ento::operator<<().
const RegionTy * clang::ento::MemRegion::getAs | ( | ) | const |
Definition at line 1174 of file MemRegion.h.
Referenced by clang::ento::mpi::MPIChecker::checkMissingWaits(), GetAllocationSite(), clang::ento::SVal::getAsFunctionDecl(), getDescriptiveName(), getNullConstraint(), and parameterTypeFromSVal().
RegionOffset MemRegion::getAsOffset | ( | ) | const |
Compute the offset within the top level memory object.
Definition at line 1210 of file MemRegion.cpp.
References distance(), clang::RecordDecl::field_begin(), clang::RecordDecl::field_end(), clang::ento::MemRegionManager::getAllocator(), clang::ento::SVal::getAs(), clang::Type::getAsCXXRecordDecl(), clang::ASTContext::getASTRecordLayout(), clang::ASTRecordLayout::getBaseClassOffset(), clang::ASTContext::getCharWidth(), clang::ento::MemRegionManager::getCodeRegion(), clang::ento::MemRegionManager::getContext(), clang::ento::BlockCodeRegion::getDecl(), 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::AnalysisDeclContext::getReferencedBlockVars(), clang::ento::SubRegion::getSuperRegion(), clang::ASTContext::getTypeSize(), clang::ento::MemRegionManager::getUnknownRegion(), clang::ento::ElementRegion::getValueType(), clang::ento::MemRegionManager::getVarRegion(), clang::ASTRecordLayout::getVBaseClassOffset(), clang::Decl::hasAttr(), clang::VarDecl::hasLocalStorage(), clang::TagDecl::isCompleteDefinition(), isImmediateBase(), clang::Type::isIncompleteType(), clang::TagDecl::isUnion(), clang::ento::CXXBaseObjectRegion::isVirtual(), clang::CXXRecordDecl::isVirtuallyDerivedFrom(), and clang::ento::RegionOffset::Symbolic.
const MemRegion * MemRegion::getBaseRegion | ( | ) | const |
Definition at line 1093 of file MemRegion.cpp.
References getKind().
Referenced by clang::ento::ProgramState::addPartialTaint(), GetAllocationSite(), getExistingLazyBinding(), clang::CXXInstanceCall::getExtraInvalidatedValues(), clang::ento::BugReport::isInteresting(), isRecordEmpty(), clang::ento::BugReport::markInteresting(), clang::ento::ExprEngine::ProcessAutomaticObjDtor(), and clang::ento::ScanReachableSymbols::scan().
|
inline |
Definition at line 1374 of file MemRegion.h.
Referenced by clang::ento::MemRegionManager::getElementRegionWithSuper().
Get descriptive name for memory region.
The name is obtained from the variable/field declaration retrieved from the memory region. Regions that point to an element of an array are returned as: "arr[0]". Regions that point to a struct are returned as: "st.var".
UseQuotes | Set if the name should be quoted. |
Definition at line 595 of file MemRegion.cpp.
References canPrintPrettyAsExpr(), clang::ento::SVal::getAs(), getAs(), getDescriptiveName(), clang::ento::ElementRegion::getIndex(), clang::ento::SubRegion::getSuperRegion(), and printPrettyAsExpr().
Referenced by getDescriptiveName(), clang::ento::mpi::MPIBugReporter::reportDoubleNonblocking(), clang::ento::mpi::MPIBugReporter::reportMissingWait(), and clang::ento::mpi::MPIBugReporter::reportUnmatchedWait().
|
inline |
Definition at line 148 of file MemRegion.h.
Referenced by addValue(), clang::ento::StoreManager::castRegion(), clang::ento::MemSpaceRegion::classof(), clang::ento::CodeSpaceRegion::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::FunctionCodeRegion::classof(), clang::ento::BlockCodeRegion::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(), StripCasts(), and clang::ento::MemRegionVisitor< SValExplainer, std::string >::Visit().
const MemSpaceRegion * MemRegion::getMemorySpace | ( | ) | const |
Definition at line 1061 of file MemRegion.cpp.
References clang::ento::SubRegion::getSuperRegion().
Referenced by computeExtentBegin(), getExistingLazyBinding(), isInitializationOfVar(), and clang::ento::SValExplainer::VisitSymbolicRegion().
|
pure virtual |
Implemented in clang::ento::SubRegion, and clang::ento::MemSpaceRegion.
Referenced by clang::ento::mpi::MPIChecker::checkMissingWaits(), and clang::ento::SubRegion::getMemRegionManager().
std::string MemRegion::getString | ( | ) | const |
Get a string representation of a region for debug use.
Definition at line 399 of file MemRegion.cpp.
Referenced by clang::ento::SValExplainer::VisitStringRegion().
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 1141 of file MemRegion.cpp.
References clang::ento::SubRegion::getSuperRegion().
Referenced by clang::ento::SVal::getAsLocSymbol().
bool MemRegion::hasGlobalsOrParametersStorage | ( | ) | const |
Definition at line 1085 of file MemRegion.cpp.
bool MemRegion::hasStackNonParametersStorage | ( | ) | const |
Definition at line 1077 of file MemRegion.cpp.
Referenced by getExistingLazyBinding().
bool MemRegion::hasStackParametersStorage | ( | ) | const |
Definition at line 1081 of file MemRegion.cpp.
bool MemRegion::hasStackStorage | ( | ) | const |
Definition at line 1073 of file MemRegion.cpp.
|
inlinevirtual |
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 152 of file MemRegion.h.
Referenced by clang::ento::StoreManager::castRegion(), and clang::ento::ProgramState::getSValAsScalarOrLoc().
Check if the region is a subregion of the given region.
Reimplemented in clang::ento::SubRegion.
Definition at line 1111 of file MemRegion.cpp.
|
virtual |
Print the region for use in diagnostics.
Reimplemented in clang::ento::FieldRegion.
Definition at line 536 of file MemRegion.cpp.
|
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 543 of file MemRegion.cpp.
Referenced by getDescriptiveName(), clang::ento::FieldRegion::printPrettyAsExpr(), and clang::ento::CXXBaseObjectRegion::printPrettyAsExpr().
|
pure virtual |
Implemented in clang::ento::CXXBaseObjectRegion, clang::ento::CXXTempObjectRegion, clang::ento::ElementRegion, clang::ento::CXXThisRegion, clang::ento::VarRegion, clang::ento::DeclRegion, clang::ento::CompoundLiteralRegion, clang::ento::ObjCStringRegion, clang::ento::StringRegion, clang::ento::SymbolicRegion, clang::ento::BlockDataRegion, clang::ento::BlockCodeRegion, clang::ento::FunctionCodeRegion, clang::ento::AllocaRegion, clang::ento::StackSpaceRegion, clang::ento::StaticGlobalSpaceRegion, and clang::ento::MemSpaceRegion.
SourceRange MemRegion::sourceRange | ( | ) | const |
Retrieve source range from memory region.
The range retrieval is based on the decl obtained from the memory region. For a VarRegion the range of the base region is returned. For a FieldRegion the range of the field is returned. If no declaration is found, an empty source range is returned. The client is responsible for checking if the returned range is valid.
Definition at line 635 of file MemRegion.cpp.
References clang::ento::VarRegion::getDecl(), clang::ento::FieldRegion::getDecl(), clang::VarDecl::getSourceRange(), and clang::FieldDecl::getSourceRange().
Referenced by clang::ento::mpi::MPIBugReporter::reportDoubleNonblocking(), clang::ento::mpi::MPIBugReporter::reportMissingWait(), and clang::ento::mpi::MPIBugReporter::reportUnmatchedWait().
Definition at line 1119 of file MemRegion.cpp.
References clang::ento::ElementRegion::getIndex(), getKind(), clang::ento::SubRegion::getSuperRegion(), and clang::ento::SVal::isZeroConstant().
Referenced by clang::ento::StoreManager::attemptDownCast(), clang::ento::StoreManager::castRegion(), clang::ento::SVal::getAsLocSymbol(), clang::ento::getDynamicTypeInfo(), clang::ento::StoreManager::getLValueElement(), clang::CXXInstanceCall::getRuntimeDefinition(), clang::ento::setDynamicTypeInfo(), and clang::ento::loc::MemRegionVal::stripCasts().