[PATCH] D26219: Bitcode: Change reader interface to take memory buffers.

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 9 12:43:55 PST 2016


mehdi_amini added a comment.

Alright, LGTM!



================
Comment at: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h:435
+        return BitstreamEntry::getError();
+
       unsigned Code = ReadCode();
----------------
There is a semantic change here.

Previously, when at the end of the stream after calling `Stream.advance(BitstreamCursor::AF_DontPopBlockAtEnd);` we would call `ReadCode()` which would return `0` which is also `bitc::END_BLOCK`, and we would enter the condition below and ` return BitstreamEntry::getEndBlock();`.
Now we return an error instead.

This is breaking the loop pattern in `BitcodeReader::parseIdentificationBlock`, which is conceptually the following:

```
  // We expect a number of well-defined blocks, though we don't necessarily
  // need to understand them all.
  while (1) {
    BitstreamEntry Entry =
        Stream.advance(BitstreamCursor::AF_DontPopBlockAtEnd);
    // Ignore other sub-blocks.
    if (Stream.SkipBlock())
      return error("Malformed block");
  }
``` 



Repository:
  rL LLVM

https://reviews.llvm.org/D26219





More information about the llvm-commits mailing list