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/Support/Allocator.h"
32 #include "llvm/Support/Casting.h"
80 NodeGroup(
bool Flag =
false) :
P(Flag) {
81 assert(getFlag() == Flag);
88 unsigned size()
const;
90 bool empty()
const {
return P == 0 || getFlag() != 0; }
105 bool getFlag()
const {
112 const ProgramPoint Location;
126 : Location(loc), State(std::move(state)), Succs(IsSink) {
127 assert(
isSink() == IsSink);
147 template <
typename T>
154 template <
typename T>
156 return Location.
getAs<T>();
164 ID.AddPointer(state.get());
165 ID.AddBoolean(IsSink);
182 bool isSink()
const {
return Succs.getFlag(); }
239 void replaceSuccessor(
ExplodedNode *node) { Succs.replaceNode(node); }
240 void replacePredecessor(
ExplodedNode *node) { Preds.replaceNode(node); }
243 typedef llvm::DenseMap<const ExplodedNode *, const ExplodedNode *>
264 llvm::FoldingSet<ExplodedNode>
Nodes;
295 bool* IsNew =
nullptr);
303 bool IsSink =
false);
306 return llvm::make_unique<ExplodedGraph>();
370 typedef llvm::DenseMap<const ExplodedNode*, ExplodedNode*>
NodeMap;
382 std::unique_ptr<ExplodedGraph>
407 typedef llvm::SmallPtrSet<ExplodedNode*,5> ImplTy;
412 assert (N && !static_cast<ExplodedNode*>(N)->isSink());
419 if (N && !static_cast<ExplodedNode*>(N)->isSink()) Impl.insert(N);
425 unsigned size()
const {
return Impl.size(); }
426 bool empty()
const {
return Impl.empty(); }
452 template<>
struct GraphTraits<clang::ento::ExplodedNode*> {
468 template<>
struct GraphTraits<const clang::ento::ExplodedNode*> {
clang::ento::ExplodedNode::succ_iterator ChildIteratorType
unsigned ReclaimCounter
Counter to determine when to reclaim nodes.
ExplodedNode *const * succ_iterator
unsigned num_eops() const
llvm::df_iterator< NodeRef > nodes_iterator
AllNodesTy::const_iterator const_node_iterator
static ChildIteratorType child_begin(NodeRef N)
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.
Decl - This represents one declaration (or definition), e.g.
friend class ExplodedGraph
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
const clang::ento::ExplodedNode * NodeRef
unsigned pred_size() const
static nodes_iterator nodes_begin(NodeRef N)
llvm::BumpPtrAllocator & getAllocator()
ImplTy::const_iterator const_iterator
static ChildIteratorType child_end(NodeRef N)
llvm::DenseMap< const ExplodedNode *, ExplodedNode * > NodeMap
unsigned succ_size() const
roots_iterator roots_begin()
const_eop_iterator eop_end() const
NodeVector ChangedNodes
A list of recently allocated nodes that can potentially be recycled.
ImplTy::iterator iterator
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_end(NodeRef 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.
const LocationContext * getLocationContext() const
llvm::df_iterator< NodeRef > nodes_iterator
clang::ento::ExplodedNode::const_succ_iterator ChildIteratorType
std::vector< ExplodedNode * > NodeVector
const_succ_iterator succ_begin() const
llvm::DenseMap< const ExplodedNode *, const ExplodedNode * > InterExplodedGraphMap
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)
const ExplodedNode * getFirstSucc() const
std::unique_ptr< ExplodedGraph > MakeEmptyGraph() const
static ChildIteratorType child_begin(NodeRef N)
const_iterator end() const
const_eop_iterator eop_begin() const
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()
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_end(NodeRef 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
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)
const ExplodedNode *const * const_pred_iterator
static ChildIteratorType child_end(NodeRef N)
static void SetAuditor(Auditor *A)
NodeVector::iterator eop_iterator
friend class EndOfFunctionNodeBuilder
ParentMap & getParentMap() const
static nodes_iterator nodes_begin(NodeRef N)
bool erase(ExplodedNode *N)
const StackFrameContext * getStackFrame() const
clang::ento::ExplodedNode * NodeRef
static NodeRef getEntryNode(NodeRef N)
pred_iterator pred_begin()
llvm::BumpPtrAllocator & getAllocator()
static NodeRef getEntryNode(NodeRef N)
bool hasSinglePred() const
NodeVector::const_iterator const_roots_iterator
AllNodesTy::iterator node_iterator
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