clang 22.0.0git
clang::ento::ExplodedGraph Class Reference

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

Public Types

using NodeTy = ExplodedNode
using AllNodesTy = llvm::FoldingSet<ExplodedNode>
using eop_iterator = NodeVector::iterator
using const_eop_iterator = NodeVector::const_iterator
using node_iterator = AllNodesTy::iterator
using const_node_iterator = AllNodesTy::const_iterator
using NodeMap = llvm::DenseMap<const ExplodedNode *, ExplodedNode *>

Public Member Functions

 ExplodedGraph ()
 ~ExplodedGraph ()
ExplodedNodegetRoot () const
 Get the root node of the graph.
ExplodedNodegetNode (const ProgramPoint &L, ProgramStateRef State, bool IsSink=false, bool *IsNew=nullptr)
 Retrieve the node associated with a (Location, State) pair, where the 'Location' is a ProgramPoint in the CFG.
ExplodedNodecreateUncachedNode (const ProgramPoint &L, ProgramStateRef State, int64_t Id, bool IsSink=false)
 Create a node for a (Location, State) pair, but don't store it for deduplication later.
void designateAsRoot (ExplodedNode *V)
 Mark a node as the root of the graph.
ExplodedNodeaddEndOfPath (ExplodedNode *V)
 addEndOfPath - Add an untyped node to the set of EOP nodes.
unsigned num_eops () const
bool empty () const
unsigned size () const
void reserve (unsigned NodeCount)
llvm::iterator_range< node_iteratornodes ()
llvm::iterator_range< const_node_iteratornodes () const
eop_iterator eop_begin ()
eop_iterator eop_end ()
const_eop_iterator eop_begin () const
const_eop_iterator eop_end () const
llvm::BumpPtrAllocator & getAllocator ()
BumpVectorContextgetNodeAllocator ()
std::unique_ptr< ExplodedGraphtrim (ArrayRef< const NodeTy * > Nodes, InterExplodedGraphMap *ForwardMap=nullptr, InterExplodedGraphMap *InverseMap=nullptr) const
 Creates a trimmed version of the graph that only contains paths leading to the given nodes.
void enableNodeReclamation (unsigned Interval)
 Enable tracking of recently allocated nodes for potential reclamation when calling reclaimRecentlyAllocatedNodes().
void reclaimRecentlyAllocatedNodes ()
 Reclaim "uninteresting" nodes created since the last time this method was called.

Static Public Member Functions

static bool isInterestingLValueExpr (const Expr *Ex)
 Returns true if nodes for the given expression kind are always kept around.

Protected Types

using NodeVector = std::vector<ExplodedNode *>

Protected Attributes

ExplodedNodeRoot = nullptr
 The root of the simulation graph.
NodeVector EndNodes
 The nodes in the simulation graph which have been specially marked as the endpoint of an abstract simulation path.
llvm::FoldingSet< ExplodedNodeNodes
 Nodes - The nodes in the graph.
BumpVectorContext BVC
 BVC - Allocator and context for allocating nodes and their predecessor and successor groups.
int64_t NumNodes = 0
 NumNodes - The number of nodes in the graph.
NodeVector ChangedNodes
 A list of recently allocated nodes that can potentially be recycled.
NodeVector FreeNodes
 A list of nodes that can be reused.
unsigned ReclaimNodeInterval = 0
 Determines how often nodes are reclaimed.
unsigned ReclaimCounter
 Counter to determine when to reclaim nodes.

Friends

class CoreEngine

Detailed Description

Definition at line 303 of file ExplodedGraph.h.

Member Typedef Documentation

◆ AllNodesTy

Definition at line 388 of file ExplodedGraph.h.

◆ const_eop_iterator

using clang::ento::ExplodedGraph::const_eop_iterator = NodeVector::const_iterator

Definition at line 390 of file ExplodedGraph.h.

◆ const_node_iterator

using clang::ento::ExplodedGraph::const_node_iterator = AllNodesTy::const_iterator

Definition at line 392 of file ExplodedGraph.h.

◆ eop_iterator

using clang::ento::ExplodedGraph::eop_iterator = NodeVector::iterator

Definition at line 389 of file ExplodedGraph.h.

◆ node_iterator

using clang::ento::ExplodedGraph::node_iterator = AllNodesTy::iterator

Definition at line 391 of file ExplodedGraph.h.

◆ NodeMap

Definition at line 409 of file ExplodedGraph.h.

◆ NodeTy

◆ NodeVector

using clang::ento::ExplodedGraph::NodeVector = std::vector<ExplodedNode *>
protected

Definition at line 308 of file ExplodedGraph.h.

Constructor & Destructor Documentation

