OLD | NEW |
---|---|
1 //===-- llvm-nm.cpp - Symbol table dumping utility for llvm ---------------===// | 1 //===-- llvm-nm.cpp - Symbol table dumping utility for llvm ---------------===// |
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 program is a utility that works like traditional Unix "nm", that is, it | 10 // This program is a utility that works like traditional Unix "nm", that is, it |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
159 | 159 |
160 std::string ToolName; | 160 std::string ToolName; |
161 | 161 |
162 // @LOCALMOD-BEGIN | 162 // @LOCALMOD-BEGIN |
163 cl::opt<NaClFileFormat> InputFileFormat( | 163 cl::opt<NaClFileFormat> InputFileFormat( |
164 "bitcode-format", cl::desc("Define format of input file:"), | 164 "bitcode-format", cl::desc("Define format of input file:"), |
165 cl::values(clEnumValN(LLVMFormat, "llvm", "LLVM file (default)"), | 165 cl::values(clEnumValN(LLVMFormat, "llvm", "LLVM file (default)"), |
166 clEnumValN(PNaClFormat, "pnacl", "PNaCl bitcode file"), | 166 clEnumValN(PNaClFormat, "pnacl", "PNaCl bitcode file"), |
167 clEnumValEnd), | 167 clEnumValEnd), |
168 cl::init(LLVMFormat)); | 168 cl::init(LLVMFormat)); |
169 | |
170 static cl::opt<bool> | |
171 VerboseErrors( | |
172 "verbose-parse-errors", | |
173 cl::desc("Print out more descriptive PNaCl bitcode parse errors"), | |
174 cl::init(false)); | |
169 // @LOCALMOD-END | 175 // @LOCALMOD-END |
170 } | 176 } |
171 | 177 |
172 static void error(Twine Message, Twine Path = Twine()) { | 178 static void error(Twine Message, Twine Path = Twine()) { |
173 HadError = true; | 179 HadError = true; |
174 errs() << ToolName << ": " << Path << ": " << Message << ".\n"; | 180 errs() << ToolName << ": " << Path << ": " << Message << ".\n"; |
175 } | 181 } |
176 | 182 |
177 static bool error(std::error_code EC, Twine Path = Twine()) { | 183 static bool error(std::error_code EC, Twine Path = Twine()) { |
178 if (EC) { | 184 if (EC) { |
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1004 MemoryBuffer::getFileOrSTDIN(Filename); | 1010 MemoryBuffer::getFileOrSTDIN(Filename); |
1005 if (error(BufferOrErr.getError(), Filename)) | 1011 if (error(BufferOrErr.getError(), Filename)) |
1006 return; | 1012 return; |
1007 | 1013 |
1008 LLVMContext &Context = getGlobalContext(); | 1014 LLVMContext &Context = getGlobalContext(); |
1009 | 1015 |
1010 // @LOCALMOD-BEGIN | 1016 // @LOCALMOD-BEGIN |
1011 // Support parsing PNaCl bitcode files | 1017 // Support parsing PNaCl bitcode files |
1012 /* TODO(jfb) This is currently broken: the code base now requires an Object. | 1018 /* TODO(jfb) This is currently broken: the code base now requires an Object. |
1013 if (InputFileFormat == PNaClFormat) { | 1019 if (InputFileFormat == PNaClFormat) { |
1014 std::string ErrorMessage; | 1020 ErrorOr<Module *> Result = |
1015 Module *Result = NaClParseBitcodeFile(BufferOrErr.get().release(), Context, | 1021 NaClParseBitcodeFile(BufferOrErr.get().release(), VerboseErrors, |
jvoung (off chromium)
2014/12/03 19:43:46
NaClParseBitcodeFile now takes a pointer instead o
Karl
2014/12/03 20:53:44
Done.
| |
1016 &ErrorMessage); | 1022 Context); |
1017 if (Result) { | 1023 if (Result) { |
1018 DumpSymbolNamesFromModule(Result); | 1024 DumpSymbolNamesFromModule(Result.get()); |
1019 delete Result; | 1025 delete Result; |
1020 } else { | 1026 } else { |
1021 error(ErrorMessage, Filename); | 1027 error(Result.message(), Filename); |
1022 return; | 1028 return; |
1023 } | 1029 } |
1024 } | 1030 } |
1025 */ | 1031 */ |
1026 // @LOCALMOD-END | 1032 // @LOCALMOD-END |
1027 | 1033 |
1028 ErrorOr<Binary *> BinaryOrErr = | 1034 ErrorOr<Binary *> BinaryOrErr = |
1029 createBinary(std::move(*BufferOrErr), &Context); | 1035 createBinary(std::move(*BufferOrErr), &Context); |
1030 if (error(BinaryOrErr.getError(), Filename)) | 1036 if (error(BinaryOrErr.getError(), Filename)) |
1031 return; | 1037 return; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1265 "for the -s option"); | 1271 "for the -s option"); |
1266 | 1272 |
1267 std::for_each(InputFilenames.begin(), InputFilenames.end(), | 1273 std::for_each(InputFilenames.begin(), InputFilenames.end(), |
1268 dumpSymbolNamesFromFile); | 1274 dumpSymbolNamesFromFile); |
1269 | 1275 |
1270 if (HadError) | 1276 if (HadError) |
1271 return 1; | 1277 return 1; |
1272 | 1278 |
1273 return 0; | 1279 return 0; |
1274 } | 1280 } |
OLD | NEW |