Change Pass::print to take a raw ostream instead of std::ostream,
update all code that this affects.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79830 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/opt/AnalysisWrappers.cpp b/tools/opt/AnalysisWrappers.cpp
index 2ab69ea..18360f8 100644
--- a/tools/opt/AnalysisWrappers.cpp
+++ b/tools/opt/AnalysisWrappers.cpp
@@ -34,27 +34,31 @@
     static char ID; // Pass ID, replacement for typeid
     ExternalFunctionsPassedConstants() : ModulePass(&ID) {}
     virtual bool runOnModule(Module &M) {
-      for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
-        if (I->isDeclaration()) {
-          bool PrintedFn = false;
-          for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
-               UI != E; ++UI)
-            if (Instruction *User = dyn_cast<Instruction>(*UI)) {
-              CallSite CS = CallSite::get(User);
-              if (CS.getInstruction()) {
-                for (CallSite::arg_iterator AI = CS.arg_begin(),
-                       E = CS.arg_end(); AI != E; ++AI)
-                  if (isa<Constant>(*AI)) {
-                    if (!PrintedFn) {
-                      errs() << "Function '" << I->getName() << "':\n";
-                      PrintedFn = true;
-                    }
-                    errs() << *User;
-                    break;
-                  }
-              }
+      for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
+        if (!I->isDeclaration()) continue;
+        
+        bool PrintedFn = false;
+        for (Value::use_iterator UI = I->use_begin(), E = I->use_end();
+             UI != E; ++UI) {
+          Instruction *User = dyn_cast<Instruction>(*UI);
+          if (!User) continue;
+          
+          CallSite CS = CallSite::get(User);
+          if (!CS.getInstruction()) continue;
+          
+          for (CallSite::arg_iterator AI = CS.arg_begin(),
+               E = CS.arg_end(); AI != E; ++AI) {
+            if (!isa<Constant>(*AI)) continue;
+
+            if (!PrintedFn) {
+              errs() << "Function '" << I->getName() << "':\n";
+              PrintedFn = true;
             }
+            errs() << *User;
+            break;
+          }
         }
+      }
 
       return false;
     }
@@ -78,7 +82,7 @@
       AU.addRequiredTransitive<CallGraph>();
     }
     virtual bool runOnModule(Module &M) {
-      getAnalysis<CallGraph>().print(std::cerr, &M);
+      getAnalysis<CallGraph>().print(errs(), &M);
       return false;
     }
   };
diff --git a/tools/opt/GraphPrinters.cpp b/tools/opt/GraphPrinters.cpp
index 5d581e4..6bd0a6e 100644
--- a/tools/opt/GraphPrinters.cpp
+++ b/tools/opt/GraphPrinters.cpp
@@ -70,8 +70,7 @@
       return false;
     }
 
-    void print(std::ostream &OS) const {}
-    void print(std::ostream &OS, const llvm::Module*) const {}
+    void print(raw_ostream &OS, const llvm::Module*) const {}
 
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       AU.addRequired<CallGraph>();
diff --git a/tools/opt/PrintSCC.cpp b/tools/opt/PrintSCC.cpp
index a0aa4e9..66709ff 100644
--- a/tools/opt/PrintSCC.cpp
+++ b/tools/opt/PrintSCC.cpp
@@ -39,7 +39,7 @@
     CFGSCC() : FunctionPass(&ID) {}
     bool runOnFunction(Function& func);
 
-    void print(std::ostream &O, const Module* = 0) const { }
+    void print(raw_ostream &O, const Module* = 0) const { }
 
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       AU.setPreservesAll();
@@ -53,7 +53,7 @@
     // run - Print out SCCs in the call graph for the specified module.
     bool runOnModule(Module &M);
 
-    void print(std::ostream &O, const Module* = 0) const { }
+    void print(raw_ostream &O, const Module* = 0) const { }
 
     // getAnalysisUsage - This pass requires the CallGraph.
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp
index 4f24198..f41b202 100644
--- a/tools/opt/opt.cpp
+++ b/tools/opt/opt.cpp
@@ -140,7 +140,7 @@
         Function *F = SCC[i]->getFunction();
         if (F) {
           outs().flush();
-          getAnalysisID<Pass>(PassToPrint).print(cout, F->getParent());
+          getAnalysisID<Pass>(PassToPrint).print(outs(), F->getParent());
           cout << std::flush;
         }
       }
@@ -169,7 +169,7 @@
     if (!Quiet) {
       outs() << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
       outs().flush();
-      getAnalysisID<Pass>(PassToPrint).print(cout, &M);
+      getAnalysisID<Pass>(PassToPrint).print(outs(), &M);
       cout << std::flush;
     }
 
@@ -199,7 +199,7 @@
     }
     // Get and print pass...
     outs().flush();
-    getAnalysisID<Pass>(PassToPrint).print(cout, F.getParent());
+    getAnalysisID<Pass>(PassToPrint).print(outs(), F.getParent());
     cout << std::flush;
     return false;
   }
@@ -224,7 +224,7 @@
     if (!Quiet) {
       outs() << "Printing analysis '" << PassToPrint->getPassName() << "':\n";
       outs().flush();
-      getAnalysisID<Pass>(PassToPrint).print(cout,
+      getAnalysisID<Pass>(PassToPrint).print(outs(),
                                   L->getHeader()->getParent()->getParent());
       cout << std::flush;
     }
@@ -256,7 +256,7 @@
 
     // Get and print pass...
     outs().flush();
-    getAnalysisID<Pass>(PassToPrint).print(cout, BB.getParent()->getParent());
+    getAnalysisID<Pass>(PassToPrint).print(outs(), BB.getParent()->getParent());
     cout << std::flush;
     return false;
   }