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

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 9 14:26:43 PST 2016


pcc added inline comments.


================
Comment at: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h:435
+        return BitstreamEntry::getError();
+
       unsigned Code = ReadCode();
----------------
mehdi_amini wrote:
> 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");
>   }
> ``` 
> 
As discussed on IRC, let's add a `BitstreamEntry::EOF` enum and change the clients to handle it.


Repository:
  rL LLVM

https://reviews.llvm.org/D26219





More information about the llvm-commits mailing list