OLD | NEW |
1 /* Copyright 2013 The Native Client Authors. All rights reserved. | 1 /* Copyright 2013 The Native Client Authors. All rights reserved. |
2 * Use of this source code is governed by a BSD-style license that can | 2 * Use of this source code is governed by a BSD-style license that can |
3 * be found in the LICENSE file. | 3 * be found in the LICENSE file. |
4 */ | 4 */ |
5 | 5 |
6 //===-- pnacl-freeze.cpp - The low-level NaCl bitcode freezer --------===// | 6 //===-- pnacl-freeze.cpp - The low-level NaCl bitcode freezer --------===// |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // Generates NaCl pexe wire format. | 10 // Generates NaCl pexe wire format. |
11 // | 11 // |
12 //===----------------------------------------------------------------------===// | 12 //===----------------------------------------------------------------------===// |
13 | 13 |
14 #include "llvm/Bitcode/NaCl/NaClReaderWriter.h" | 14 #include "llvm/Bitcode/NaCl/NaClReaderWriter.h" |
15 #include "llvm/Bitcode/ReaderWriter.h" | 15 #include "llvm/Bitcode/ReaderWriter.h" |
16 #include "llvm/IR/LLVMContext.h" | 16 #include "llvm/IR/LLVMContext.h" |
17 #include "llvm/IR/Module.h" | 17 #include "llvm/IR/Module.h" |
18 #include "llvm/Support/CommandLine.h" | 18 #include "llvm/Support/CommandLine.h" |
19 #include "llvm/Support/DataStream.h" | 19 #include "llvm/Support/DataStream.h" |
20 #include "llvm/Support/FileSystem.h" | 20 #include "llvm/Support/FileSystem.h" |
21 #include "llvm/Support/ManagedStatic.h" | 21 #include "llvm/Support/ManagedStatic.h" |
22 #include "llvm/Support/PrettyStackTrace.h" | 22 #include "llvm/Support/PrettyStackTrace.h" |
23 #include "llvm/Support/Signals.h" | 23 #include "llvm/Support/Signals.h" |
24 #include "llvm/Support/StreamableMemoryObject.h" | 24 #include "llvm/Support/StreamingMemoryObject.h" |
25 #include "llvm/Support/ToolOutputFile.h" | 25 #include "llvm/Support/ToolOutputFile.h" |
26 | 26 |
27 using namespace llvm; | 27 using namespace llvm; |
28 | 28 |
29 | 29 |
30 static cl::opt<std::string> | 30 static cl::opt<std::string> |
31 OutputFilename("o", cl::desc("Specify output filename"), | 31 OutputFilename("o", cl::desc("Specify output filename"), |
32 cl::value_desc("filename"), cl::init("-")); | 32 cl::value_desc("filename"), cl::init("-")); |
33 | 33 |
34 static cl::opt<std::string> | 34 static cl::opt<std::string> |
35 InputFilename(cl::Positional, cl::desc("<pexe file>"), cl::init("-")); | 35 InputFilename(cl::Positional, cl::desc("<pexe file>"), cl::init("-")); |
36 | 36 |
37 static void WriteOutputFile(const Module *M) { | 37 static void WriteOutputFile(const Module *M) { |
38 | 38 |
39 std::string ErrorInfo; | 39 std::error_code EC; |
40 std::unique_ptr<tool_output_file> Out( | 40 std::unique_ptr<tool_output_file> Out( |
41 new tool_output_file(OutputFilename.c_str(), ErrorInfo, sys::fs::F_None)); | 41 new tool_output_file(OutputFilename, EC, sys::fs::F_None)); |
42 if (!ErrorInfo.empty()) { | 42 if (EC) { |
43 errs() << ErrorInfo << '\n'; | 43 errs() << EC.message() << '\n'; |
44 exit(1); | 44 exit(1); |
45 } | 45 } |
46 | 46 |
47 NaClWriteBitcodeToFile(M, Out->os(), /* AcceptSupportedOnly = */ false); | 47 NaClWriteBitcodeToFile(M, Out->os(), /* AcceptSupportedOnly = */ false); |
48 | 48 |
49 // Declare success. | 49 // Declare success. |
50 Out->keep(); | 50 Out->keep(); |
51 } | 51 } |
52 | 52 |
53 int main(int argc, char **argv) { | 53 int main(int argc, char **argv) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 if (ErrorMessage.size()) | 87 if (ErrorMessage.size()) |
88 errs() << ErrorMessage << "\n"; | 88 errs() << ErrorMessage << "\n"; |
89 else | 89 else |
90 errs() << "bitcode didn't read correctly.\n"; | 90 errs() << "bitcode didn't read correctly.\n"; |
91 return 1; | 91 return 1; |
92 } | 92 } |
93 | 93 |
94 WriteOutputFile(M.get()); | 94 WriteOutputFile(M.get()); |
95 return 0; | 95 return 0; |
96 } | 96 } |
OLD | NEW |