◆ ExplodedGraph()

ExplodedGraph::ExplodedGraph ( )
default

◆ ~ExplodedGraph()

ExplodedGraph::~ExplodedGraph ( )
default

Member Function Documentation

◆ addEndOfPath()

ExplodedNode * clang::ento::ExplodedGraph::addEndOfPath ( ExplodedNode * V)
inline

addEndOfPath - Add an untyped node to the set of EOP nodes.

Definition at line 374 of file ExplodedGraph.h.

References EndNodes, and V.

◆ createUncachedNode()

ExplodedNode * ExplodedGraph::createUncachedNode ( const ProgramPoint & L,
ProgramStateRef State,
int64_t Id,
bool IsSink = false )

Create a node for a (Location, State) pair, but don't store it for deduplication later.

This is useful when copying some nodes from an already completed ExplodedGraph for further processing.

Definition at line 430 of file ExplodedGraph.cpp.

References getAllocator(), and V.

◆ designateAsRoot()

void clang::ento::ExplodedGraph::designateAsRoot ( ExplodedNode * V)
inline

Mark a node as the root of the graph.

Calling this is an error if the graph already has a root node.

Definition at line 367 of file ExplodedGraph.h.

References Root, and V.

◆ empty()

bool clang::ento::ExplodedGraph::empty ( ) const
inline

Definition at line 381 of file ExplodedGraph.h.

References NumNodes.

◆ enableNodeReclamation()

void clang::ento::ExplodedGraph::enableNodeReclamation ( unsigned Interval)
inline

Enable tracking of recently allocated nodes for potential reclamation when calling reclaimRecentlyAllocatedNodes().

Definition at line 428 of file ExplodedGraph.h.

References ReclaimCounter, and ReclaimNodeInterval.

◆ eop_begin() [1/2]

eop_iterator clang::ento::ExplodedGraph::eop_begin ( )
inline

Definition at line 398 of file ExplodedGraph.h.

References EndNodes.

◆ eop_begin() [2/2]

const_eop_iterator clang::ento::ExplodedGraph::eop_begin ( ) const
inline

Definition at line 402 of file ExplodedGraph.h.

References EndNodes.

◆ eop_end() [1/2]

eop_iterator clang::ento::ExplodedGraph::eop_end ( )
inline

Definition at line 400 of file ExplodedGraph.h.

References EndNodes.

◆ eop_end() [2/2]

const_eop_iterator clang::ento::ExplodedGraph::eop_end ( ) const
inline

Definition at line 404 of file ExplodedGraph.h.

References EndNodes.

◆ getAllocator()

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

Definition at line 406 of file ExplodedGraph.h.

References BVC.

Referenced by createUncachedNode(), and getNode().

◆ getNode()

ExplodedNode * ExplodedGraph::getNode ( const ProgramPoint & L,
ProgramStateRef State,
bool IsSink = false,
bool * IsNew = nullptr )

Retrieve the node associated with a (Location, State) pair, where the 'Location' is a ProgramPoint in the CFG.

If no node for this pair exists, it is created. IsNew is set to true if the node was freshly created.

Definition at line 392 of file ExplodedGraph.cpp.

References ChangedNodes, FreeNodes, getAllocator(), Nodes, NumNodes, clang::ento::ExplodedNode::Profile(), ReclaimNodeInterval, and V.

◆ getNodeAllocator()

BumpVectorContext & clang::ento::ExplodedGraph::getNodeAllocator ( )
inline

Definition at line 407 of file ExplodedGraph.h.

References BVC.

◆ getRoot()

ExplodedNode * clang::ento::ExplodedGraph::getRoot ( ) const
inline

Get the root node of the graph.

This may return nullptr if the graph is empty or under construction.

Definition at line 348 of file ExplodedGraph.h.

References Root.

Referenced by llvm::GraphTraits< clang::ento::ExplodedGraph * >::getEntryNode(), getInlinedLocationContext(), and trim().

◆ isInterestingLValueExpr()

bool ExplodedGraph::isInterestingLValueExpr ( const Expr * Ex)
static

Returns true if nodes for the given expression kind are always kept around.

Definition at line 48 of file ExplodedGraph.cpp.

References clang::isa(), and clang::Expr::isLValue().

◆ nodes() [1/2]

llvm::iterator_range< node_iterator > clang::ento::ExplodedGraph::nodes ( )
inline

Definition at line 394 of file ExplodedGraph.h.

References Nodes.

◆ nodes() [2/2]

llvm::iterator_range< const_node_iterator > clang::ento::ExplodedGraph::nodes ( ) const
inline

Definition at line 396 of file ExplodedGraph.h.

References Nodes.

◆ num_eops()

