[llvm-commits] CVS: llvm/tools/llvm2cpp/Makefile llvm2cpp.cpp
Chris Lattner
sabre at nondot.org
Sat May 5 22:22:02 PDT 2007
Changes in directory llvm/tools/llvm2cpp:
Makefile updated: 1.9 -> 1.10
llvm2cpp.cpp updated: 1.7 -> 1.8
---
Log message:
bitcodify, remove eh cruft
---
Diffs of the changes: (+19 -6)
Makefile | 3 +--
llvm2cpp.cpp | 22 ++++++++++++++++++----
2 files changed, 19 insertions(+), 6 deletions(-)
Index: llvm/tools/llvm2cpp/Makefile
diff -u llvm/tools/llvm2cpp/Makefile:1.9 llvm/tools/llvm2cpp/Makefile:1.10
--- llvm/tools/llvm2cpp/Makefile:1.9 Thu Nov 2 18:05:16 2006
+++ llvm/tools/llvm2cpp/Makefile Sun May 6 00:21:42 2007
@@ -8,8 +8,7 @@
##===----------------------------------------------------------------------===##
LEVEL = ../..
TOOLNAME = llvm2cpp
-LINK_COMPONENTS = bcreader
-REQUIRES_EH := 1
+LINK_COMPONENTS = bcreader bitreader
include $(LEVEL)/Makefile.common
Index: llvm/tools/llvm2cpp/llvm2cpp.cpp
diff -u llvm/tools/llvm2cpp/llvm2cpp.cpp:1.7 llvm/tools/llvm2cpp/llvm2cpp.cpp:1.8
--- llvm/tools/llvm2cpp/llvm2cpp.cpp:1.7 Wed Feb 7 15:41:02 2007
+++ llvm/tools/llvm2cpp/llvm2cpp.cpp Sun May 6 00:21:42 2007
@@ -17,19 +17,22 @@
//===------------------------------------------------------------------------===
#include "llvm/Module.h"
+#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Bytecode/Reader.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;
+cl::opt<bool> Bitcode("bitcode");
+
static cl::opt<std::string>
InputFilename(cl::Positional, cl::desc("<input LLVM bytecode file>"),
cl::init("-"));
@@ -49,9 +52,20 @@
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;
+ if (Bitcode) {
+ std::auto_ptr<MemoryBuffer> Buffer(
+ MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()));
+ if (Buffer.get())
+ M.reset(ParseBitcodeFile(Buffer.get(), &ErrorMessage));
+ else
+ ErrorMessage = "Error reading file '" + InputFilename + "'";
+ } else {
+ M.reset(ParseBytecodeFile(InputFilename,
+ Compressor::decompressToNewBuffer,
+ &ErrorMessage));
+ }
if (M.get() == 0) {
std::cerr << argv[0] << ": ";
if (ErrorMessage.size())
More information about the llvm-commits
mailing list