[PATCH] Add test showing error in StreamingMemoryObject.setKnownObjectSize().
Rafael Ávila de Espíndola
rafael.espindola at gmail.com
Thu Apr 30 13:32:45 PDT 2015
It would be better for both APIs to see the end of data in the same way.
The code organization actually makes that easy now, no?:
Just replace the
return true;
on line 80 with
return !ObjectSize || Pos < ObjectSize;
Considering all the cases:
- Asked to read until a valid position and we manage to read it: We will return true since we either found the object size or it has to be larger than pos (since pos is valid)
- Asked to read too much and we actually manage to do it. ObjectSize must be set for it to be legal to put data after a bitcode file, so we will detect this.
- Asked to read too much, and the GetBytes fails, the check for eof will return false.
================
Comment at: include/llvm/Support/StreamingMemoryObject.h:75
@@ -73,3 +74,3 @@
BytesRead += bytes;
- if (bytes != kChunkSize) { // reached EOF/ran out of bytes
- ObjectSize = BytesRead;
+ if (bytes == 0) { // reached EOF/ran out of bytes
+ if (ObjectSize == 0)
----------------
Why only == 0?
The previous logic looks correct If we ask for 100 bytes but only get 50, we are at the end of the stream.
http://reviews.llvm.org/D8931
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list