Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: tools/pnacl-thaw/pnacl-thaw.cpp

Issue 940243003: PNaCl localmod mods in LLVM to 223109 (local files only) (Closed)
Patch Set: xx Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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-thaw.cpp - The low-level NaCl bitcode thawer ----------------===// 6 //===-- pnacl-thaw.cpp - The low-level NaCl bitcode thawer ----------------===//
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // Converts NaCl wire format back to LLVM bitcode. 10 // Converts NaCl wire format back to LLVM bitcode.
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 static cl::opt<std::string> 29 static cl::opt<std::string>
30 OutputFilename("o", cl::desc("Specify thawed pexe filename"), 30 OutputFilename("o", cl::desc("Specify thawed pexe filename"),
31 cl::value_desc("filename"), cl::init("-")); 31 cl::value_desc("filename"), cl::init("-"));
32 32
33 static cl::opt<std::string> 33 static cl::opt<std::string>
34 InputFilename(cl::Positional, cl::desc("<frozen file>"), cl::init("-")); 34 InputFilename(cl::Positional, cl::desc("<frozen file>"), cl::init("-"));
35 35
36 static cl::opt<bool> 36 static cl::opt<bool>
37 VerboseErrors( 37 VerboseErrors(
38 "verbose-parse-errors", 38 "verbose-parse-errors",
39 cl::desc("Print out more descriptive PNaCl bitcode parse errors"), 39 cl::desc("Print out more descriptive PNaCl bitcode parse errors"),
40 cl::init(false)); 40 cl::init(false));
41 41
42 static void WriteOutputFile(const Module *M) { 42 static void WriteOutputFile(const Module *M) {
43 43
44 std::string ErrorInfo; 44 std::error_code EC;
45 std::unique_ptr<tool_output_file> Out( 45 std::unique_ptr<tool_output_file> Out(
46 new tool_output_file(OutputFilename.c_str(), ErrorInfo, sys::fs::F_None)); 46 new tool_output_file(OutputFilename, EC, sys::fs::F_None));
47 if (!ErrorInfo.empty()) { 47 if (EC) {
48 errs() << ErrorInfo << '\n'; 48 errs() << EC.message() << '\n';
49 exit(1); 49 exit(1);
50 } 50 }
51 51
52 WriteBitcodeToFile(M, Out->os()); 52 WriteBitcodeToFile(M, Out->os());
53 53
54 // Declare success. 54 // Declare success.
55 Out->keep(); 55 Out->keep();
56 } 56 }
57 57
58 int main(int argc, char **argv) { 58 int main(int argc, char **argv) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 if (ErrorMessage.size()) 96 if (ErrorMessage.size())
97 errs() << ErrorMessage << "\n"; 97 errs() << ErrorMessage << "\n";
98 else 98 else
99 errs() << "bitcode didn't read correctly.\n"; 99 errs() << "bitcode didn't read correctly.\n";
100 return 1; 100 return 1;
101 } 101 }
102 102
103 WriteOutputFile(M.get()); 103 WriteOutputFile(M.get());
104 return 0; 104 return 0;
105 } 105 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698