X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FBitcode%2FBitstreamReader.h;h=eac9ab0b607ad82f5bdbca5cc4e4e6c5dd3d25e6;hb=a727d5502c8e23c090da658bf14c5ebc1169a070;hp=634bc738dfdd71bb5a650965bf09968456750287;hpb=90a5c7dbc150af336b6e153427f21fb8a1d46d78;p=oota-llvm.git diff --git a/include/llvm/Bitcode/BitstreamReader.h b/include/llvm/Bitcode/BitstreamReader.h index 634bc738dfd..eac9ab0b607 100644 --- a/include/llvm/Bitcode/BitstreamReader.h +++ b/include/llvm/Bitcode/BitstreamReader.h @@ -75,12 +75,12 @@ public: // 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 &Abbrevs = BlockScope[S].PrevAbbrevs; for (unsigned i = 0, e = Abbrevs.size(); i != e; ++i) - delete Abbrevs[i]; + Abbrevs[i]->dropRef(); } } @@ -93,16 +93,19 @@ public: /// 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 #. @@ -260,7 +263,7 @@ public: // 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(); @@ -280,7 +283,7 @@ public: 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];