19 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_EXPLODEDGRAPH_H
20 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_EXPLODEDGRAPH_H
27 #include "llvm/ADT/DepthFirstIterator.h"
28 #include "llvm/ADT/FoldingSet.h"
29 #include "llvm/ADT/GraphTraits.h"
30 #include "llvm/ADT/SmallPtrSet.h"
31 #include "llvm/ADT/SmallVector.h"
32 #include "llvm/Support/Allocator.h"
33 #include "llvm/Support/Casting.h"
81 NodeGroup(
bool Flag =
false) :
P(Flag) {
82 assert(getFlag() == Flag);
89 unsigned size()
const;
91 bool empty()
const {
return P == 0 || getFlag() != 0; }
106 bool getFlag()
const {
113 const ProgramPoint Location;
127 : Location(loc), State(std::move(state)), Succs(IsSink) {
128 assert(
isSink() == IsSink);
148 template <
typename T>
155 template <
typename T>
157 return Location.
getAs<T>();
165 ID.AddPointer(state.get());
166 ID.AddBoolean(IsSink);
183 bool isSink()
const {
return Succs.getFlag(); }
240 void replaceSuccessor(
ExplodedNode *node) { Succs.replaceNode(node); }
241 void replacePredecessor(
ExplodedNode *node) { Preds.replaceNode(node); }
244 typedef llvm::DenseMap<const ExplodedNode *, const ExplodedNode *>
265 llvm::FoldingSet<ExplodedNode>
Nodes;
296 bool* IsNew =
nullptr);
304 bool IsSink =
false);
307 return llvm::make_unique<ExplodedGraph>();
371 typedef llvm::DenseMap<const ExplodedNode*, ExplodedNode*>
NodeMap;
383 std::unique_ptr<ExplodedGraph>
408 typedef llvm::SmallPtrSet<ExplodedNode*,5> ImplTy;
413 assert (N && !static_cast<ExplodedNode*>(N)->isSink());
420 if (N && !static_cast<ExplodedNode*>(N)->isSink()) Impl.insert(N);
426 unsigned size()
const {
return Impl.size(); }
427 bool empty()
const {
return Impl.empty(); }
453 template<>
struct GraphTraits<clang::ento::ExplodedNode*> {
480 template<>
struct GraphTraits<const clang::ento::ExplodedNode*> {
llvm::df_iterator< NodeType * > nodes_iterator
unsigned ReclaimCounter
Counter to determine when to reclaim nodes.
static ChildIteratorType child_begin(NodeType *N)
ExplodedNode *const * succ_iterator
unsigned num_eops() const
NodeType::succ_iterator ChildIteratorType
AllNodesTy::const_iterator const_node_iterator
const_pred_iterator pred_begin() const
NodeVector FreeNodes
A list of nodes that can be reused.
unsigned NumNodes
NumNodes - The number of nodes in the graph.
ProgramPoint getLocation() const
getLocation - Returns the edge associated with the given node.
friend class ExplodedGraph
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
const clang::ento::ExplodedNode * NodeRef
unsigned pred_size() const
static NodeType * getEntryNode(NodeType *N)
llvm::BumpPtrAllocator & getAllocator()
ImplTy::const_iterator const_iterator
llvm::DenseMap< const ExplodedNode *, ExplodedNode * > NodeMap
unsigned succ_size() const
roots_iterator roots_begin()
const_eop_iterator eop_end() const
NodeType::const_succ_iterator ChildIteratorType
NodeVector ChangedNodes
A list of recently allocated nodes that can potentially be recycled.
ImplTy::iterator iterator
static ChildIteratorType child_end(NodeType *N)
const_node_iterator nodes_end() const
NodeVector EndNodes
The nodes in the simulation graph which have been specially marked as the endpoint of an abstract sim...
succ_iterator succ_begin()
void addPredecessor(ExplodedNode *V, ExplodedGraph &G)
addPredeccessor - Adds a predecessor to the current node, and in tandem add this node as a successor ...
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
Optional< T > getLocationAs() const LLVM_LVALUE_FUNCTION
void enableNodeReclamation(unsigned Interval)
Enable tracking of recently allocated nodes for potential reclamation when calling reclaimRecentlyAll...
static nodes_iterator nodes_begin(NodeType *N)
const_pred_iterator pred_end() const
ExplodedNode * getFirstPred()
ExplodedNode * createUncachedNode(const ProgramPoint &L, ProgramStateRef State, bool IsSink=false)
Create a node for a (Location, State) pair, but don't store it for deduplication later.
llvm::df_iterator< NodeType * > nodes_iterator
const LocationContext * getLocationContext() const
std::vector< ExplodedNode * > NodeVector
const_succ_iterator succ_begin() const
llvm::DenseMap< const ExplodedNode *, const ExplodedNode * > InterExplodedGraphMap
static nodes_iterator nodes_end(NodeType *N)
const_iterator begin() const
Expr - This represents one expression.
const ProgramStateRef & getState() const
CFG - Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt...
const ExplodedNode * getFirstPred() const
ParentMap & getParentMap() const
This is the simplest builder which generates nodes in the ExplodedGraph.
void Add(ExplodedNode *N)
static ChildIteratorType child_end(NodeType *N)
const ExplodedNode * getFirstSucc() const
std::unique_ptr< ExplodedGraph > MakeEmptyGraph() const
const_iterator end() const
const_eop_iterator eop_begin() const
static NodeType * getEntryNode(NodeType *N)
llvm::FoldingSet< ExplodedNode > AllNodesTy
static void Profile(llvm::FoldingSetNodeID &ID, const ProgramPoint &Loc, const ProgramStateRef &state, bool IsSink)
ExplodedNode * 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 ...
NodeVector::const_iterator const_eop_iterator
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
ExplodedNode *const * pred_iterator
void Profile(llvm::FoldingSetNodeID &ID) const
unsigned ReclaimNodeInterval
Determines how often nodes are reclaimed.
node_iterator nodes_begin()
static nodes_iterator nodes_end(NodeType *N)
const TemplateArgument * iterator
const StackFrameContext * getCurrentStackFrame() const
BumpVectorContext BVC
BVC - Allocator and context for allocating nodes and their predecessor and successor groups...
const ExplodedNode *const * const_succ_iterator
static nodes_iterator nodes_begin(NodeType *N)
const_node_iterator nodes_begin() const
roots_iterator roots_end()
llvm::FoldingSet< ExplodedNode > Nodes
Nodes - The nodes in the graph.
const_roots_iterator roots_end() const
node_iterator nodes_end()
const Decl * getDecl() const
unsigned num_roots() const
const clang::ento::ExplodedNode NodeType
void insert(const ExplodedNodeSet &S)
std::unique_ptr< 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...
CoreEngine - Implements the core logic of the graph-reachability analysis.
BumpVectorContext & getNodeAllocator()
const Decl & getCodeDecl() const
ExplodedNodeSet(ExplodedNode *N)
const LocationContext * getLocationContext() const
virtual void AddEdge(ExplodedNode *Src, ExplodedNode *Dst)=0
NodeVector Roots
The roots of the simulation graph.
void reclaimRecentlyAllocatedNodes()
Reclaim "uninteresting" nodes created since the last time this method was called. ...
BranchNodeBuilder is responsible for constructing the nodes corresponding to the two branches of the ...
NodeVector::iterator roots_iterator
Optional< T > getAs() const
Convert to the specified ProgramPoint type, returning None if this ProgramPoint is not of the desired...
ExplodedNode(const ProgramPoint &loc, ProgramStateRef state, bool IsSink)
void reserve(unsigned NodeCount)
clang::ento::ExplodedNode NodeType
const ExplodedNode *const * const_pred_iterator
static void SetAuditor(Auditor *A)
NodeVector::iterator eop_iterator
friend class EndOfFunctionNodeBuilder
ParentMap & getParentMap() const
bool erase(ExplodedNode *N)
const StackFrameContext * getStackFrame() const
clang::ento::ExplodedNode * NodeRef
pred_iterator pred_begin()
llvm::BumpPtrAllocator & getAllocator()
bool hasSinglePred() const
NodeVector::const_iterator const_roots_iterator
AllNodesTy::iterator node_iterator
static ChildIteratorType child_begin(NodeType *N)
ExplodedNode * addEndOfPath(ExplodedNode *V)
addEndOfPath - Add an untyped node to the set of EOP nodes.
const_succ_iterator succ_end() const
ExplodedNode * addRoot(ExplodedNode *V)
addRoot - Add an untyped node to the set of roots.
static bool isInterestingLValueExpr(const Expr *Ex)
Returns true if nodes for the given expression kind are always kept around.
const_roots_iterator roots_begin() const