Adding ocaml language bindings for the vmcore and bitwriter libraries. These are
[oota-llvm.git] / tools / llvm2cpp / llvm2cpp.cpp
index fe9504e5673757a92e44051e9af2b4eb7a3dd54f..2db7543f4817b960936c2377cdc7d58577242b08 100644 (file)
 //===------------------------------------------------------------------------===
 
 #include "llvm/Module.h"
-#include "llvm/Bytecode/Reader.h"
+#include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm/Analysis/Verifier.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/SystemUtils.h"
 #include "llvm/System/Signals.h"
 #include "CppWriter.h"
 #include <fstream>
 #include <iostream>
 #include <memory>
-
 using namespace llvm;
 
 static cl::opt<std::string>
-InputFilename(cl::Positional, cl::desc("<input LLVM bytecode file>"), 
+InputFilename(cl::Positional, cl::desc("<input LLVM bitcode file>"), 
   cl::init("-"));
 
 static cl::opt<std::string>
@@ -49,15 +49,18 @@ int main(int argc, char **argv) {
   int exitCode = 0;
   std::ostream *Out = 0;
   std::string ErrorMessage;
-  std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename, 
-                                            Compressor::decompressToNewBuffer, 
-                                            &ErrorMessage));
+  
+  std::auto_ptr<Module> M;
+  std::auto_ptr<MemoryBuffer> Buffer(
+       MemoryBuffer::getFileOrSTDIN(InputFilename, &ErrorMessage));
+  if (Buffer.get())
+    M.reset(ParseBitcodeFile(Buffer.get(), &ErrorMessage));
   if (M.get() == 0) {
     std::cerr << argv[0] << ": ";
     if (ErrorMessage.size())
       std::cerr << ErrorMessage << "\n";
     else
-      std::cerr << "bytecode didn't read correctly.\n";
+      std::cerr << "bitcode didn't read correctly.\n";
     return 1;
   }