OLD | NEW |
1 //===-- llvm-bcanalyzer.cpp - Bitcode Analyzer --------------------------===// | 1 //===-- llvm-bcanalyzer.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 // This tool may be invoked in the following manner: | 10 // This tool may be invoked in the following manner: |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 // Read the input file. | 478 // Read the input file. |
479 OwningPtr<MemoryBuffer> MemBuf; | 479 OwningPtr<MemoryBuffer> MemBuf; |
480 | 480 |
481 if (error_code ec = | 481 if (error_code ec = |
482 MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), MemBuf)) | 482 MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), MemBuf)) |
483 return Error("Error reading '" + InputFilename + "': " + ec.message()); | 483 return Error("Error reading '" + InputFilename + "': " + ec.message()); |
484 | 484 |
485 if (MemBuf->getBufferSize() & 3) | 485 if (MemBuf->getBufferSize() & 3) |
486 return Error("Bitcode stream should be a multiple of 4 bytes in length"); | 486 return Error("Bitcode stream should be a multiple of 4 bytes in length"); |
487 | 487 |
488 unsigned char *BufPtr = (unsigned char *)MemBuf->getBufferStart(); | 488 const unsigned char *BufPtr = (unsigned char *)MemBuf->getBufferStart(); |
489 unsigned char *EndBufPtr = BufPtr+MemBuf->getBufferSize(); | 489 const unsigned char *EndBufPtr = BufPtr+MemBuf->getBufferSize(); |
490 | 490 |
491 // If we have a wrapper header, parse it and ignore the non-bc file contents. | 491 // If we have a wrapper header, parse it and ignore the non-bc file contents. |
492 // The magic number is 0x0B17C0DE stored in little endian. | 492 // The magic number is 0x0B17C0DE stored in little endian. |
493 if (isBitcodeWrapper(BufPtr, EndBufPtr)) | 493 if (isBitcodeWrapper(BufPtr, EndBufPtr)) |
494 if (SkipBitcodeWrapperHeader(BufPtr, EndBufPtr)) | 494 if (SkipBitcodeWrapperHeader(BufPtr, EndBufPtr, true)) |
495 return Error("Invalid bitcode wrapper header"); | 495 return Error("Invalid bitcode wrapper header"); |
496 | 496 |
497 BitstreamReader StreamFile(BufPtr, EndBufPtr); | 497 BitstreamReader StreamFile(BufPtr, EndBufPtr); |
498 BitstreamCursor Stream(StreamFile); | 498 BitstreamCursor Stream(StreamFile); |
499 StreamFile.CollectBlockInfoNames(); | 499 StreamFile.CollectBlockInfoNames(); |
500 | 500 |
501 // Read the stream signature. | 501 // Read the stream signature. |
502 char Signature[6]; | 502 char Signature[6]; |
503 Signature[0] = Stream.Read(8); | 503 Signature[0] = Stream.Read(8); |
504 Signature[1] = Stream.Read(8); | 504 Signature[1] = Stream.Read(8); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 | 620 |
621 int main(int argc, char **argv) { | 621 int main(int argc, char **argv) { |
622 // Print a stack trace if we signal out. | 622 // Print a stack trace if we signal out. |
623 sys::PrintStackTraceOnErrorSignal(); | 623 sys::PrintStackTraceOnErrorSignal(); |
624 PrettyStackTraceProgram X(argc, argv); | 624 PrettyStackTraceProgram X(argc, argv); |
625 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. | 625 llvm_shutdown_obj Y; // Call llvm_shutdown() on exit. |
626 cl::ParseCommandLineOptions(argc, argv, "llvm-bcanalyzer file analyzer\n"); | 626 cl::ParseCommandLineOptions(argc, argv, "llvm-bcanalyzer file analyzer\n"); |
627 | 627 |
628 return AnalyzeBitcode(); | 628 return AnalyzeBitcode(); |
629 } | 629 } |
OLD | NEW |