19 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_EXPLODEDGRAPH_H 20 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_EXPLODEDGRAPH_H 29 #include "llvm/ADT/ArrayRef.h" 30 #include "llvm/ADT/DenseMap.h" 31 #include "llvm/ADT/DepthFirstIterator.h" 32 #include "llvm/ADT/FoldingSet.h" 33 #include "llvm/ADT/GraphTraits.h" 34 #include "llvm/ADT/Optional.h" 35 #include "llvm/ADT/STLExtras.h" 36 #include "llvm/ADT/SetVector.h" 37 #include "llvm/Support/Allocator.h" 38 #include "llvm/Support/Compiler.h" 92 NodeGroup(
bool Flag =
false) : P(Flag) {
93 assert(getFlag() == Flag);
100 unsigned size()
const;
102 bool empty()
const {
return P == 0 || getFlag() != 0; }
117 bool getFlag()
const {
138 : Location(loc), State(
std::move(state)), Succs(IsSink) {
139 assert(
isSink() == IsSink);
159 template <
typename T>
166 template <
typename T>
168 return Location.
getAs<T>();
181 ID.AddPointer(state.get());
182 ID.AddBoolean(IsSink);
199 bool isSink()
const {
return Succs.getFlag(); }
256 void replaceSuccessor(
ExplodedNode *node) { Succs.replaceNode(node); }
257 void replacePredecessor(
ExplodedNode *node) { Preds.replaceNode(node); }
261 llvm::DenseMap<const ExplodedNode *, const ExplodedNode *>;
281 llvm::FoldingSet<ExplodedNode>
Nodes;
288 unsigned NumNodes = 0;
299 unsigned ReclaimNodeInterval = 0;
314 bool* IsNew =
nullptr);
322 bool IsSink =
false);
325 return llvm::make_unique<ExplodedGraph>();
336 EndNodes.push_back(V);
341 unsigned num_eops()
const {
return EndNodes.size(); }
343 bool empty()
const {
return NumNodes == 0; }
344 unsigned size()
const {
return NumNodes; }
346 void reserve(
unsigned NodeCount) { Nodes.reserve(NodeCount); }
385 using NodeMap = llvm::DenseMap<const ExplodedNode *, ExplodedNode *>;
397 std::unique_ptr<ExplodedGraph>
405 ReclaimCounter = ReclaimNodeInterval = Interval;
410 void reclaimRecentlyAllocatedNodes();
414 static bool isInterestingLValueExpr(
const Expr *Ex);
427 assert(N && !static_cast<ExplodedNode*>(N)->
isSink());
434 if (N && !static_cast<ExplodedNode*>(N)->
isSink()) Impl.insert(N);
440 unsigned size()
const {
return Impl.size(); }
441 bool empty()
const {
return Impl.empty(); }
503 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_EXPLODEDGRAPH_H
const_iterator end() const
unsigned ReclaimCounter
Counter to determine when to reclaim nodes.
void Profile(llvm::FoldingSetNodeID &ID) const
const_roots_iterator roots_begin() const
const ExplodedNode * getFirstPred() const
ImplTy::iterator iterator
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Stmt - This represents one statement.
static ChildIteratorType child_begin(NodeRef N)
NodeVector FreeNodes
A list of nodes that can be reused.
AllNodesTy::const_iterator const_node_iterator
Decl - This represents one declaration (or definition), e.g.
const_eop_iterator eop_begin() const
friend class ExplodedGraph
const_succ_iterator succ_begin() const
const_node_iterator nodes_end() const
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
static nodes_iterator nodes_begin(NodeRef N)
const ProgramStateRef & getState() const
llvm::BumpPtrAllocator & getAllocator()
const_pred_iterator pred_end() const
const_succ_iterator succ_end() const
static ChildIteratorType child_end(NodeRef N)
const Decl & getCodeDecl() const
roots_iterator roots_begin()
clang::ento::ExplodedNode::succ_iterator ChildIteratorType
NodeVector ChangedNodes
A list of recently allocated nodes that can potentially be recycled.
const_eop_iterator eop_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()
NodeVector::const_iterator const_eop_iterator
std::vector< ExplodedNode * > NodeVector
NodeVector::iterator roots_iterator
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
const StackFrameContext * getStackFrame() const
void enableNodeReclamation(unsigned Interval)
Enable tracking of recently allocated nodes for potential reclamation when calling reclaimRecentlyAll...
unsigned succ_size() const
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
static nodes_iterator nodes_end(NodeRef N)
const LocationContext * getLocationContext() const
std::unique_ptr< ExplodedGraph > MakeEmptyGraph() const
const_roots_iterator roots_end() const
ExplodedNode * getFirstPred()
llvm::FoldingSet< ExplodedNode > AllNodesTy
unsigned pred_size() const
const ExplodedNode *const * const_succ_iterator
AllNodesTy::iterator node_iterator
Expr - This represents one expression.
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt...
llvm::DenseMap< const ExplodedNode *, ExplodedNode * > NodeMap
This is the simplest builder which generates nodes in the ExplodedGraph.
ExplodedNode *const * succ_iterator
void Add(ExplodedNode *N)
unsigned num_roots() const
const_node_iterator nodes_begin() const
static ChildIteratorType child_begin(NodeRef N)
static void Profile(llvm::FoldingSetNodeID &ID, const ProgramPoint &Loc, const ProgramStateRef &state, bool IsSink)
__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
llvm::df_iterator< NodeRef > nodes_iterator
node_iterator nodes_begin()
ImplTy::const_iterator const_iterator
BumpVectorContext BVC
BVC - Allocator and context for allocating nodes and their predecessor and successor groups...
llvm::df_iterator< NodeRef > nodes_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.
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
clang::ento::ExplodedNode::const_succ_iterator ChildIteratorType
node_iterator nodes_end()
NodeVector::iterator eop_iterator
ParentMap & getParentMap() const
SVal getSVal(const Stmt *S) const
Get the value of an arbitrary expression at this node.
void insert(const ExplodedNodeSet &S)
CoreEngine - Implements the core logic of the graph-reachability analysis.
NodeVector::const_iterator const_roots_iterator
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 ...
ExplodedNode(const ProgramPoint &loc, ProgramStateRef state, bool IsSink)
const Decl * getDecl() const
void reserve(unsigned NodeCount)
llvm::DenseMap< const ExplodedNode *, const ExplodedNode * > InterExplodedGraphMap
static ChildIteratorType child_end(NodeRef N)
static void SetAuditor(Auditor *A)
const LocationContext * getLocationContext() const
friend class EndOfFunctionNodeBuilder
static nodes_iterator nodes_begin(NodeRef N)
bool erase(ExplodedNode *N)
unsigned num_eops() const
static NodeRef getEntryNode(NodeRef N)
pred_iterator pred_begin()
llvm::BumpPtrAllocator & getAllocator()
static NodeRef getEntryNode(NodeRef N)
ExplodedNode * addEndOfPath(ExplodedNode *V)
addEndOfPath - Add an untyped node to the set of EOP nodes.
const StackFrameContext * getStackFrame() const
const ExplodedNode *const * const_pred_iterator
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 *const * pred_iterator
ExplodedNode * addRoot(ExplodedNode *V)
addRoot - Add an untyped node to the set of roots.
const_iterator begin() const