18 #ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_EXPLODEDGRAPH_H 19 #define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_EXPLODEDGRAPH_H 28 #include "llvm/ADT/ArrayRef.h" 29 #include "llvm/ADT/DenseMap.h" 30 #include "llvm/ADT/DepthFirstIterator.h" 31 #include "llvm/ADT/FoldingSet.h" 32 #include "llvm/ADT/GraphTraits.h" 33 #include "llvm/ADT/Optional.h" 34 #include "llvm/ADT/STLExtras.h" 35 #include "llvm/ADT/SetVector.h" 36 #include "llvm/Support/Allocator.h" 37 #include "llvm/Support/Compiler.h" 91 NodeGroup(
bool Flag =
false) : P(Flag) {
92 assert(getFlag() == Flag);
99 unsigned size()
const;
101 bool empty()
const {
return P == 0 || getFlag() != 0; }
116 bool getFlag()
const {
138 int64_t Id,
bool IsSink)
139 : Location(loc), State(
std::move(state)), Succs(IsSink), Id(Id) {
140 assert(
isSink() == IsSink);
164 template <
typename T>
171 template <
typename T>
173 return Location.
getAs<T>();
186 ID.AddPointer(state.get());
187 ID.AddBoolean(IsSink);
204 bool isSink()
const {
return Succs.getFlag(); }
263 int64_t
getID()
const {
return Id; }
298 void replacePredecessor(
ExplodedNode *node) { Preds.replaceNode(node); }
302 llvm::DenseMap<const ExplodedNode *, const ExplodedNode *>;
322 llvm::FoldingSet<ExplodedNode>
Nodes;
329 int64_t NumNodes = 0;
340 unsigned ReclaimNodeInterval = 0;
355 bool* IsNew =
nullptr);
364 bool IsSink =
false);
367 return std::make_unique<ExplodedGraph>();
378 EndNodes.push_back(V);
383 unsigned num_eops()
const {
return EndNodes.size(); }
385 bool empty()
const {
return NumNodes == 0; }
386 unsigned size()
const {
return NumNodes; }
388 void reserve(
unsigned NodeCount) { Nodes.reserve(NodeCount); }
427 using NodeMap = llvm::DenseMap<const ExplodedNode *, ExplodedNode *>;
439 std::unique_ptr<ExplodedGraph>
447 ReclaimCounter = ReclaimNodeInterval = Interval;
452 void reclaimRecentlyAllocatedNodes();
456 static bool isInterestingLValueExpr(
const Expr *Ex);
469 assert(N && !static_cast<ExplodedNode*>(N)->
isSink());
476 if (N && !static_cast<ExplodedNode*>(N)->
isSink()) Impl.insert(N);
482 unsigned size()
const {
return Impl.size(); }
483 bool empty()
const {
return Impl.empty(); }
525 if (predecessorOfTrivial(N))
531 if (predecessorOfTrivial(N))
546 #endif // LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_EXPLODEDGRAPH_H
const_iterator end() const
unsigned ReclaimCounter
Counter to determine when to reclaim nodes.
llvm::iterator_range< const_succ_iterator > const_succ_range
void Profile(llvm::FoldingSetNodeID &ID) const
const_roots_iterator roots_begin() const
const Stmt * getStmtForDiagnostics() const
If the node's program point corresponds to a statement, retrieve that statement.
const Stmt * getCurrentOrPreviousStmtForDiagnostics() const
Find the statement that was executed at or immediately before this node.
const ExplodedNode * getFirstPred() const
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
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
ExplodedNode(const ProgramPoint &loc, ProgramStateRef state, int64_t Id, bool IsSink)
const CFGBlock * getCFGBlock() const
const_succ_iterator succ_begin() const
const_pred_range preds() 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
llvm::iterator_range< const_pred_iterator > const_pred_range
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
Represents a single basic block in a source-level CFG.
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()
const ParentMap & getParentMap() const
llvm::DenseMap< const ExplodedNode *, ExplodedNode * > NodeMap
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
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)
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.
const Stmt * getPreviousStmtForDiagnostics() const
Find the statement that was executed immediately before this 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
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
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 ...
const Decl * getDecl() const
void reserve(unsigned NodeCount)
llvm::iterator_range< pred_iterator > pred_range
llvm::DenseMap< const ExplodedNode *, const ExplodedNode * > InterExplodedGraphMap
static Expected< DynTypedNode > getNode(const ast_matchers::BoundNodes &Nodes, StringRef ID)
const LocationContext * getLocationContext() const
friend class EndOfFunctionNodeBuilder
const_succ_range succs() const
llvm::iterator_range< succ_iterator > succ_range
bool erase(ExplodedNode *N)
unsigned num_eops() const
const ParentMap & getParentMap() const
pred_iterator pred_begin()
llvm::BumpPtrAllocator & getAllocator()
ExplodedNode * addEndOfPath(ExplodedNode *V)
addEndOfPath - Add an untyped node to the set of EOP nodes.
const Stmt * getNextStmtForDiagnostics() const
Find the next statement that was executed on this node's execution path.
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