// Abbrevs could still exist if the stream was broken. If so, don't leak
// them.
for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i)
- delete CurAbbrevs[i];
+ CurAbbrevs[i]->dropRef();
for (unsigned S = 0, e = BlockScope.size(); S != e; ++S) {
std::vector<BitCodeAbbrev*> &Abbrevs = BlockScope[S].PrevAbbrevs;
for (unsigned i = 0, e = Abbrevs.size(); i != e; ++i)
- delete Abbrevs[i];
+ Abbrevs[i]->dropRef();
}
}
/// JumpToBit - Reset the stream to the specified bit number.
void JumpToBit(uint64_t BitNo) {
- unsigned WordNo = BitNo/32;
+ unsigned ByteNo = (BitNo/8) & ~3;
unsigned WordBitNo = BitNo & 31;
- assert(WordNo < (unsigned)(LastChar-FirstChar) && "Invalid location");
+ assert(ByteNo < (unsigned)(LastChar-FirstChar) && "Invalid location");
// Move the cursor to the right word.
- NextChar = FirstChar+WordNo;
+ NextChar = FirstChar+ByteNo;
BitsInCurWord = 0;
// Skip over any bits that are already consumed.
- if (WordBitNo) Read(WordBitNo);
+ if (WordBitNo) {
+ NextChar -= 4;
+ Read(WordBitNo);
+ }
}
/// GetAbbrevIDWidth - Return the number of bits used to encode an abbrev #.
// Delete abbrevs from popped scope.
for (unsigned i = 0, e = CurAbbrevs.size(); i != e; ++i)
- delete CurAbbrevs[i];
+ CurAbbrevs[i]->dropRef();
BlockScope.back().PrevAbbrevs.swap(CurAbbrevs);
BlockScope.pop_back();
return Code;
}
- unsigned AbbrevNo = AbbrevID-bitc::FIRST_ABBREV;
+ unsigned AbbrevNo = AbbrevID-bitc::FIRST_APPLICATION_ABBREV;
assert(AbbrevNo < CurAbbrevs.size() && "Invalid abbrev #!");
BitCodeAbbrev *Abbv = CurAbbrevs[AbbrevNo];