Add a newline to the end of this file.
[oota-llvm.git] / lib / Analysis / IPA / CallGraph.cpp
index 128e11ebd7f28b3b46fa89098f4d466776ba4d80..5f9850c93dcbff08dd43d71558e6eed0fec6971a 100644 (file)
@@ -16,6 +16,7 @@
 #include "llvm/Module.h"
 #include "llvm/Instructions.h"
 #include "llvm/Support/CallSite.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/Streams.h"
 #include <ostream>
 using namespace llvm;
@@ -35,7 +36,7 @@ namespace {
 //===----------------------------------------------------------------------===//
 // BasicCallGraph class definition
 //
-class BasicCallGraph : public CallGraph, public ModulePass {
+class VISIBILITY_HIDDEN BasicCallGraph : public CallGraph, public ModulePass {
   // Root is root of the call graph, or the external node if a 'main' function
   // couldn't be found.
   //
@@ -50,7 +51,9 @@ class BasicCallGraph : public CallGraph, public ModulePass {
   CallGraphNode *CallsExternalNode;
 
 public:
-  BasicCallGraph() : Root(0), ExternalCallingNode(0), CallsExternalNode(0) {}
+  static char ID; // Class identification, replacement for typeinfo
+  BasicCallGraph() : ModulePass((intptr_t)&ID), Root(0), 
+    ExternalCallingNode(0), CallsExternalNode(0) {}
 
   // runOnModule - Compute the call graph for the specified module.
   virtual bool runOnModule(Module &M) {
@@ -74,8 +77,8 @@ public:
     AU.setPreservesAll();
   }
 
-  void print(llvm_ostream &o, const Module *M) const {
-    if (o.stream()) print(*o.stream(), M);
+  void print(std::ostream *o, const Module *M) const {
+    if (o) print(*o, M);
   }
 
   virtual void print(std::ostream &o, const Module *M) const {
@@ -95,7 +98,7 @@ public:
   /// dump - Print out this call graph.
   ///
   inline void dump() const {
-    print(llvm_cerr, Mod);
+    print(cerr, Mod);
   }
 
   CallGraphNode* getExternalCallingNode() const { return ExternalCallingNode; }
@@ -133,7 +136,7 @@ private:
 
     // If this function is not defined in this translation unit, it could call
     // anything.
-    if (F->isExternal() && !F->getIntrinsicID())
+    if (F->isDeclaration() && !F->getIntrinsicID())
       Node->addCalledFunction(CallSite(), CallsExternalNode);
 
     // Loop over all of the users of the function... looking for callers...
@@ -193,6 +196,9 @@ RegisterAnalysisGroup<CallGraph, true> Z(Y);
 
 } //End anonymous namespace
 
+char CallGraph::ID = 0;
+char BasicCallGraph::ID = 0;
+
 void CallGraph::initialize(Module &M) {
   Mod = &M;
 }
@@ -212,7 +218,7 @@ void CallGraph::print(std::ostream &OS, const Module *M) const {
 }
 
 void CallGraph::dump() const {
-  print(llvm_cerr, 0);
+  print(cerr, 0);
 }
 
 //===----------------------------------------------------------------------===//
@@ -275,7 +281,7 @@ void CallGraphNode::print(std::ostream &OS) const {
   OS << "\n";
 }
 
-void CallGraphNode::dump() const { print(llvm_cerr); }
+void CallGraphNode::dump() const { print(cerr); }
 
 void CallGraphNode::removeCallEdgeTo(CallGraphNode *Callee) {
   for (unsigned i = CalledFunctions.size(); ; --i) {