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

Sean Silva chisophugis at gmail.com
Wed Nov 12 16:37:45 PST 2014


+    // Handle big-endian byte-swapping if necessary.
+    support::detail::packed_endian_specific_integral<
+        word_t, support::little, support::unaligned> EndianValue;
+    memcpy(&EndianValue, Array, sizeof(Array));
+
+    CurWord = EndianValue;

Can you do:

CurWord = endian::read<word_t, support::little, support::unaligned>(Array)

?

-- Sean Silva

On Wed, Nov 12, 2014 at 4:09 PM, Jordan Rose <jordan_rose at apple.com> wrote:

> Committed in r221840.
>
> Jordan
>
>
> > On Nov 12, 2014, at 15:59 , Jordan Rose <jordan_rose at apple.com> wrote:
> >
> > 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
> >>>
> >
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141112/41ee4b62/attachment.html>


More information about the llvm-commits mailing list