| OLD | NEW |
| 1 //===- NaClBitcodeReader.cpp ----------------------------------------------===// | 1 //===- NaClBitcodeReader.cpp ----------------------------------------------===// |
| 2 // Internal NaClBitcodeReader implementation | 2 // Internal NaClBitcodeReader implementation |
| 3 // | 3 // |
| 4 // The LLVM Compiler Infrastructure | 4 // The LLVM Compiler Infrastructure |
| 5 // | 5 // |
| 6 // This file is distributed under the University of Illinois Open Source | 6 // This file is distributed under the University of Illinois Open Source |
| 7 // License. See LICENSE.TXT for details. | 7 // License. See LICENSE.TXT for details. |
| 8 // | 8 // |
| 9 //===----------------------------------------------------------------------===// | 9 //===----------------------------------------------------------------------===// |
| 10 | 10 |
| (...skipping 1828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1839 } | 1839 } |
| 1840 | 1840 |
| 1841 std::error_code NaClBitcodeReader::InitStreamFromBuffer() { | 1841 std::error_code NaClBitcodeReader::InitStreamFromBuffer() { |
| 1842 const unsigned char *BufPtr = (const unsigned char*)Buffer->getBufferStart(); | 1842 const unsigned char *BufPtr = (const unsigned char*)Buffer->getBufferStart(); |
| 1843 const unsigned char *BufEnd = BufPtr+Buffer->getBufferSize(); | 1843 const unsigned char *BufEnd = BufPtr+Buffer->getBufferSize(); |
| 1844 | 1844 |
| 1845 if (Buffer->getBufferSize() & 3) | 1845 if (Buffer->getBufferSize() & 3) |
| 1846 return Error(InvalidBitstream, | 1846 return Error(InvalidBitstream, |
| 1847 "Bitcode stream should be a multiple of 4 bytes in length"); | 1847 "Bitcode stream should be a multiple of 4 bytes in length"); |
| 1848 | 1848 |
| 1849 if (Header.Read(BufPtr, BufEnd)) | 1849 const unsigned char *HeaderPtr = BufPtr; |
| 1850 if (Header.Read(HeaderPtr, BufEnd)) |
| 1850 return Error(InvalidBitstream, Header.Unsupported()); | 1851 return Error(InvalidBitstream, Header.Unsupported()); |
| 1851 | 1852 |
| 1852 StreamFile.reset(new NaClBitstreamReader(BufPtr, BufEnd)); | 1853 StreamFile.reset(new NaClBitstreamReader(BufPtr, BufEnd, |
| 1854 Header.getHeaderSize())); |
| 1853 Stream.init(StreamFile.get()); | 1855 Stream.init(StreamFile.get()); |
| 1854 | 1856 |
| 1855 if (AcceptHeader()) | 1857 if (AcceptHeader()) |
| 1856 return Error(InvalidBitstream, Header.Unsupported()); | 1858 return Error(InvalidBitstream, Header.Unsupported()); |
| 1857 return std::error_code(); | 1859 return std::error_code(); |
| 1858 } | 1860 } |
| 1859 | 1861 |
| 1860 std::error_code NaClBitcodeReader::InitLazyStream() { | 1862 std::error_code NaClBitcodeReader::InitLazyStream() { |
| 1861 if (Header.Read(LazyStreamer)) | 1863 if (Header.Read(LazyStreamer)) |
| 1862 return Error(InvalidBitstream, Header.Unsupported()); | 1864 return Error(InvalidBitstream, Header.Unsupported()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1935 if (std::error_code EC = M->materializeAllPermanently()) { | 1937 if (std::error_code EC = M->materializeAllPermanently()) { |
| 1936 delete M; | 1938 delete M; |
| 1937 return EC; | 1939 return EC; |
| 1938 } | 1940 } |
| 1939 | 1941 |
| 1940 // TODO: Restore the use-lists to the in-memory state when the bitcode was | 1942 // TODO: Restore the use-lists to the in-memory state when the bitcode was |
| 1941 // written. We must defer until the Module has been fully materialized. | 1943 // written. We must defer until the Module has been fully materialized. |
| 1942 | 1944 |
| 1943 return M; | 1945 return M; |
| 1944 } | 1946 } |
| OLD | NEW |