| 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 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1841 const unsigned char *BufEnd = BufPtr+Buffer->getBufferSize(); | 1841 const unsigned char *BufEnd = BufPtr+Buffer->getBufferSize(); |
| 1842 | 1842 |
| 1843 if (Buffer->getBufferSize() & 3) | 1843 if (Buffer->getBufferSize() & 3) |
| 1844 return Error(InvalidBitstream, | 1844 return Error(InvalidBitstream, |
| 1845 "Bitcode stream should be a multiple of 4 bytes in length"); | 1845 "Bitcode stream should be a multiple of 4 bytes in length"); |
| 1846 | 1846 |
| 1847 const unsigned char *HeaderPtr = BufPtr; | 1847 const unsigned char *HeaderPtr = BufPtr; |
| 1848 if (Header.Read(HeaderPtr, BufEnd)) | 1848 if (Header.Read(HeaderPtr, BufEnd)) |
| 1849 return Error(InvalidBitstream, Header.Unsupported()); | 1849 return Error(InvalidBitstream, Header.Unsupported()); |
| 1850 | 1850 |
| 1851 StreamFile.reset(new NaClBitstreamReader(BufPtr, BufEnd, | 1851 if (AcceptHeader()) |
| 1852 Header.getHeaderSize())); | 1852 return Error(InvalidBitstream, Header.Unsupported()); |
| 1853 |
| 1854 StreamFile.reset(new NaClBitstreamReader(BufPtr, BufEnd, Header)); |
| 1853 Stream.init(StreamFile.get()); | 1855 Stream.init(StreamFile.get()); |
| 1854 | 1856 |
| 1855 if (AcceptHeader()) | |
| 1856 return Error(InvalidBitstream, Header.Unsupported()); | |
| 1857 return std::error_code(); | 1857 return std::error_code(); |
| 1858 } | 1858 } |
| 1859 | 1859 |
| 1860 std::error_code NaClBitcodeReader::InitLazyStream() { | 1860 std::error_code NaClBitcodeReader::InitLazyStream() { |
| 1861 if (Header.Read(LazyStreamer)) | 1861 if (Header.Read(LazyStreamer)) |
| 1862 return Error(InvalidBitstream, Header.Unsupported()); | 1862 return Error(InvalidBitstream, Header.Unsupported()); |
| 1863 | 1863 |
| 1864 StreamFile.reset(new NaClBitstreamReader(LazyStreamer, | |
| 1865 Header.getHeaderSize())); | |
| 1866 Stream.init(StreamFile.get()); | |
| 1867 if (AcceptHeader()) | 1864 if (AcceptHeader()) |
| 1868 return Error(InvalidBitstream, Header.Unsupported()); | 1865 return Error(InvalidBitstream, Header.Unsupported()); |
| 1866 |
| 1867 StreamFile.reset(new NaClBitstreamReader(LazyStreamer, Header)); |
| 1868 Stream.init(StreamFile.get()); |
| 1869 return std::error_code(); | 1869 return std::error_code(); |
| 1870 } | 1870 } |
| 1871 | 1871 |
| 1872 //===----------------------------------------------------------------------===// | 1872 //===----------------------------------------------------------------------===// |
| 1873 // External interface | 1873 // External interface |
| 1874 //===----------------------------------------------------------------------===// | 1874 //===----------------------------------------------------------------------===// |
| 1875 | 1875 |
| 1876 /// \brief Get a lazy one-at-time loading module from bitcode. | 1876 /// \brief Get a lazy one-at-time loading module from bitcode. |
| 1877 /// | 1877 /// |
| 1878 /// This isn't always used in a lazy context. In particular, it's also used by | 1878 /// This isn't always used in a lazy context. In particular, it's also used by |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1935 if (std::error_code EC = M->materializeAllPermanently()) { | 1935 if (std::error_code EC = M->materializeAllPermanently()) { |
| 1936 delete M; | 1936 delete M; |
| 1937 return EC; | 1937 return EC; |
| 1938 } | 1938 } |
| 1939 | 1939 |
| 1940 // TODO: Restore the use-lists to the in-memory state when the bitcode was | 1940 // 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. | 1941 // written. We must defer until the Module has been fully materialized. |
| 1942 | 1942 |
| 1943 return M; | 1943 return M; |
| 1944 } | 1944 } |
| OLD | NEW |