summaryrefslogtreecommitdiff
path: root/include/llvm/Bitcode
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-26 21:07:02 +0000
committerChris Lattner <sabre@nondot.org>2009-04-26 21:07:02 +0000
commit7919b966a8fd8f98346216e79df6f4722693be22 (patch)
tree47581098e1b1404b8b27f5e58d6a4d6d5efe4451 /include/llvm/Bitcode
parent962dde3cef3184f1683d5070c298c9a29509d62e (diff)
downloadllvm-7919b966a8fd8f98346216e79df6f4722693be22.tar.gz
llvm-7919b966a8fd8f98346216e79df6f4722693be22.tar.bz2
llvm-7919b966a8fd8f98346216e79df6f4722693be22.tar.xz
make BitstreamCursor's copyable and assignable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70159 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Bitcode')
-rw-r--r--include/llvm/Bitcode/BitstreamReader.h40
1 files changed, 38 insertions, 2 deletions
diff --git a/include/llvm/Bitcode/BitstreamReader.h b/include/llvm/Bitcode/BitstreamReader.h
index ae18f2c57b..d2489d19ac 100644
--- a/include/llvm/Bitcode/BitstreamReader.h
+++ b/include/llvm/Bitcode/BitstreamReader.h
@@ -71,6 +71,11 @@ public:
// Block Manipulation
//===--------------------------------------------------------------------===//
+ /// hasBlockInfoRecords - Return true if we've already read and processed the
+ /// block info block for this Bitstream. We only process it for the first
+ /// cursor that walks over it.
+ bool hasBlockInfoRecords() const { return !BlockInfoRecords.empty(); }
+
/// getBlockInfo - If there is block info for the specified ID, return it,
/// otherwise return null.
BlockInfo *getBlockInfo(unsigned BlockID) {
@@ -126,11 +131,13 @@ class BitstreamCursor {
/// BlockScope - This tracks the codesize of parent blocks.
SmallVector<Block, 8> BlockScope;
- BitstreamCursor(const BitstreamCursor&); // NOT YET IMPLEMENTED.
- void operator=(const BitstreamCursor&); // NOT YET IMPLEMENTED.
public:
BitstreamCursor() : BitStream(0), NextChar(0) {
}
+ BitstreamCursor(const BitstreamCursor &RHS) : BitStream(0), NextChar(0) {
+ operator=(RHS);
+ }
+
explicit BitstreamCursor(BitstreamReader &R) : BitStream(&R) {
NextChar = R.getFirstChar();
assert(NextChar && "Bitstream not initialized yet");
@@ -154,6 +161,31 @@ public:
freeState();
}
+ void 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 (unsigned i = 0, e = static_cast<unsigned>(CurAbbrevs.size());
+ i != e; ++i)
+ CurAbbrevs[i]->addRef();
+
+ // Copy block scope and bump ref counts.
+ for (unsigned S = 0, e = static_cast<unsigned>(BlockScope.size());
+ S != e; ++S) {
+ std::vector<BitCodeAbbrev*> &Abbrevs = BlockScope[S].PrevAbbrevs;
+ for (unsigned i = 0, e = static_cast<unsigned>(Abbrevs.size());
+ i != e; ++i)
+ Abbrevs[i]->addRef();
+ }
+ }
+
void freeState() {
// Free all the Abbrevs.
for (unsigned i = 0, e = static_cast<unsigned>(CurAbbrevs.size());
@@ -512,6 +544,10 @@ public:
public:
bool ReadBlockInfoBlock() {
+ // If this is the second stream to get to the block info block, skip it.
+ if (BitStream->hasBlockInfoRecords())
+ return SkipBlock();
+
if (EnterSubBlock(bitc::BLOCKINFO_BLOCK_ID)) return true;
SmallVector<uint64_t, 64> Record;