[llvm-commits] CVS: llvm/tools/gccld/GenerateCode.cpp gccld.cpp

Bill Wendling isanbard at gmail.com
Tue Nov 28 16:20:27 PST 2006



Changes in directory llvm/tools/gccld:

GenerateCode.cpp updated: 1.65 -> 1.66
gccld.cpp updated: 1.111 -> 1.112
---
Log message:

Replacing std::iostreams with llvm iostreams. Some of these changes involve
adding a temporary wrapper around the ostream to make it friendly to
functions expecting an LLVM stream. This should be fixed in the future.


---
Diffs of the changes:  (+24 -22)

 GenerateCode.cpp |   11 ++++++-----
 gccld.cpp        |   35 ++++++++++++++++++-----------------
 2 files changed, 24 insertions(+), 22 deletions(-)


Index: llvm/tools/gccld/GenerateCode.cpp
diff -u llvm/tools/gccld/GenerateCode.cpp:1.65 llvm/tools/gccld/GenerateCode.cpp:1.66
--- llvm/tools/gccld/GenerateCode.cpp:1.65	Wed Nov 22 17:49:16 2006
+++ llvm/tools/gccld/GenerateCode.cpp	Tue Nov 28 18:19:40 2006
@@ -27,7 +27,7 @@
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Support/SystemUtils.h"
 #include "llvm/Support/CommandLine.h"
