summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-11-04 02:53:39 +0000
committerChris Lattner <sabre@nondot.org>2002-11-04 02:53:39 +0000
commit7e5f46a441ced022d40dca5a2ecb076499e09078 (patch)
treef901ab4bd5cd882dcc7f768ec0f1c8656673edc1 /include
parent048912bad9a3164b340d25bd30a1e22385e12056 (diff)
downloadllvm-7e5f46a441ced022d40dca5a2ecb076499e09078.tar.gz
llvm-7e5f46a441ced022d40dca5a2ecb076499e09078.tar.bz2
llvm-7e5f46a441ced022d40dca5a2ecb076499e09078.tar.xz
Implement methods needed to print out call graph
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4522 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Analysis/CallGraph.h25
1 files changed, 22 insertions, 3 deletions
diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h
index 740709d29f..fde7c82abb 100644
--- a/include/llvm/Analysis/CallGraph.h
+++ b/include/llvm/Analysis/CallGraph.h
@@ -42,6 +42,7 @@
#define LLVM_ANALYSIS_CALLGRAPH_H
#include "Support/GraphTraits.h"
+#include "Support/STLExtras.h"
#include "llvm/Pass.h"
class Function;
class Module;
@@ -242,18 +243,36 @@ template <> struct GraphTraits<const CallGraphNode*> {
static inline ChildIteratorType child_end (NodeType *N) { return N->end(); }
};
-
-template<> struct GraphTraits<CallGraph*> :
- public GraphTraits<CallGraphNode*> {
+template<> struct GraphTraits<CallGraph*> : public GraphTraits<CallGraphNode*> {
static NodeType *getEntryNode(CallGraph *CGN) {
return CGN->getExternalNode(); // Start at the external node!
}
+ typedef std::pair<const Function*, CallGraphNode*> PairTy;
+ typedef std::pointer_to_unary_function<PairTy, CallGraphNode&> DerefFun;
+
+ // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
+ typedef mapped_iterator<CallGraph::iterator, DerefFun> nodes_iterator;
+ static nodes_iterator nodes_begin(CallGraph *CG) {
+ return map_iterator(CG->begin(), DerefFun(CGdereference));
+ }
+ static nodes_iterator nodes_end (CallGraph *CG) {
+ return map_iterator(CG->end(), DerefFun(CGdereference));
+ }
+
+ static CallGraphNode &CGdereference (std::pair<const Function*,
+ CallGraphNode*> P) {
+ return *P.second;
+ }
};
template<> struct GraphTraits<const CallGraph*> :
public GraphTraits<const CallGraphNode*> {
static NodeType *getEntryNode(const CallGraph *CGN) {
return CGN->getExternalNode();
}
+ // nodes_iterator/begin/end - Allow iteration over all nodes in the graph
+ typedef CallGraph::const_iterator nodes_iterator;
+ static nodes_iterator nodes_begin(const CallGraph *CG) { return CG->begin(); }
+ static nodes_iterator nodes_end (const CallGraph *CG) { return CG->end(); }
};
#endif