OLD | NEW |
---|---|
1 //===-- llvm-dis.cpp - The low-level LLVM disassembler --------------------===// | 1 //===-- llvm-dis.cpp - The low-level LLVM disassembler --------------------===// |
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 // This utility may be invoked in the following manner: | 10 // This utility may be invoked in the following manner: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 // @LOCALMOD-BEGIN | 58 // @LOCALMOD-BEGIN |
59 static cl::opt<NaClFileFormat> | 59 static cl::opt<NaClFileFormat> |
60 InputFileFormat( | 60 InputFileFormat( |
61 "bitcode-format", | 61 "bitcode-format", |
62 cl::desc("Define format of input bitcode file:"), | 62 cl::desc("Define format of input bitcode file:"), |
63 cl::values( | 63 cl::values( |
64 clEnumValN(LLVMFormat, "llvm", "LLVM bitcode file (default)"), | 64 clEnumValN(LLVMFormat, "llvm", "LLVM bitcode file (default)"), |
65 clEnumValN(PNaClFormat, "pnacl", "PNaCl bitcode file"), | 65 clEnumValN(PNaClFormat, "pnacl", "PNaCl bitcode file"), |
66 clEnumValEnd), | 66 clEnumValEnd), |
67 cl::init(LLVMFormat)); | 67 cl::init(LLVMFormat)); |
68 | |
69 static cl::opt<bool> | |
70 VerboseErrors( | |
71 "verbose-parse-errors", | |
72 cl::desc("Print out more descriptive PNaCl bitcode parse errors"), | |
73 cl::init(false)); | |
68 // @LOCALMOD-END | 74 // @LOCALMOD-END |
69 | 75 |
70 namespace { | 76 namespace { |
71 | 77 |
72 static void printDebugLoc(const DebugLoc &DL, formatted_raw_ostream &OS) { | 78 static void printDebugLoc(const DebugLoc &DL, formatted_raw_ostream &OS) { |
73 OS << DL.getLine() << ":" << DL.getCol(); | 79 OS << DL.getLine() << ":" << DL.getCol(); |
74 if (MDNode *N = DL.getInlinedAt(getGlobalContext())) { | 80 if (MDNode *N = DL.getInlinedAt(getGlobalContext())) { |
75 DebugLoc IDL = DebugLoc::getFromDILocation(N); | 81 DebugLoc IDL = DebugLoc::getFromDILocation(N); |
76 if (!IDL.isUnknown()) { | 82 if (!IDL.isUnknown()) { |
77 OS << "@"; | 83 OS << "@"; |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 DisplayFilename = InputFilename; | 159 DisplayFilename = InputFilename; |
154 | 160 |
155 // @LOCALMOD-BEGIN | 161 // @LOCALMOD-BEGIN |
156 switch (InputFileFormat) { | 162 switch (InputFileFormat) { |
157 case LLVMFormat: | 163 case LLVMFormat: |
158 // The Module's BitcodeReader's BitstreamReader takes ownership | 164 // The Module's BitcodeReader's BitstreamReader takes ownership |
159 // of the StreamingMemoryObject. | 165 // of the StreamingMemoryObject. |
160 M.reset(getStreamedBitcodeModule( | 166 M.reset(getStreamedBitcodeModule( |
161 DisplayFilename, Buffer.release(), Context, &ErrorMessage)); | 167 DisplayFilename, Buffer.release(), Context, &ErrorMessage)); |
162 break; | 168 break; |
163 case PNaClFormat: | 169 case PNaClFormat: { |
170 raw_ostream *Verbose = VerboseErrors ? &errs() : nullptr; | |
jvoung (off chromium)
2014/12/03 19:43:46
I guess I was okay with this unconditionally havin
Karl
2014/12/03 20:53:44
Since this is an LLVM tool, I guess we should be j
| |
164 M.reset(getNaClStreamedBitcodeModule( | 171 M.reset(getNaClStreamedBitcodeModule( |
165 DisplayFilename, Buffer.release(), Context, &ErrorMessage)); | 172 DisplayFilename, Buffer.release(), Context, Verbose, |
173 &ErrorMessage)); | |
166 break; | 174 break; |
175 } | |
167 default: | 176 default: |
168 ErrorMessage = "Don't understand specified bitcode format"; | 177 ErrorMessage = "Don't understand specified bitcode format"; |
169 break; | 178 break; |
170 } | 179 } |
171 // @LOCALMOD-END | 180 // @LOCALMOD-END |
172 | 181 |
173 if(M.get()) { | 182 if(M.get()) { |
174 if (std::error_code EC = M->materializeAllPermanently()) { | 183 if (std::error_code EC = M->materializeAllPermanently()) { |
175 ErrorMessage = EC.message(); | 184 ErrorMessage = EC.message(); |
176 M.reset(); | 185 M.reset(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 | 228 |
220 // All that llvm-dis does is write the assembly to a file. | 229 // All that llvm-dis does is write the assembly to a file. |
221 if (!DontPrint) | 230 if (!DontPrint) |
222 M->print(Out->os(), Annotator.get()); | 231 M->print(Out->os(), Annotator.get()); |
223 | 232 |
224 // Declare success. | 233 // Declare success. |
225 Out->keep(); | 234 Out->keep(); |
226 | 235 |
227 return 0; | 236 return 0; |
228 } | 237 } |
OLD | NEW |