-
+#include "llvm/Support/Streams.h"
 using namespace llvm;
 
 namespace {
@@ -123,10 +123,10 @@
 }
 
 static void dumpArgs(const char **args) {
-  std::cerr << *args++;
+  llvm_cerr << *args++;
   while (*args)
-    std::cerr << ' ' << *args++;
-  std::cerr << '\n' << std::flush;
+    llvm_cerr << ' ' << *args++;
+  llvm_cerr << '\n' << std::flush;
 }
 
 static inline void addPass(PassManager &PM, Pass *P) {
@@ -283,7 +283,8 @@
   Passes.add(createVerifierPass());
 
   // Add the pass that writes bytecode to the output file...
-  addPass(Passes, new WriteBytecodePass(Out, false, !NoCompress));
+  llvm_ostream L(*Out);
+  addPass(Passes, new WriteBytecodePass(&L, false, !NoCompress));
 
   // Run our queue of passes all at once now, efficiently.
   Passes.run(*M);


Index: llvm/tools/gccld/gccld.cpp
diff -u llvm/tools/gccld/gccld.cpp:1.111 llvm/tools/gccld/gccld.cpp:1.112
--- llvm/tools/gccld/gccld.cpp:1.111	Fri Sep  1 15:35:17 2006
+++ llvm/tools/gccld/gccld.cpp	Tue Nov 28 18:19:40 2006
@@ -31,6 +31,7 @@
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileUtilities.h"
+#include "llvm/Support/Streams.h"
 #include "llvm/System/Signals.h"
 #include "llvm/Support/SystemUtils.h"
 #include <fstream>
@@ -126,7 +127,7 @@
 ///  Message  - The message to print to standard error.
 ///
 static int PrintAndReturn(const char *progname, const std::string &Message) {
-  std::cerr << progname << ": " << Message << "\n";
+  llvm_cerr << progname << ": " << Message << "\n";
   return 1;
 }
 
@@ -140,11 +141,11 @@
   std::string ErrMsg;  
   sys::Path llvmstub = FindExecutable("llvm-stub.exe", argv[0]);
   if (llvmstub.isEmpty()) {
-    std::cerr << "Could not find llvm-stub.exe executable!\n";
+    llvm_cerr << "Could not find llvm-stub.exe executable!\n";
     exit(1);
   }
   if (0 != sys::CopyFile(sys::Path(OutputFilename), llvmstub, &ErrMsg)) {
-    std::cerr << argv[0] << ": " << ErrMsg << "\n";
+    llvm_cerr << argv[0] << ": " << ErrMsg << "\n";
     exit(1);    
   }
 
@@ -324,18 +325,18 @@
         return PrintAndReturn(argv[0], "Failed to find gcc");
 
       // Generate an assembly language file for the bytecode.
-      if (Verbose) std::cout << "Generating Assembly Code\n";
+      if (Verbose) llvm_cout << "Generating Assembly Code\n";
       std::string ErrMsg;
       if (0 != GenerateAssembly(
           AssemblyFile.toString(), RealBytecodeOutput, llc, ErrMsg, Verbose)) {
-        std::cerr << argv[0] << ": " << ErrMsg << "\n";
+        llvm_cerr << argv[0] << ": " << ErrMsg << "\n";
         return 2;
       }
-      if (Verbose) std::cout << "Generating Native Code\n";
+      if (Verbose) llvm_cout << "Generating Native Code\n";
       if (0 != GenerateNative(OutputFilename, AssemblyFile.toString(),
                      LibPaths, Libraries, gcc, envp, LinkAsLibrary,
                      NoInternalize, RPath, SOName, ErrMsg, Verbose) ) {
-        std::cerr << argv[0] << ": " << ErrMsg << "\n";
+        llvm_cerr << argv[0] << ": " << ErrMsg << "\n";
         return 2;
       }
 
@@ -364,18 +365,18 @@
         return PrintAndReturn(argv[0], "Failed to find gcc");
 
       // Generate an assembly language file for the bytecode.
-      if (Verbose) std::cout << "Generating C Source Code\n";
+      if (Verbose) llvm_cout << "Generating C Source Code\n";
       std::string ErrMsg;
       if (0 != GenerateCFile(
           CFile.toString(), RealBytecodeOutput, llc, ErrMsg, Verbose)) {
-        std::cerr << argv[0] << ": " << ErrMsg << "\n";
+        llvm_cerr << argv[0] << ": " << ErrMsg << "\n";
         return 2;
       }
-      if (Verbose) std::cout << "Generating Native Code\n";
+      if (Verbose) llvm_cout << "Generating Native Code\n";
       if (0 != GenerateNative(OutputFilename, CFile.toString(),
                      LibPaths, Libraries, gcc, envp, LinkAsLibrary,
                      NoInternalize, RPath, SOName, ErrMsg, Verbose)) {
-        std::cerr << argv[0] << ": " << ErrMsg << "\n";
+        llvm_cerr << argv[0] << ": " << ErrMsg << "\n";
         return 2;
       }
 
@@ -392,11 +393,11 @@
       // Make the bytecode file readable and directly executable in LLEE
       std::string ErrMsg;
       if (sys::Path(RealBytecodeOutput).makeExecutableOnDisk(&ErrMsg)) {
-        std::cerr << argv[0] << ": " << ErrMsg << "\n";
+        llvm_cerr << argv[0] << ": " << ErrMsg << "\n";
         return 1;
       }
       if (sys::Path(RealBytecodeOutput).makeReadableOnDisk(&ErrMsg)) {
-        std::cerr << argv[0] << ": " << ErrMsg << "\n";
+        llvm_cerr << argv[0] << ": " << ErrMsg << "\n";
         return 1;
       }
     }
@@ -404,18 +405,18 @@
     // Make the output, whether native or script, executable as well...
     std::string ErrMsg;
     if (sys::Path(OutputFilename).makeExecutableOnDisk(&ErrMsg)) {
-      std::cerr << argv[0] << ": " << ErrMsg << "\n";
+      llvm_cerr << argv[0] << ": " << ErrMsg << "\n";
       return 1;
     }
   } catch (const char*msg) {
-    std::cerr << argv[0] << ": " << msg << "\n";
+    llvm_cerr << argv[0] << ": " << msg << "\n";
     exitCode = 1;
   } catch (const std::string& msg) {
-    std::cerr << argv[0] << ": " << msg << "\n";
+    llvm_cerr << argv[0] << ": " << msg << "\n";
     exitCode = 2;
   } catch (...) {
     // This really shouldn't happen, but just in case ....
-    std::cerr << argv[0] << ": An unexpected unknown exception occurred.\n";
+    llvm_cerr << argv[0] << ": An unexpected unknown exception occurred.\n";
     exitCode = 3;
   }
 






More information about the llvm-commits mailing list