unsigned clang::ento::ExplodedGraph::num_eops ( ) const
inline

Definition at line 379 of file ExplodedGraph.h.

References EndNodes.

◆ reclaimRecentlyAllocatedNodes()

void ExplodedGraph::reclaimRecentlyAllocatedNodes ( )

Reclaim "uninteresting" nodes created since the last time this method was called.

Definition at line 167 of file ExplodedGraph.cpp.

References ChangedNodes, ReclaimCounter, and ReclaimNodeInterval.

◆ reserve()

void clang::ento::ExplodedGraph::reserve ( unsigned NodeCount)
inline

Definition at line 384 of file ExplodedGraph.h.

References Nodes.

◆ size()

unsigned clang::ento::ExplodedGraph::size ( ) const
inline

Definition at line 382 of file ExplodedGraph.h.

References NumNodes.

◆ trim()

std::unique_ptr< ExplodedGraph > ExplodedGraph::trim ( ArrayRef< const NodeTy * > Nodes,
InterExplodedGraphMap * ForwardMap = nullptr,
InterExplodedGraphMap * InverseMap = nullptr ) const

Creates a trimmed version of the graph that only contains paths leading to the given nodes.

Parameters
NodesThe nodes which must appear in the final graph. Presumably these are end-of-path nodes (i.e. they have no successors).
[out]ForwardMapAn optional map from nodes in this graph to nodes in the returned graph.
[out]InverseMapAn optional map from nodes in the returned graph to nodes in this graph.
Returns
The trimmed graph

Definition at line 440 of file ExplodedGraph.cpp.

References clang::ento::ExplodedNode::addPredecessor(), clang::ento::ExplodedNode::getID(), clang::ento::ExplodedNode::getLocation(), getRoot(), clang::ento::ExplodedNode::isSink(), and Nodes.

◆ CoreEngine

friend class CoreEngine
friend

Definition at line 305 of file ExplodedGraph.h.

References CoreEngine.

Referenced by CoreEngine.

Member Data Documentation

◆ BVC

BumpVectorContext clang::ento::ExplodedGraph::BVC
protected

BVC - Allocator and context for allocating nodes and their predecessor and successor groups.

Definition at line 323 of file ExplodedGraph.h.

Referenced by getAllocator(), and getNodeAllocator().

◆ ChangedNodes

NodeVector clang::ento::ExplodedGraph::ChangedNodes
protected

A list of recently allocated nodes that can potentially be recycled.

Definition at line 329 of file ExplodedGraph.h.

Referenced by getNode(), and reclaimRecentlyAllocatedNodes().

◆ EndNodes

NodeVector clang::ento::ExplodedGraph::EndNodes
protected

The nodes in the simulation graph which have been specially marked as the endpoint of an abstract simulation path.

Definition at line 316 of file ExplodedGraph.h.

Referenced by addEndOfPath(), eop_begin(), eop_begin(), eop_end(), eop_end(), and num_eops().

◆ FreeNodes

NodeVector clang::ento::ExplodedGraph::FreeNodes
protected

A list of nodes that can be reused.

Definition at line 332 of file ExplodedGraph.h.

Referenced by getNode().

◆ Nodes

llvm::FoldingSet<ExplodedNode> clang::ento::ExplodedGraph::Nodes
protected

Nodes - The nodes in the graph.

Definition at line 319 of file ExplodedGraph.h.

Referenced by getNode(), nodes(), nodes(), reserve(), and trim().

◆ NumNodes

int64_t clang::ento::ExplodedGraph::NumNodes = 0
protected

NumNodes - The number of nodes in the graph.

Definition at line 326 of file ExplodedGraph.h.

Referenced by empty(), getNode(), and size().

◆ ReclaimCounter

unsigned clang::ento::ExplodedGraph::ReclaimCounter
protected

Counter to determine when to reclaim nodes.

Definition at line 340 of file ExplodedGraph.h.

Referenced by enableNodeReclamation(), and reclaimRecentlyAllocatedNodes().

◆ ReclaimNodeInterval

unsigned clang::ento::ExplodedGraph::ReclaimNodeInterval = 0
protected

Determines how often nodes are reclaimed.

If this is 0, nodes will never be reclaimed.

Definition at line 337 of file ExplodedGraph.h.

Referenced by enableNodeReclamation(), getNode(), and reclaimRecentlyAllocatedNodes().

◆ Root

ExplodedNode* clang::ento::ExplodedGraph::Root = nullptr
protected

The root of the simulation graph.

Can be nullptr if the graph is empty or if it was populated by createUncachedNode().

Definition at line 312 of file ExplodedGraph.h.

Referenced by designateAsRoot(), and getRoot().


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