forked from OSchip/llvm-project
parent
b94d80b6fb
commit
99016c3f2d
|
@ -8,8 +8,7 @@
|
||||||
##===----------------------------------------------------------------------===##
|
##===----------------------------------------------------------------------===##
|
||||||
LEVEL = ../..
|
LEVEL = ../..
|
||||||
TOOLNAME = llvm2cpp
|
TOOLNAME = llvm2cpp
|
||||||
LINK_COMPONENTS = bcreader
|
LINK_COMPONENTS = bcreader bitreader
|
||||||
REQUIRES_EH := 1
|
|
||||||
|
|
||||||
include $(LEVEL)/Makefile.common
|
include $(LEVEL)/Makefile.common
|
||||||
|
|
||||||
|
|
|
@ -17,19 +17,22 @@
|
||||||
//===------------------------------------------------------------------------===
|
//===------------------------------------------------------------------------===
|
||||||
|
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
|
#include "llvm/Bitcode/ReaderWriter.h"
|
||||||
#include "llvm/Bytecode/Reader.h"
|
#include "llvm/Bytecode/Reader.h"
|
||||||
#include "llvm/Analysis/Verifier.h"
|
#include "llvm/Analysis/Verifier.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/ManagedStatic.h"
|
#include "llvm/Support/ManagedStatic.h"
|
||||||
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include "llvm/Support/SystemUtils.h"
|
#include "llvm/Support/SystemUtils.h"
|
||||||
#include "llvm/System/Signals.h"
|
#include "llvm/System/Signals.h"
|
||||||
#include "CppWriter.h"
|
#include "CppWriter.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
|
cl::opt<bool> Bitcode("bitcode");
|
||||||
|
|
||||||
static cl::opt<std::string>
|
static cl::opt<std::string>
|
||||||
InputFilename(cl::Positional, cl::desc("<input LLVM bytecode file>"),
|
InputFilename(cl::Positional, cl::desc("<input LLVM bytecode file>"),
|
||||||
cl::init("-"));
|
cl::init("-"));
|
||||||
|
@ -49,9 +52,20 @@ int main(int argc, char **argv) {
|
||||||
int exitCode = 0;
|
int exitCode = 0;
|
||||||
std::ostream *Out = 0;
|
std::ostream *Out = 0;
|
||||||
std::string ErrorMessage;
|
std::string ErrorMessage;
|
||||||
std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename,
|
|
||||||
|
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,
|
Compressor::decompressToNewBuffer,
|
||||||
&ErrorMessage));
|
&ErrorMessage));
|
||||||
|
}
|
||||||
if (M.get() == 0) {
|
if (M.get() == 0) {
|
||||||
std::cerr << argv[0] << ": ";
|
std::cerr << argv[0] << ": ";
|
||||||
if (ErrorMessage.size())
|
if (ErrorMessage.size())
|
||||||
|
|
Loading…
Reference in New Issue