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/SetVector.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 {
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>();
317 EndNodes.push_back(V);
326 unsigned num_eops()
const {
return EndNodes.size(); }
328 bool empty()
const {
return NumNodes == 0; }
329 unsigned size()
const {
return NumNodes; }
331 void reserve(
unsigned NodeCount) { Nodes.reserve(NodeCount); }
349 const_node_iterator
nodes_end()
const {
return Nodes.end(); }
355 const_roots_iterator
roots_begin()
const {
return Roots.begin(); }
357 const_roots_iterator
roots_end()
const {
return Roots.end(); }
361 eop_iterator
eop_end() {
return EndNodes.end(); }
363 const_eop_iterator
eop_begin()
const {
return EndNodes.begin(); }
365 const_eop_iterator
eop_end()
const {
return EndNodes.end(); }
370 typedef llvm::DenseMap<const ExplodedNode*, ExplodedNode*>
NodeMap;
382 std::unique_ptr<ExplodedGraph>
390 ReclaimCounter = ReclaimNodeInterval = Interval;
395 void reclaimRecentlyAllocatedNodes();
399 static bool isInterestingLValueExpr(
const Expr *Ex);
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(); }
438 inline iterator
begin() {
return Impl.begin(); }
439 inline iterator
end() {
return Impl.end(); }
441 inline const_iterator
begin()
const {
return Impl.begin(); }
442 inline const_iterator
end()
const {
return Impl.end(); }
463 static nodes_iterator
nodes_begin(NodeRef N) {
return df_begin(N); }
465 static nodes_iterator
nodes_end(NodeRef N) {
return df_end(N); }
479 static nodes_iterator
nodes_begin(NodeRef N) {
return df_begin(N); }
481 static nodes_iterator
nodes_end(NodeRef N) {
return df_end(N); }
clang::ento::ExplodedNode::succ_iterator ChildIteratorType
const_iterator end() const
unsigned ReclaimCounter
Counter to determine when to reclaim nodes.
void Profile(llvm::FoldingSetNodeID &ID) const
ExplodedNode *const * succ_iterator
const_roots_iterator roots_begin() const
llvm::df_iterator< NodeRef > nodes_iterator
const ExplodedNode * getFirstPred() const
AllNodesTy::const_iterator const_node_iterator
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
static ChildIteratorType child_begin(NodeRef N)
NodeVector FreeNodes
A list of nodes that can be reused.
unsigned NumNodes
NumNodes - The number of nodes in the graph.
Decl - This represents one declaration (or definition), e.g.
const_eop_iterator eop_begin() const
friend class ExplodedGraph
const clang::ento::ExplodedNode * NodeRef
const_succ_iterator succ_begin() const
const_node_iterator nodes_end() const
static nodes_iterator nodes_begin(NodeRef N)
const ProgramStateRef & getState() const
llvm::BumpPtrAllocator & getAllocator()
const_pred_iterator pred_end() const
ImplTy::const_iterator const_iterator
const_succ_iterator succ_end() const
static ChildIteratorType child_end(NodeRef N)
const Decl & getCodeDecl() const
llvm::DenseMap< const ExplodedNode *, ExplodedNode * > NodeMap
roots_iterator roots_begin()
NodeVector ChangedNodes
A list of recently allocated nodes that can potentially be recycled.
const_eop_iterator eop_end() const
ImplTy::iterator iterator
NodeVector EndNodes
The nodes in the simulation graph which have been specially marked as the endpoint of an abstract sim...
succ_iterator succ_begin()
bool hasSinglePred() const
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...
unsigned succ_size() const
static nodes_iterator nodes_end(NodeRef N)
const StackFrameContext * getCurrentStackFrame() const
const LocationContext * getLocationContext() const
std::unique_ptr< ExplodedGraph > MakeEmptyGraph() const
const_roots_iterator roots_end() const
ExplodedNode * getFirstPred()
unsigned pred_size() const
llvm::df_iterator< NodeRef > nodes_iterator
clang::ento::ExplodedNode::const_succ_iterator ChildIteratorType
std::vector< ExplodedNode * > NodeVector
llvm::DenseMap< const ExplodedNode *, const ExplodedNode * > InterExplodedGraphMap
Expr - This represents one expression.
CFG - Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt...
const FunctionProtoType * T
This is the simplest builder which generates nodes in the ExplodedGraph.
void Add(ExplodedNode *N)
unsigned num_roots() const
const_node_iterator nodes_begin() const
static ChildIteratorType child_begin(NodeRef N)
llvm::FoldingSet< ExplodedNode > AllNodesTy
static void Profile(llvm::FoldingSetNodeID &ID, const ProgramPoint &Loc, const ProgramStateRef &state, bool IsSink)
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...
ParentMap & getParentMap() const
ExplodedNode *const * pred_iterator
unsigned ReclaimNodeInterval
Determines how often nodes are reclaimed.
node_iterator nodes_begin()
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)
roots_iterator roots_end()
llvm::FoldingSet< ExplodedNode > Nodes
Nodes - The nodes in the graph.
ProgramPoint getLocation() const
getLocation - Returns the edge associated with the given node.
node_iterator nodes_end()
ParentMap & getParentMap() const
void insert(const ExplodedNodeSet &S)
CoreEngine - Implements the core logic of the graph-reachability analysis.
Dataflow Directional Tag Classes.
BumpVectorContext & getNodeAllocator()
ExplodedNodeSet(ExplodedNode *N)
NodeVector Roots
The roots of the simulation graph.
const ExplodedNode * getFirstSucc() const
BranchNodeBuilder is responsible for constructing the nodes corresponding to the two branches of the ...
NodeVector::iterator roots_iterator
ExplodedNode(const ProgramPoint &loc, ProgramStateRef state, bool IsSink)
const Decl * getDecl() const
void reserve(unsigned NodeCount)
const ExplodedNode *const * const_pred_iterator
static ChildIteratorType child_end(NodeRef N)
static void SetAuditor(Auditor *A)
const LocationContext * getLocationContext() const
NodeVector::iterator eop_iterator
friend class EndOfFunctionNodeBuilder
static nodes_iterator nodes_begin(NodeRef N)
bool erase(ExplodedNode *N)
clang::ento::ExplodedNode * NodeRef
unsigned num_eops() const
static NodeRef getEntryNode(NodeRef N)
pred_iterator pred_begin()
llvm::BumpPtrAllocator & getAllocator()
static NodeRef getEntryNode(NodeRef N)
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 StackFrameContext * getStackFrame() const
const_pred_iterator pred_begin() const
Optional< T > getAs() const
Convert to the specified ProgramPoint type, returning None if this ProgramPoint is not of the desired...
ExplodedNode * addRoot(ExplodedNode *V)
addRoot - Add an untyped node to the set of roots.
const_iterator begin() const