OLD | NEW |
1 //===-- NaClBitcodeAnalyzer.cpp - Bitcode Analyzer ------------------------===// | 1 //===-- NaClBitcodeAnalyzer.cpp - Bitcode Analyzer ------------------------===// |
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 #define DEBUG_TYPE "nacl-bitcode-analyzer" | 10 #define DEBUG_TYPE "nacl-bitcode-analyzer" |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 NaClBitcodeHeader Header; | 412 NaClBitcodeHeader Header; |
413 if (Header.Read(BufPtr, EndBufPtr)) | 413 if (Header.Read(BufPtr, EndBufPtr)) |
414 return Error("Invalid PNaCl bitcode header"); | 414 return Error("Invalid PNaCl bitcode header"); |
415 | 415 |
416 if (!Header.IsSupported()) | 416 if (!Header.IsSupported()) |
417 errs() << "Warning: " << Header.Unsupported() << "\n"; | 417 errs() << "Warning: " << Header.Unsupported() << "\n"; |
418 | 418 |
419 if (!Header.IsReadable()) | 419 if (!Header.IsReadable()) |
420 Error("Bitcode file is not readable"); | 420 Error("Bitcode file is not readable"); |
421 | 421 |
422 NaClBitstreamReader StreamFile(BufPtr, EndBufPtr); | 422 NaClBitstreamReader StreamFile(BufPtr, EndBufPtr, Header); |
423 NaClBitstreamCursor Stream(StreamFile); | 423 NaClBitstreamCursor Stream(StreamFile); |
424 | 424 |
425 unsigned NumTopBlocks = 0; | 425 unsigned NumTopBlocks = 0; |
426 | 426 |
427 // Print out header information. | 427 // Print out header information. |
428 for (size_t i = 0, limit = Header.NumberFields(); i < limit; ++i) { | 428 for (size_t i = 0, limit = Header.NumberFields(); i < limit; ++i) { |
429 OS << Header.GetField(i)->Contents() << "\n"; | 429 OS << Header.GetField(i)->Contents() << "\n"; |
430 } | 430 } |
431 if (Header.NumberFields()) OS << "\n"; | 431 if (Header.NumberFields()) OS << "\n"; |
432 | 432 |
(...skipping 27 matching lines...) Expand all Loading... |
460 ErrorOr<std::unique_ptr<MemoryBuffer>> ErrOrFile = | 460 ErrorOr<std::unique_ptr<MemoryBuffer>> ErrOrFile = |
461 MemoryBuffer::getFileOrSTDIN(InputFilename); | 461 MemoryBuffer::getFileOrSTDIN(InputFilename); |
462 if (std::error_code EC = ErrOrFile.getError()) | 462 if (std::error_code EC = ErrOrFile.getError()) |
463 return Error(Twine("Error reading '") + InputFilename + "': " + | 463 return Error(Twine("Error reading '") + InputFilename + "': " + |
464 EC.message()); | 464 EC.message()); |
465 | 465 |
466 return AnalyzeBitcodeInBuffer(ErrOrFile.get(), OS, DumpOptions); | 466 return AnalyzeBitcodeInBuffer(ErrOrFile.get(), OS, DumpOptions); |
467 } | 467 } |
468 | 468 |
469 } // namespace llvm | 469 } // namespace llvm |
OLD | NEW |