r221804 - Use the return of readBytes to find out if we are at the end of the stream.

Jordan Rose jordan_rose at apple.com
Wed Nov 12 15:59:00 PST 2014


I'm just going to write a gtest unit test for this. That's easy enough.

Jordan

> On Nov 12, 2014, at 15:58 , Rafael Avila de Espindola <rafael.espindola at gmail.com> wrote:
> 
> Would it reproduce with opt and an empty file?
> 
> Sent from my iPhone
> 
>> On Nov 12, 2014, at 18:54, Jordan Rose <jordan_rose at apple.com> wrote:
>> 
>> 
>>> On Nov 12, 2014, at 15:38, Rafael Avila de Espindola <rafael.espindola at gmail.com> wrote:
>>> 
>>> 
>>> 
>>> Sent from my iPhone
>>> 
>>>> On Nov 12, 2014, at 18:22, Jordan Rose <jordan_rose at apple.com> wrote:
>>>> 
>>>> Looks like it's just this:
>>>> 
>>>> diff --git a/include/llvm/Bitcode/BitstreamReader.h b/include/llvm/Bitcode/BitstreamReader.h
>>>> index 6b9c858..41e50e1 100644
>>>> --- a/include/llvm/Bitcode/BitstreamReader.h
>>>> +++ b/include/llvm/Bitcode/BitstreamReader.h
>>>> @@ -227,7 +227,7 @@ public:
>>>> bool AtEndOfStream() {
>>>>  if (BitsInCurWord != 0)
>>>>    return false;
>>>> -    if (Size == NextChar)
>>>> +    if (Size != 0 && Size == NextChar)
>>>>    return true;
>>>>  fillCurWord();
>>>>  return BitsInCurWord == 0;
>>>> 
>>>> i.e. you forgot about the fact that we /start/ with both Size and NextChar equal to 0. Does this look like the right fix to you?
>>> 
>>> 
>>> Oh, so a call at the very start would fail. LGTM
>> 
>> Yup, I don't have a test case in LLVM's code, but Swift is checking explicitly for an empty file. Took me a while to track that down.
>> 
>> Thanks, I'll commit.
>> Jordan
>> 





More information about the llvm-commits mailing list