clang  16.0.0git
Public Types | Public Member Functions | Protected Member Functions | List of all members
clang::ento::MemRegion Class Referenceabstract

MemRegion - The root abstract class for all memory regions. More...

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

Inheritance diagram for clang::ento::MemRegion:
Inheritance graph
[legend]
Collaboration diagram for clang::ento::MemRegion:
Collaboration graph
[legend]

Public Types

enum  Kind
 

Public Member Functions

ASTContextgetContext () const
 
virtual void Profile (llvm::FoldingSetNodeID &ID) const =0
 
virtual MemRegionManagergetMemRegionManager () const =0
 
const LLVM_ATTRIBUTE_RETURNS_NONNULL MemSpaceRegiongetMemorySpace () const
 
const LLVM_ATTRIBUTE_RETURNS_NONNULL MemRegiongetBaseRegion () const
 
const LLVM_ATTRIBUTE_RETURNS_NONNULL MemRegiongetMostDerivedObjectRegion () const
 Recursively retrieve the region of the most derived class instance of regions of C++ base class instances. More...
 
virtual bool isSubRegionOf (const MemRegion *R) const
 Check if the region is a subregion of the given region. More...
 
const LLVM_ATTRIBUTE_RETURNS_NONNULL MemRegionStripCasts (bool StripBaseAndDerivedCasts=true) const
 
const SymbolicRegiongetSymbolicBase () 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
 
template<typename RegionTy >
const LLVM_ATTRIBUTE_RETURNS_NONNULL RegionTy * castAs () const
 
virtual bool isBoundable () const
 
std::string getDescriptiveName (bool UseQuotes=true) const
 Get descriptive name for memory region. More...
 
SourceRange sourceRange () const
 Retrieve source range from memory region. More...
 

Protected Member Functions

 MemRegion (Kind k)
 
virtual ~MemRegion ()
 

Detailed Description

MemRegion - The root abstract class for all memory regions.

Definition at line 95 of file MemRegion.h.

Member Enumeration Documentation

◆ Kind

Constructor & Destructor Documentation

◆ MemRegion()

clang::ento::MemRegion::MemRegion ( Kind  k)
inlineprotected

Definition at line 108 of file MemRegion.h.

◆ ~MemRegion()

MemRegion::~MemRegion ( )
protectedvirtualdefault

Member Function Documentation

◆ canPrintPretty()

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

References canPrintPrettyAsExpr().

Referenced by printPretty().

◆ canPrintPrettyAsExpr()

bool MemRegion::canPrintPrettyAsExpr ( ) const
virtual

◆ castAs()

template<typename RegionTy >
const LLVM_ATTRIBUTE_RETURNS_NONNULL RegionTy * clang::ento::MemRegion::castAs

Definition at line 1345 of file MemRegion.h.

◆ dump()

LLVM_DUMP_METHOD void MemRegion::dump ( ) const

Definition at line 441 of file MemRegion.cpp.

References dumpToStream().

◆ dumpToStream()

void MemRegion::dumpToStream ( raw_ostream &  os) const
virtual

◆ getAs()

template<typename RegionTy >
const RegionTy * clang::ento::MemRegion::getAs

◆ getAsOffset()

RegionOffset MemRegion::getAsOffset ( ) const

Compute the offset within the top level memory object.

Definition at line 1602 of file MemRegion.cpp.

References calculateOffset().

◆ getBaseRegion()

const MemRegion * MemRegion::getBaseRegion ( ) const

◆ getContext()

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

◆ getDescriptiveName()

std::string MemRegion::getDescriptiveName ( bool  UseQuotes = true) const

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".

Parameters
UseQuotesSet if the name should be quoted.
Returns
variable name for memory region

Definition at line 675 of file MemRegion.cpp.

References canPrintPrettyAsExpr(), clang::ento::SVal::getAs(), getAs(), getDescriptiveName(), clang::ento::ElementRegion::getIndex(), clang::ento::SubRegion::getSuperRegion(), printPrettyAsExpr(), and string().

