mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Use IntrusiveRefCntPtr to manage the lifetime of BitCodeAbbrevs.
This doesn't change the interface or gives additional safety but removes a ton of retain/release boilerplate. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217778 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -15,41 +15,11 @@ using namespace llvm;
|
||||
// BitstreamCursor implementation
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void BitstreamCursor::operator=(const BitstreamCursor &RHS) {
|
||||
freeState();
|
||||
|
||||
BitStream = RHS.BitStream;
|
||||
NextChar = RHS.NextChar;
|
||||
CurWord = RHS.CurWord;
|
||||
BitsInCurWord = RHS.BitsInCurWord;
|
||||
CurCodeSize = RHS.CurCodeSize;
|
||||
|
||||
// Copy abbreviations, and bump ref counts.
|
||||
CurAbbrevs = RHS.CurAbbrevs;
|
||||
for (size_t i = 0, e = CurAbbrevs.size(); i != e; ++i)
|
||||
CurAbbrevs[i]->addRef();
|
||||
|
||||
// Copy block scope and bump ref counts.
|
||||
BlockScope = RHS.BlockScope;
|
||||
for (size_t S = 0, e = BlockScope.size(); S != e; ++S) {
|
||||
std::vector<BitCodeAbbrev*> &Abbrevs = BlockScope[S].PrevAbbrevs;
|
||||
for (size_t i = 0, e = Abbrevs.size(); i != e; ++i)
|
||||
Abbrevs[i]->addRef();
|
||||
}
|
||||
}
|
||||
|
||||
void BitstreamCursor::freeState() {
|
||||
// Free all the Abbrevs.
|
||||
for (size_t i = 0, e = CurAbbrevs.size(); i != e; ++i)
|
||||
CurAbbrevs[i]->dropRef();
|
||||
CurAbbrevs.clear();
|
||||
|
||||
// Free all the Abbrevs in the block scope.
|
||||
for (size_t S = 0, e = BlockScope.size(); S != e; ++S) {
|
||||
std::vector<BitCodeAbbrev*> &Abbrevs = BlockScope[S].PrevAbbrevs;
|
||||
for (size_t i = 0, e = Abbrevs.size(); i != e; ++i)
|
||||
Abbrevs[i]->dropRef();
|
||||
}
|
||||
BlockScope.clear();
|
||||
}
|
||||
|
||||
@@ -63,10 +33,8 @@ bool BitstreamCursor::EnterSubBlock(unsigned BlockID, unsigned *NumWordsP) {
|
||||
// Add the abbrevs specific to this block to the CurAbbrevs list.
|
||||
if (const BitstreamReader::BlockInfo *Info =
|
||||
BitStream->getBlockInfo(BlockID)) {
|
||||
for (size_t i = 0, e = Info->Abbrevs.size(); i != e; ++i) {
|
||||
CurAbbrevs.push_back(Info->Abbrevs[i]);
|
||||
CurAbbrevs.back()->addRef();
|
||||
}
|
||||
CurAbbrevs.insert(CurAbbrevs.end(), Info->Abbrevs.begin(),
|
||||
Info->Abbrevs.end());
|
||||
}
|
||||
|
||||
// Get the codesize of this block.
|
||||
@@ -339,9 +307,8 @@ bool BitstreamCursor::ReadBlockInfoBlock() {
|
||||
|
||||
// ReadAbbrevRecord installs the abbrev in CurAbbrevs. Move it to the
|
||||
// appropriate BlockInfo.
|
||||
BitCodeAbbrev *Abbv = CurAbbrevs.back();
|
||||
CurBlockInfo->Abbrevs.push_back(std::move(CurAbbrevs.back()));
|
||||
CurAbbrevs.pop_back();
|
||||
CurBlockInfo->Abbrevs.push_back(Abbv);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user