OSDN Git Service

Bitcode: Change reader interface to take memory buffers.
authorPeter Collingbourne <peter@pcc.me.uk>
Wed, 2 Nov 2016 00:08:19 +0000 (00:08 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Wed, 2 Nov 2016 00:08:19 +0000 (00:08 +0000)
commite8516587a2604386a8faaab28c410663c2ec884c
treee8b6fc5608214951fb388faf948200df8990a697
parenta0a6883ade4b400d4ed53048e877ca5711cded53
Bitcode: Change reader interface to take memory buffers.

As proposed on llvm-dev:
http://lists.llvm.org/pipermail/llvm-dev/2016-October/106595.html

This change also fixes an API oddity where BitstreamCursor::Read() would
return zero for the first read past the end of the bitstream, but would
report_fatal_error for subsequent reads. Now we always report_fatal_error
for all reads past the end. Updated clients to check for the end of the
bitstream before reading from it.

I also needed to add padding to the invalid bitcode tests in
test/Bitcode/. This is because the streaming interface was not checking that
the file size is a multiple of 4.

Differential Revision: https://reviews.llvm.org/D26219

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285773 91177308-0d34-0410-b5e6-96231b3b80d8
15 files changed:
include/llvm/Bitcode/BitstreamReader.h
include/llvm/Bitcode/ReaderWriter.h
lib/Bitcode/Reader/BitcodeReader.cpp
test/Bitcode/Inputs/invalid-array-operand-encoding.bc
test/Bitcode/Inputs/invalid-code-len-width.bc
test/Bitcode/Inputs/invalid-extractval-array-idx.bc
test/Bitcode/Inputs/invalid-function-comdat-id.bc
test/Bitcode/Inputs/invalid-fwdref-type-mismatch-2.bc
test/Bitcode/Inputs/invalid-metadata-not-followed-named-node.bc
test/Bitcode/Inputs/invalid-name-with-0-byte.bc
test/Bitcode/Inputs/invalid-unexpected-eof.bc
tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp
tools/llvm-dis/llvm-dis.cpp
unittests/Bitcode/BitReaderTest.cpp
unittests/Bitcode/BitstreamReaderTest.cpp