Referenced by getDescriptiveName(), clang::ento::mpi::MPIBugReporter::reportDoubleNonblocking(), clang::ento::mpi::MPIBugReporter::reportMissingWait(), and clang::ento::mpi::MPIBugReporter::reportUnmatchedWait().

◆ getKind()

Kind clang::ento::MemRegion::getKind ( ) const
inline

Definition at line 173 of file MemRegion.h.

Referenced by 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::NonParamVarRegion::classof(), clang::ento::ParamVarRegion::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(), clang::ento::CXXDerivedObjectRegion::classof(), getBaseRegion(), clang::ento::MemSpaceRegion::Profile(), clang::ento::StaticGlobalSpaceRegion::Profile(), clang::ento::StackSpaceRegion::Profile(), StripCasts(), and clang::ento::MemRegionVisitor< SValExplainer, std::string >::Visit().

◆ getMemorySpace()

const MemSpaceRegion * MemRegion::getMemorySpace ( ) const

◆ getMemRegionManager()

virtual MemRegionManager& clang::ento::MemRegion::getMemRegionManager ( ) const
pure virtual

◆ getMostDerivedObjectRegion()

const MemRegion * MemRegion::getMostDerivedObjectRegion ( ) const

Recursively retrieve the region of the most derived class instance of regions of C++ base class instances.

Definition at line 1315 of file MemRegion.cpp.

◆ getString()

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(), s, and string().

Referenced by clang::ento::SValExplainer::VisitStringRegion().

◆ getSymbolicBase()

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. It might return null.

Definition at line 1353 of file MemRegion.cpp.

Referenced by clang::ento::SVal::getAsLocSymbol().

◆ hasGlobalsOrParametersStorage()

bool MemRegion::hasGlobalsOrParametersStorage ( ) const

Definition at line 1289 of file MemRegion.cpp.

References getMemorySpace().

◆ hasStackNonParametersStorage()

bool MemRegion::hasStackNonParametersStorage ( ) const

Definition at line 1281 of file MemRegion.cpp.

References getMemorySpace().

◆ hasStackParametersStorage()

bool MemRegion::hasStackParametersStorage ( ) const

Definition at line 1285 of file MemRegion.cpp.

References getMemorySpace().

◆ hasStackStorage()

bool MemRegion::hasStackStorage ( ) const

◆ isBoundable()

virtual bool clang::ento::MemRegion::isBoundable ( ) const
inlinevirtual

◆ isSubRegionOf()

bool MemRegion::isSubRegionOf ( const MemRegion R) const
virtual

Check if the region is a subregion of the given region.

Each region is a subregion of itself.

Reimplemented in clang::ento::SubRegion.

Definition at line 1322 of file MemRegion.cpp.

Referenced by clang::ento::UndefOrNullArgVisitor::VisitNode().

◆ printPretty()

void MemRegion::printPretty ( raw_ostream &  os) const
virtual

Print the region for use in diagnostics.

Reimplemented in clang::ento::FieldRegion.

Definition at line 601 of file MemRegion.cpp.

References canPrintPretty(), and printPrettyAsExpr().

◆ printPrettyAsExpr()

void MemRegion::printPrettyAsExpr ( raw_ostream &  os) const
virtual

◆ Profile()

virtual void clang::ento::MemRegion::Profile ( llvm::FoldingSetNodeID &  ID) const
pure virtual

◆ sourceRange()

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.

Returns
source range for declaration retrieved from memory region

Definition at line 714 of file MemRegion.cpp.

References getBaseRegion().

Referenced by clang::ento::mpi::MPIBugReporter::reportDoubleNonblocking(), clang::ento::mpi::MPIBugReporter::reportMissingWait(), and clang::ento::mpi::MPIBugReporter::reportUnmatchedWait().

◆ StripCasts()

const MemRegion * MemRegion::StripCasts ( bool  StripBaseAndDerivedCasts = true) const

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