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(); }
257 void replaceSuccessor(
ExplodedNode *node) { Succs.replaceNode(node); }
258 void replacePredecessor(
ExplodedNode *node) { Preds.replaceNode(node); }
262 llvm::DenseMap<const ExplodedNode *, const ExplodedNode *>;
282 llvm::FoldingSet<ExplodedNode>
Nodes;
289 unsigned NumNodes = 0;
300 unsigned ReclaimNodeInterval = 0;
315 bool* IsNew =
nullptr);
323 bool IsSink =
false);
326 return llvm::make_unique<ExplodedGraph>();
337 EndNodes.push_back(V);
342 unsigned num_eops()
const {
return EndNodes.size(); }
344 bool empty()
const {
return NumNodes == 0; }
345 unsigned size()
const {
return NumNodes; }
347 void reserve(
unsigned NodeCount) { Nodes.reserve(NodeCount); }
386 using NodeMap = llvm::DenseMap<const ExplodedNode *, ExplodedNode *>;
398 std::unique_ptr<ExplodedGraph>
406 ReclaimCounter = ReclaimNodeInterval = Interval;
411 void reclaimRecentlyAllocatedNodes();
415 static bool isInterestingLValueExpr(
const Expr *Ex);
428 assert(N && !static_cast<ExplodedNode*>(N)->
isSink());
435 if (N && !static_cast<ExplodedNode*>(N)->
isSink()) Impl.insert(N);
441 unsigned size()
const {
return Impl.size(); }
442 bool empty()
const {
return Impl.empty(); }
484 if (predecessorOfTrivial(N))
490 if (predecessorOfTrivial(N))
505 #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.
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
static bool predecessorOfTrivial(NodeRef N)
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 ChildIteratorType child_end(NodeRef N)
const ProgramStateRef & getState() const
llvm::BumpPtrAllocator & getAllocator()
const_pred_iterator pred_end() const
llvm::df_iterator< GraphTy > nodes_iterator
const_succ_iterator succ_end() const
const Decl & getCodeDecl() const
roots_iterator roots_begin()
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...
static nodes_iterator nodes_begin(const GraphTy G)
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...
const LocationContext * getLocationContext() const
std::unique_ptr< ExplodedGraph > MakeEmptyGraph() const
clang::ento::ExplodedNode::succ_iterator ChildIteratorType
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
This represents one expression.
Represents a source-level, intra-procedural CFG that represents the control-flow of a Stmt...
ExplodedNode * getFirstSucc()
llvm::DenseMap< const ExplodedNode *, ExplodedNode * > NodeMap
static nodes_iterator nodes_end(const GraphTy G)
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)
static NodeRef getEntryNode(const GraphTy G)
__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
node_iterator nodes_begin()
ImplTy::const_iterator const_iterator
BumpVectorContext BVC
BVC - Allocator and context for allocating nodes and their predecessor and successor groups...
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...
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)
int64_t getID(ExplodedGraph *G) const
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
bool isTrivial() const
The node is trivial if it has only one successor, only one predecessor, it's predecessor has only one...
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
const LocationContext * getLocationContext() const
friend class EndOfFunctionNodeBuilder
bool erase(ExplodedNode *N)
unsigned num_eops() const
pred_iterator pred_begin()
llvm::BumpPtrAllocator & getAllocator()
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