Improve handling of end of file in the bitcode reader.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 16 Jun 2015 20:03:39 +0000 (20:03 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 16 Jun 2015 20:03:39 +0000 (20:03 +0000)
commit0c650627ca135dcc270558f134606b58da3a2c7f
treec2f5676defe272dfa4a37908d0b9ca0a3934cd67
parent3f53fc8f5f56f6627785ad22bc4dd1471ee6b07d
Improve handling of end of file in the bitcode reader.

Before this patch the bitcode reader would read a module from a file
that contained in order:

* Any number of non MODULE_BLOCK sub blocks.
* One MODULE_BLOCK
* Any number of non MODULE_BLOCK sub blocks.
* 4 '\n' characters to handle OS X's ranlib.

Since we support lazy reading of modules, any information that is relevant
for the module has to be in the MODULE_BLOCK or before it. We don't gain
anything from checking what is after.

This patch then changes the reader to stop once the MODULE_BLOCK has been
successfully parsed.

This avoids the ugly special case for .bc files in an archive and makes it
easier to embed bitcode files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239845 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Bitcode/Reader/BitcodeReader.cpp
test/Bitcode/Inputs/padding-garbage.bc [new file with mode: 0644]
test/Bitcode/padding.test