+ /// A node in the call graph.
+ ///
+ /// This represents a single node. It's primary roles are to cache the list of
+ /// callees, de-duplicate and provide fast testing of whether a function is
+ /// a callee, and facilitate iteration of child nodes in the graph.
+ class Node {
+ friend class LazyCallGraph;
+ friend class LazyCallGraph::SCC;
+
+ LazyCallGraph *G;
+ Function &F;
+
+ // We provide for the DFS numbering and Tarjan walk lowlink numbers to be
+ // stored directly within the node.
+ int DFSNumber;
+ int LowLink;
+
+ mutable NodeVectorT Callees;
+ DenseMap<Function *, size_t> CalleeIndexMap;
+
+ /// Basic constructor implements the scanning of F into Callees and
+ /// CalleeIndexMap.
+ Node(LazyCallGraph &G, Function &F);
+
+ /// Internal helper to insert a callee.
+ void insertEdgeInternal(Function &Callee);
+
+ /// Internal helper to insert a callee.
+ void insertEdgeInternal(Node &CalleeN);
+
+ /// Internal helper to remove a callee from this node.
+ void removeEdgeInternal(Function &Callee);
+
+ public:
+ typedef LazyCallGraph::iterator iterator;
+
+ Function &getFunction() const { return F; }
+
+ iterator begin() const {
+ return iterator(*G, Callees.begin(), Callees.end());
+ }
+ iterator end() const { return iterator(*G, Callees.end(), Callees.end()); }
+
+ /// Equality is defined as address equality.
+ bool operator==(const Node &N) const { return this == &N; }
+ bool operator!=(const Node &N) const { return !operator==(N); }
+ };
+
+ /// A lazy iterator used for both the entry nodes and child nodes.