| OLD | NEW |
| 1 //===-- pnacl-bcdis.cpp - Disassemble pnacl bitcode -----------------------===// | 1 //===-- pnacl-bcdis.cpp - Disassemble pnacl bitcode -----------------------===// |
| 2 // | 2 // |
| 3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 | 9 |
| 10 /// TODO(kschimpf): Add disassembling abbreviations. | 10 /// TODO(kschimpf): Add disassembling abbreviations. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 // Open the bitcode file and put into a buffer. | 49 // Open the bitcode file and put into a buffer. |
| 50 ErrorOr<std::unique_ptr<MemoryBuffer>> ErrOrFile = | 50 ErrorOr<std::unique_ptr<MemoryBuffer>> ErrOrFile = |
| 51 MemoryBuffer::getFileOrSTDIN(InputFilename); | 51 MemoryBuffer::getFileOrSTDIN(InputFilename); |
| 52 if (std::error_code EC = ErrOrFile.getError()) { | 52 if (std::error_code EC = ErrOrFile.getError()) { |
| 53 errs() << "Error reading '" << InputFilename << "': " << EC.message() | 53 errs() << "Error reading '" << InputFilename << "': " << EC.message() |
| 54 << "\n"; | 54 << "\n"; |
| 55 return true; | 55 return true; |
| 56 } | 56 } |
| 57 | 57 |
| 58 // Create a stream to output the bitcode text to. | 58 // Create a stream to output the bitcode text to. |
| 59 std::string ErrorInfo; | 59 std::error_code EC; |
| 60 raw_fd_ostream Output(OutputFilename.c_str(), ErrorInfo, sys::fs::F_None); | 60 raw_fd_ostream Output(OutputFilename, EC, sys::fs::F_None); |
| 61 if (!ErrorInfo.empty()) { | 61 if (EC) { |
| 62 errs() << ErrorInfo << '\n'; | 62 errs() << EC.message() << '\n'; |
| 63 return true; | 63 return true; |
| 64 } | 64 } |
| 65 | 65 |
| 66 // Parse the the bitcode file. | 66 // Parse the the bitcode file. |
| 67 return NaClObjDump(ErrOrFile.get().release(), Output, NoRecords, NoAssembly); | 67 return NaClObjDump(ErrOrFile.get().release(), Output, NoRecords, NoAssembly); |
| 68 } | 68 } |
| 69 | 69 |
| 70 } | 70 } |
| 71 | 71 |
| 72 int main(int argc, char **argv) { | 72 int main(int argc, char **argv) { |
| 73 // Print a stack trace if we signal out. | 73 // Print a stack trace if we signal out. |
| 74 sys::PrintStackTraceOnErrorSignal(); | 74 sys::PrintStackTraceOnErrorSignal(); |
| 75 PrettyStackTraceProgram X(argc, argv); | 75 PrettyStackTraceProgram X(argc, argv); |
| 76 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. | 76 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. |
| 77 cl::ParseCommandLineOptions(argc, argv, "pnacl-bccompress file analyzer\n"); | 77 cl::ParseCommandLineOptions(argc, argv, "pnacl-bccompress file analyzer\n"); |
| 78 | 78 |
| 79 if (DisassembleBitcode()) return 1; | 79 if (DisassembleBitcode()) return 1; |
| 80 return 0; | 80 return 0; |
| 81 } | 81 } |
| OLD | NEW |