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 {
137 : Location(loc), State(
std::move(state)), Succs(IsSink) {
138 assert(
isSink() == IsSink);
158 template <
typename T>
165 template <
typename T>
167 return Location.
getAs<T>();
180 ID.AddPointer(state.get());
181 ID.AddBoolean(IsSink);
198 bool isSink()
const {
return Succs.getFlag(); }
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(); }
483 if (predecessorOfTrivial(N))
489 if (predecessorOfTrivial(N))
504 #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
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
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
__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)
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
static Expected< DynTypedNode > getNode(const ast_matchers::BoundNodes &Nodes, StringRef ID)
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