[llvm-commits] [llvm] r120341 - in /llvm/trunk/tools: llvm-ar/llvm-ar.cpp llvm-ranlib/llvm-ranlib.cpp

Chris Lattner sabre at nondot.org
Mon Nov 29 15:02:20 PST 2010


Author: lattner
Date: Mon Nov 29 17:02:20 2010
New Revision: 120341

URL: http://llvm.org/viewvc/llvm-project?rev=120341&view=rev
Log:
convert llvm-ar and llvm-ranlib to raw_ostream from iostreams.
Patch by Danil Malyshev!


Modified:
    llvm/trunk/tools/llvm-ar/llvm-ar.cpp
    llvm/trunk/tools/llvm-ranlib/llvm-ranlib.cpp

Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=120341&r1=120340&r2=120341&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Mon Nov 29 17:02:20 2010
@@ -18,11 +18,10 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Format.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Signals.h"
-#include <iostream>
 #include <algorithm>
-#include <iomanip>
 #include <memory>
 #include <fstream>
 using namespace llvm;
@@ -335,12 +334,12 @@
 
 // printSymbolTable - print out the archive's symbol table.
 void printSymbolTable() {
-  std::cout << "\nArchive Symbol Table:\n";
+  outs() << "\nArchive Symbol Table:\n";
   const Archive::SymTabType& symtab = TheArchive->getSymbolTable();
   for (Archive::SymTabType::const_iterator I=symtab.begin(), E=symtab.end();
        I != E; ++I ) {
     unsigned offset = TheArchive->getFirstFileOffset() + I->second;
-    std::cout << " " << std::setw(9) << offset << "\t" << I->first <<"\n";
+    outs() << " " << format("%9u", offset) << "\t" << I->first <<"\n";
   }
 }
 
@@ -365,10 +364,10 @@
           continue;
 
         if (Verbose)
-          std::cout << "Printing " << I->getPath().str() << "\n";
+          outs() << "Printing " << I->getPath().str() << "\n";
 
         unsigned len = I->getSize();
-        std::cout.write(data, len);
+        outs().write(data, len);
       } else {
         countDown--;
       }
@@ -382,17 +381,17 @@
 void 
 printMode(unsigned mode) {
   if (mode & 004)
-    std::cout << "r";
+    outs() << "r";
   else
-    std::cout << "-";
+    outs() << "-";
   if (mode & 002)
-    std::cout << "w";
+    outs() << "w";
   else
-    std::cout << "-";
+    outs() << "-";
   if (mode & 001)
-    std::cout << "x";
+    outs() << "x";
   else
-    std::cout << "-";
+    outs() << "-";
 }
 
 // doDisplayTable - Implement the 't' operation. This function prints out just
@@ -411,22 +410,22 @@
         // FIXME: Output should be this format:
         // Zrw-r--r--  500/ 500    525 Nov  8 17:42 2004 Makefile
         if (I->isBitcode())
-          std::cout << "b";
+          outs() << "b";
         else if (I->isCompressed())
-          std::cout << "Z";
+          outs() << "Z";
         else
-          std::cout << " ";
+          outs() << " ";
         unsigned mode = I->getMode();
         printMode((mode >> 6) & 007);
         printMode((mode >> 3) & 007);
         printMode(mode & 007);
-        std::cout << " " << std::setw(4) << I->getUser();
-        std::cout << "/" << std::setw(4) << I->getGroup();
-        std::cout << " " << std::setw(8) << I->getSize();
-        std::cout << " " << std::setw(20) << I->getModTime().str().substr(4);
-        std::cout << " " << I->getPath().str() << "\n";
+        outs() << " " << format("%4u", I->getUser());
+        outs() << "/" << format("%4u", I->getGroup());
+        outs() << " " << format("%8u", I->getSize());
+        outs() << " " << format("%20s", I->getModTime().str().substr(4).c_str());
+        outs() << " " << I->getPath().str() << "\n";
       } else {
-        std::cout << I->getPath().str() << "\n";
+        outs() << I->getPath().str() << "\n";
       }
     }
   }

Modified: llvm/trunk/tools/llvm-ranlib/llvm-ranlib.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ranlib/llvm-ranlib.cpp?rev=120341&r1=120340&r2=120341&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ranlib/llvm-ranlib.cpp (original)
+++ llvm/trunk/tools/llvm-ranlib/llvm-ranlib.cpp Mon Nov 29 17:02:20 2010
@@ -17,12 +17,10 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Format.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Signals.h"
-#include <iostream>
-#include <iomanip>
 #include <memory>
-
 using namespace llvm;
 
 // llvm-ar operation code and modifier flags
@@ -35,12 +33,12 @@
 
 // printSymbolTable - print out the archive's symbol table.
 void printSymbolTable(Archive* TheArchive) {
-  std::cout << "\nArchive Symbol Table:\n";
+  outs() << "\nArchive Symbol Table:\n";
   const Archive::SymTabType& symtab = TheArchive->getSymbolTable();
   for (Archive::SymTabType::const_iterator I=symtab.begin(), E=symtab.end();
        I != E; ++I ) {
     unsigned offset = TheArchive->getFirstFileOffset() + I->second;
-    std::cout << " " << std::setw(9) << offset << "\t" << I->first <<"\n";
+    outs() << " " << format("%9u", offset) << "\t" << I->first <<"\n";
   }
 }
 





More information about the llvm-commits mailing list