1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

[StreamArray] Pipe the Offset through the constructor.

When randomly accessing an element by offset, we weren't passing
the offset through so if you called .offset() it would return a
value of 0.

llvm-svn: 302292
This commit is contained in:
Zachary Turner 2017-05-05 21:15:31 +00:00
parent e4592ed923
commit dc2635c4aa

View File

@ -64,8 +64,8 @@ class VarStreamArrayIterator
public:
VarStreamArrayIterator() = default;
VarStreamArrayIterator(const ArrayType &Array, const WrappedCtx &Ctx,
BinaryStreamRef Stream, bool *HadError = nullptr)
: IterRef(Stream), Ctx(&Ctx), Array(&Array), HadError(HadError) {
BinaryStreamRef Stream, bool *HadError = nullptr, uint32_t Offset = 0)
: IterRef(Stream), Ctx(&Ctx), Array(&Array), HadError(HadError), AbsOffset(Offset) {
if (IterRef.getLength() == 0)
moveToEnd();
else {
@ -238,7 +238,7 @@ public:
/// since the behavior is undefined if \p Offset does not refer to the
/// beginning of a valid record.
Iterator at(uint32_t Offset) const {
return Iterator(*this, Ctx, Stream.drop_front(Offset), nullptr);
return Iterator(*this, Ctx, Stream.drop_front(Offset), nullptr, Offset);
}
BinaryStreamRef getUnderlyingStream() const { return Stream; }