Convert to using llvm streams instead of iostreams.
authorBill Wendling <isanbard@gmail.com>
Tue, 28 Nov 2006 23:33:06 +0000 (23:33 +0000)
committerBill Wendling <isanbard@gmail.com>
Tue, 28 Nov 2006 23:33:06 +0000 (23:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31989 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/BasicAliasAnalysis.cpp
lib/Analysis/DataStructure/BottomUpClosure.cpp
lib/Analysis/DataStructure/CallTargets.cpp
lib/Analysis/DataStructure/DataStructure.cpp
lib/Analysis/DataStructure/DataStructureStats.cpp
lib/Analysis/DataStructure/EquivClassGraphs.cpp
lib/Analysis/DataStructure/GraphChecker.cpp
tools/llvm-dis/llvm-dis.cpp
tools/opt/opt.cpp

index a7269ffa091acdc732b4f3b7f1b3cca885f9ece8..26bcb438a2eead57facd13e143b6183ec260e369 100644 (file)
@@ -745,7 +745,7 @@ BasicAliasAnalysis::CheckGEPInstructions(
     assert(Offset1<Offset2 && "There is at least one different constant here!");
 
     if ((uint64_t)(Offset2-Offset1) >= SizeMax) {
-      //std::cerr << "Determined that these two GEP's don't alias ["
+      //llvm_cerr << "Determined that these two GEP's don't alias ["
       //          << SizeMax << " bytes]: \n" << *GEP1 << *GEP2;
       return NoAlias;
     }
index 0f48850ae9eae3a89d757fbcb46c4ec42cf84d68..19b3ec1533ef1e95cd6b9a3f622659afac80200e 100644 (file)
@@ -13,6 +13,7 @@
 // applications like alias analysis.
 //
 //===----------------------------------------------------------------------===//
+
 #define DEBUG_TYPE "bu_dsa"
 #include "llvm/Analysis/DataStructure/DataStructure.h"
 #include "llvm/Analysis/DataStructure/DSGraph.h"
@@ -22,7 +23,6 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/Timer.h"
-#include <iostream>
 using namespace llvm;
 
 namespace {
@@ -501,7 +501,7 @@ DSGraph &BUDataStructures::CreateGraphForExternalFunction(const Function &Fn) {
     DSG->getNodeForValue(F->arg_begin()).mergeWith(N);
 
   } else {
-    std::cerr << "Unrecognized external function: " << F->getName() << "\n";
+    llvm_cerr << "Unrecognized external function: " << F->getName() << "\n";
     abort();
   }
 
@@ -588,21 +588,21 @@ void BUDataStructures::calculateGraph(DSGraph &Graph) {
         ++NumBUInlines;
       } else {
         if (!Printed)
-          std::cerr << "In Fns: " << Graph.getFunctionNames() << "\n";
-        std::cerr << "  calls " << CalledFuncs.size()
+          llvm_cerr << "In Fns: " << Graph.getFunctionNames() << "\n";
+        llvm_cerr << "  calls " << CalledFuncs.size()
                   << " fns from site: " << CS.getCallSite().getInstruction()
                   << "  " << *CS.getCallSite().getInstruction();
-        std::cerr << "   Fns =";
+        llvm_cerr << "   Fns =";
         unsigned NumPrinted = 0;
 
         for (std::vector<Function*>::iterator I = CalledFuncs.begin(),
                E = CalledFuncs.end(); I != E; ++I) {
-          if (NumPrinted++ < 8) std::cerr << " " << (*I)->getName();
+          if (NumPrinted++ < 8) llvm_cerr << " " << (*I)->getName();
 
           // Add the call edges to the call graph.
           ActualCallees.insert(std::make_pair(TheCall, *I));
         }
-        std::cerr << "\n";
+        llvm_cerr << "\n";
 
         // See if we already computed a graph for this set of callees.
         std::sort(CalledFuncs.begin(), CalledFuncs.end());
@@ -645,7 +645,7 @@ void BUDataStructures::calculateGraph(DSGraph &Graph) {
           // Clean up the final graph!
           GI->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
         } else {
-          std::cerr << "***\n*** RECYCLED GRAPH ***\n***\n";
+          llvm_cerr << "***\n*** RECYCLED GRAPH ***\n***\n";
         }
 
         GI = IndCallGraph.first;
@@ -685,7 +685,7 @@ void BUDataStructures::calculateGraph(DSGraph &Graph) {
          E = MainSM.global_end(); I != E; ++I)
     RC.getClonedNH(MainSM[*I]);
 
-  //Graph.writeGraphToFile(std::cerr, "bu_" + F.getName());
+  //Graph.writeGraphToFile(llvm_cerr, "bu_" + F.getName());
 }
 
 static const Function *getFnForValue(const Value *V) {
@@ -746,8 +746,8 @@ void BUDataStructures::copyValue(Value *From, Value *To) {
     return;
   }
 
-  std::cerr << *From;
-  std::cerr << *To;
+  llvm_cerr << *From;
+  llvm_cerr << *To;
   assert(0 && "Do not know how to copy this yet!");
   abort();
 }
index 8b33cb0cb141a539beab9686312f7c06d03e2c99..5850749c6fdc678609d5f8c29ca3d517cdaa55b2 100644 (file)
@@ -23,9 +23,9 @@
 #include "llvm/Analysis/DataStructure/DSGraph.h"
 #include "llvm/Analysis/DataStructure/CallTargets.h"
 #include "llvm/ADT/Statistic.h"
-#include <iostream>
+#include "llvm/Support/Streams.h"
+#include <ostream>
 #include "llvm/Constants.h"
-
 using namespace llvm;
 
 namespace {
@@ -58,7 +58,7 @@ void CallTargetFinder::findIndTargets(Module &M)
               } 
               if (N->isComplete() && !IndMap[cs].size()) {
                 ++CompleteEmpty;
-                std::cerr << "Call site empty: '"
+                llvm_cerr << "Call site empty: '"
                 << cs.getInstruction()->getName() 
                           << "' In '"
                 << cs.getInstruction()->getParent()->getParent()->getName()
index 8b8bde0026d869a4cc4b28d3995dbd48e6ab0ed2..6eee541aeb578b92c024ca686741981c2061ffe7 100644 (file)
@@ -25,6 +25,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SCCIterator.h"
 #include "llvm/ADT/Statistic.h"
+#include "llvm/Support/Streams.h"
 #include "llvm/Support/Timer.h"
 #include <iostream>
 #include <algorithm>
@@ -1262,7 +1263,7 @@ DSGraph::~DSGraph() {
 }
 
 // dump - Allow inspection of graph in a debugger.
-void DSGraph::dump() const { print(std::cerr); }
+void DSGraph::dump() const { print(llvm_cerr); }
 
 
 /// remapLinks - Change all of the Links in the current node according to the
index a73fc96e6e307b2c5ca2ec3218a2e41f70f04fff..469ab2e719ea6c202142ba69dcb7091319937d53 100644 (file)
@@ -17,8 +17,9 @@
 #include "llvm/Instructions.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/InstVisitor.h"
+#include "llvm/Support/Streams.h"
 #include "llvm/ADT/Statistic.h"
-#include <iostream>
+#include <ostream>
 using namespace llvm;
 
 namespace {
@@ -91,7 +92,7 @@ void DSGraphStats::countCallees(const Function& F) {
         totalNumCallees  += Callees.size();
         ++numIndirectCalls;
       } else
-        std::cerr << "WARNING: No callee in Function '" << F.getName()
+        llvm_cerr << "WARNING: No callee in Function '" << F.getName()
                   << "' at call: \n"
                   << *I->getCallSite().getInstruction();
     }
@@ -100,7 +101,7 @@ void DSGraphStats::countCallees(const Function& F) {
   NumIndirectCalls += numIndirectCalls;
 
   if (numIndirectCalls)
-    std::cout << "  In function " << F.getName() << ":  "
+    llvm_cout << "  In function " << F.getName() << ":  "
               << (totalNumCallees / (double) numIndirectCalls)
               << " average callees per indirect call\n";
 }
index 4b1eaa9ea0157d326388aeab96ddf8ed8928b3ce..38aaf0b93c0a8e61663771cb13bb7559d13af315 100644 (file)
@@ -26,7 +26,6 @@
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/EquivalenceClasses.h"
 #include "llvm/ADT/STLExtras.h"
-#include <iostream>
 using namespace llvm;
 
 namespace {
@@ -91,7 +90,7 @@ bool EquivClassGraphs::runOnModule(Module &M) {
   if (MainFunc && !MainFunc->isExternal()) {
     processSCC(getOrCreateGraph(*MainFunc), Stack, NextID, ValMap);
   } else {
-    std::cerr << "Fold Graphs: No 'main' function found!\n";
+    llvm_cerr << "Fold Graphs: No 'main' function found!\n";
   }
 
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
@@ -173,8 +172,8 @@ void EquivClassGraphs::buildIndirectFunctionSets(Module &M) {
       FuncECs.insert(I->second);        // -- Make sure function has equiv class
       FirstFunc = I->second;            // -- First callee at this site
     } else {                            // Else indirect call
-      // DEBUG(std::cerr << "CALLEE: " << I->second->getName()
-      //       << " from : " << I->first);
+      // DOUT << "CALLEE: " << I->second->getName()
+      //      << " from : " << I->first;
       if (I->first != LastInst) {
         // This is the first callee from this call site.
         LastInst = I->first;
index 50a41f2b9a8118b7e387ca2b629a163dbc567fb1..cef3efed8f7c7f386bca95d288bcaab6a585aa3d 100644 (file)
 #include "llvm/Analysis/DataStructure/DataStructure.h"
 #include "llvm/Analysis/DataStructure/DSGraph.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Streams.h"
 #include "llvm/Value.h"
-#include <iostream>
 #include <set>
-
 using namespace llvm;
 
 namespace {
@@ -85,7 +84,7 @@ FunctionPass *llvm::createDataStructureGraphCheckerPass() {
 DSGC::DSGC() {
   if (!AbortIfAnyCollapsed && AbortIfCollapsed.empty() &&
       CheckFlags.empty() && AbortIfMerged.empty()) {
-    std::cerr << "The -datastructure-gc is useless if you don't specify any"
+    llvm_cerr << "The -datastructure-gc is useless if you don't specify any"
                  " -dsgc-* options.  See the -help-hidden output for a list.\n";
     abort();
   }
@@ -124,8 +123,8 @@ void DSGC::verify(const DSGraph &G) {
     for (DSGraph::node_const_iterator I = G.node_begin(), E = G.node_end();
          I != E; ++I)
       if (I->isNodeCompletelyFolded()) {
-        std::cerr << "Node is collapsed: ";
-        I->print(std::cerr, &G);
+        llvm_cerr << "Node is collapsed: ";
+        I->print(llvm_cerr, &G);
         abort();
       }
   }
@@ -143,7 +142,7 @@ void DSGC::verify(const DSGraph &G) {
            E = CheckFlags.end(); I != E; ++I) {
       std::string::size_type ColonPos = I->rfind(':');
       if (ColonPos == std::string::npos) {
-        std::cerr << "Error: '" << *I
+        llvm_cerr << "Error: '" << *I
                << "' is an invalid value for the --dsgc-check-flags option!\n";
         abort();
       }
@@ -159,7 +158,7 @@ void DSGC::verify(const DSGraph &G) {
         case 'M': Flags |= DSNode::Modified;    break;
         case 'R': Flags |= DSNode::Read;        break;
         case 'A': Flags |= DSNode::Array;       break;
-        default: std::cerr << "Invalid DSNode flag!\n"; abort();
+        default: llvm_cerr << "Invalid DSNode flag!\n"; abort();
         }
       CheckFlagsM[std::string(I->begin(), I->begin()+ColonPos)] = Flags;
     }
@@ -177,25 +176,25 @@ void DSGC::verify(const DSGraph &G) {
 
         // Verify it is not collapsed if it is not supposed to be...
         if (N->isNodeCompletelyFolded() && AbortIfCollapsedS.count(Name)) {
-          std::cerr << "Node for value '%" << Name << "' is collapsed: ";
-          N->print(std::cerr, &G);
+          llvm_cerr << "Node for value '%" << Name << "' is collapsed: ";
+          N->print(llvm_cerr, &G);
           abort();
         }
 
         if (CheckFlagsM.count(Name) && CheckFlagsM[Name] != N->getNodeFlags()) {
-          std::cerr << "Node flags are not as expected for node: " << Name 
+          llvm_cerr << "Node flags are not as expected for node: " << Name 
                     << " (" << CheckFlagsM[Name] << ":" <<N->getNodeFlags()
                     << ")\n";
-          N->print(std::cerr, &G);
+          N->print(llvm_cerr, &G);
           abort();
         }
 
         // Verify that it is not merged if it is not supposed to be...
         if (AbortIfMergedS.count(Name)) {
           if (AbortIfMergedNodes.count(N)) {
-            std::cerr << "Nodes for values '%" << Name << "' and '%"
+            llvm_cerr << "Nodes for values '%" << Name << "' and '%"
                       << AbortIfMergedNodes[N] << "' is merged: ";
-            N->print(std::cerr, &G);
+            N->print(llvm_cerr, &G);
             abort();
           }
           AbortIfMergedNodes[N] = Name;
index df0737ad6cef3f13ffa440ba0c8412632e5e8069..8c2b3fe2e789b4800fb5f88d265bf66bc69c4e01 100644 (file)
 #include "llvm/Bytecode/Reader.h"
 #include "llvm/Assembly/PrintModulePass.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Streams.h"
 #include "llvm/System/Signals.h"
+#include <iostream>
 #include <fstream>
 #include <memory>
-
 using namespace llvm;
 
 static cl::opt<std::string>
@@ -47,11 +48,11 @@ int main(int argc, char **argv) {
 
     std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename, &ErrorMessage));
     if (M.get() == 0) {
-      std::cerr << argv[0] << ": ";
+      llvm_cerr << argv[0] << ": ";
       if (ErrorMessage.size())
-        std::cerr << ErrorMessage << "\n";
+        llvm_cerr << ErrorMessage << "\n";
       else
-        std::cerr << "bytecode didn't read correctly.\n";
+        llvm_cerr << "bytecode didn't read correctly.\n";
       return 1;
     }
 
@@ -59,7 +60,7 @@ int main(int argc, char **argv) {
       if (OutputFilename != "-") { // Not stdout?
         if (!Force && std::ifstream(OutputFilename.c_str())) {
           // If force is not specified, make sure not to overwrite a file!
-          std::cerr << argv[0] << ": error opening '" << OutputFilename
+          llvm_cerr << argv[0] << ": error opening '" << OutputFilename
                     << "': file exists! Sending to standard output.\n";
         } else {
           Out = new std::ofstream(OutputFilename.c_str());
@@ -80,7 +81,7 @@ int main(int argc, char **argv) {
 
         if (!Force && std::ifstream(OutputFilename.c_str())) {
           // If force is not specified, make sure not to overwrite a file!
-          std::cerr << argv[0] << ": error opening '" << OutputFilename
+          llvm_cerr << argv[0] << ": error opening '" << OutputFilename
                     << "': file exists! Sending to standard output.\n";
         } else {
           Out = new std::ofstream(OutputFilename.c_str());
@@ -93,14 +94,15 @@ int main(int argc, char **argv) {
     }
 
     if (!Out->good()) {
-      std::cerr << argv[0] << ": error opening " << OutputFilename
+      llvm_cerr << argv[0] << ": error opening " << OutputFilename
                 << ": sending to stdout instead!\n";
       Out = &std::cout;
     }
 
     // All that llvm-dis does is write the assembly to a file.
     PassManager Passes;
-    Passes.add(new PrintModulePass(Out));
+    llvm_ostream L(*Out);
+    Passes.add(new PrintModulePass(&L));
     Passes.run(*M.get());
 
     if (Out != &std::cout) {
@@ -109,9 +111,9 @@ int main(int argc, char **argv) {
     }
     return 0;
   } catch (const std::string& msg) {
-    std::cerr << argv[0] << ": " << msg << "\n";
+    llvm_cerr << argv[0] << ": " << msg << "\n";
   } catch (...) {
-    std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
+    llvm_cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
   }
   return 1;
 }
index 5a6adcd9abcd84076daf79974d076308ac4f2de7..502118e65885707a94070a41737cd647b4d46986 100644 (file)
@@ -23,6 +23,7 @@
 #include "llvm/Support/PassNameParser.h"
 #include "llvm/System/Signals.h"
 #include "llvm/Support/PluginLoader.h"
+#include "llvm/Support/Streams.h"
 #include "llvm/Support/SystemUtils.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/LinkAllPasses.h"
@@ -84,9 +85,9 @@ struct ModulePassPrinter : public ModulePass {
 
   virtual bool runOnModule(Module &M) {
     if (!Quiet) {
-      std::cout << "Printing analysis '" << PassToPrint->getPassName() 
+      llvm_cout << "Printing analysis '" << PassToPrint->getPassName() 
                 << "':\n";
-      getAnalysisID<Pass>(PassToPrint).print(std::cout, &M);
+      getAnalysisID<Pass>(PassToPrint).print(llvm_cout, &M);
     }
 
     // Get and print pass...
@@ -107,11 +108,11 @@ struct FunctionPassPrinter : public FunctionPass {
 
   virtual bool runOnFunction(Function &F) {
     if (!Quiet) {
-      std::cout << "Printing analysis '" << PassToPrint->getPassName()
+      llvm_cout << "Printing analysis '" << PassToPrint->getPassName()
                << "' for function '" << F.getName() << "':\n";
     }
     // Get and print pass...
-    getAnalysisID<Pass>(PassToPrint).print(std::cout, F.getParent());
+    getAnalysisID<Pass>(PassToPrint).print(llvm_cout, F.getParent());
     return false;
   }
 
@@ -129,13 +130,13 @@ struct BasicBlockPassPrinter : public BasicBlockPass {
 
   virtual bool runOnBasicBlock(BasicBlock &BB) {
     if (!Quiet) {
-      std::cout << "Printing Analysis info for BasicBlock '" << BB.getName()
+      llvm_cout << "Printing Analysis info for BasicBlock '" << BB.getName()
                << "': Pass " << PassToPrint->getPassName() << ":\n";
     }
 
     // Get and print pass...
     getAnalysisID<Pass>(PassToPrint).print(
-      std::cout, BB.getParent()->getParent());
+      llvm_cout, BB.getParent()->getParent());
     return false;
   }
 
@@ -168,11 +169,11 @@ int main(int argc, char **argv) {
     // Load the input module...
     std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename, &ErrorMessage));
     if (M.get() == 0) {
-      std::cerr << argv[0] << ": ";
+      llvm_cerr << argv[0] << ": ";
       if (ErrorMessage.size())
-        std::cerr << ErrorMessage << "\n";
+        llvm_cerr << ErrorMessage << "\n";
       else
-        std::cerr << "bytecode didn't read correctly.\n";
+        llvm_cerr << "bytecode didn't read correctly.\n";
       return 1;
     }
 
@@ -182,7 +183,7 @@ int main(int argc, char **argv) {
     if (OutputFilename != "-") {
       if (!Force && std::ifstream(OutputFilename.c_str())) {
         // If force is not specified, make sure not to overwrite a file!
-        std::cerr << argv[0] << ": error opening '" << OutputFilename
+        llvm_cerr << argv[0] << ": error opening '" << OutputFilename
                   << "': file exists!\n"
                   << "Use -f command line argument to force output\n";
         return 1;
@@ -192,7 +193,7 @@ int main(int argc, char **argv) {
       Out = new std::ofstream(OutputFilename.c_str(), io_mode);
 
       if (!Out->good()) {
-        std::cerr << argv[0] << ": error opening " << OutputFilename << "!\n";
+        llvm_cerr << argv[0] << ": error opening " << OutputFilename << "!\n";
         return 1;
       }
 
@@ -226,7 +227,7 @@ int main(int argc, char **argv) {
         assert(target.get() && "Could not allocate target machine!");
         P = PassInf->getTargetCtor()(*target.get());
       } else
-        std::cerr << argv[0] << ": cannot create pass: "
+        llvm_cerr << argv[0] << ": cannot create pass: "
                   << PassInf->getPassName() << "\n";
       if (P) {
         Passes.add(P);
@@ -242,7 +243,7 @@ int main(int argc, char **argv) {
       }
       
       if (PrintEachXForm)
-        Passes.add(new PrintModulePass(&std::cerr));
+        Passes.add(new PrintModulePass(&llvm_cerr));
     }
 
     // Check that the module is well formed on completion of optimization
@@ -259,9 +260,9 @@ int main(int argc, char **argv) {
     return 0;
 
   } catch (const std::string& msg) {
-    std::cerr << argv[0] << ": " << msg << "\n";
+    llvm_cerr << argv[0] << ": " << msg << "\n";
   } catch (...) {
-    std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
+    llvm_cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
   }
   return 1;
 }