Allow the call graph to be called from analyze naturally with print implemented
authorChris Lattner <sabre@nondot.org>
Mon, 4 Nov 2002 00:21:19 +0000 (00:21 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 4 Nov 2002 00:21:19 +0000 (00:21 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4517 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/CallGraph.h
lib/Analysis/IPA/CallGraph.cpp

index 3c9106cec2ef3b6d11c4c6369d08413a37d7a088..740709d29f8732be899bd0b6fa6df194adca40e3 100644 (file)
@@ -137,6 +137,12 @@ public:
     destroy();
   }
 
+  /// Print the types found in the module.  If the optional Module parameter is
+  /// passed in, then the types are printed symbolically if possible, using the
+  /// symbol table from the module.
+  ///
+  void print(std::ostream &o, const Module *M) const;
+
 private:
   //===---------------------------------------------------------------------
   // Implementation of CallGraph construction
@@ -250,21 +256,4 @@ template<> struct GraphTraits<const CallGraph*> :
   }
 };
 
-
-//===----------------------------------------------------------------------===//
-// Printing support for Call Graphs
-//
-
-// Stuff for printing out a callgraph...
-
-void WriteToOutput(const CallGraph &, std::ostream &o);
-inline std::ostream &operator <<(std::ostream &o, const CallGraph &CG) {
-  WriteToOutput(CG, o); return o;
-}
-  
-void WriteToOutput(const CallGraphNode *, std::ostream &o);
-inline std::ostream &operator <<(std::ostream &o, const CallGraphNode *CGN) {
-  WriteToOutput(CGN, o); return o;
-}
-
 #endif
index 5c4b5d81f7ecd06b2c52f639e95dd66b10fe42f8..2c26f8dbb2662c2bd0ec543b7b747c275478b649 100644 (file)
@@ -130,8 +130,7 @@ void CallGraph::destroy() {
   FunctionMap.clear();
 }
 
-
-void WriteToOutput(const CallGraphNode *CGN, std::ostream &o) {
+static void WriteToOutput(const CallGraphNode *CGN, std::ostream &o) {
   if (CGN->getFunction())
     o << "Call graph node for function: '"
       << CGN->getFunction()->getName() <<"'\n";
@@ -146,11 +145,11 @@ void WriteToOutput(const CallGraphNode *CGN, std::ostream &o) {
   o << "\n";
 }
 
-void WriteToOutput(const CallGraph &CG, std::ostream &o) {
-  o << "CallGraph Root is:\n" << CG.getRoot();
+void CallGraph::print(std::ostream &o, const Module *M) const {
+  o << "CallGraph Root is:\n" << getRoot();
 
-  for (CallGraph::const_iterator I = CG.begin(), E = CG.end(); I != E; ++I)
-    o << I->second;
+  for (CallGraph::const_iterator I = begin(), E = end(); I != E; ++I)
+    WriteToOutput(I->second, o);
 }