Bitcode: Split out SimpleBitstreamCursor
Split out SimpleBitstreamCursor from BitstreamCursor, which is a
lower-level cursor with no knowledge of bitcode blocks, abbreviations,
or records. It just knows how to read bits and navigate the stream.
This is mainly organizational, to separate the API for manipulating raw
bits from that for bitcode concepts like Record and Block.
llvm-svn: 264545
diff --git a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp b/llvm/lib/Bitcode/Reader/BitstreamReader.cpp
index db9e0cd..af489d7 100644
--- a/llvm/lib/Bitcode/Reader/BitstreamReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitstreamReader.cpp
@@ -32,7 +32,7 @@
// Add the abbrevs specific to this block to the CurAbbrevs list.
if (const BitstreamReader::BlockInfo *Info =
- BitStream->getBlockInfo(BlockID)) {
+ getBitStreamReader()->getBlockInfo(BlockID)) {
CurAbbrevs.insert(CurAbbrevs.end(), Info->Abbrevs.begin(),
Info->Abbrevs.end());
}
@@ -164,7 +164,7 @@
// If this would read off the end of the bitcode file, just set the
// record to empty and return.
if (!canSkipToPos(NewEnd/8)) {
- NextChar = BitStream->getBitcodeBytes().getExtent();
+ skipToEnd();
break;
}
@@ -256,13 +256,14 @@
// record to empty and return.
if (!canSkipToPos(NewEnd/8)) {
Vals.append(NumElts, 0);
- NextChar = BitStream->getBitcodeBytes().getExtent();
+ skipToEnd();
break;
}
// Otherwise, inform the streamer that we need these bytes in memory.
- const char *Ptr = (const char*)
- BitStream->getBitcodeBytes().getPointer(CurBitPos/8, NumElts);
+ const char *Ptr =
+ (const char *)getBitStreamReader()->getBitcodeBytes().getPointer(
+ CurBitPos / 8, NumElts);
// If we can return a reference to the data, do so to avoid copying it.
if (Blob) {
@@ -320,7 +321,7 @@
bool BitstreamCursor::ReadBlockInfoBlock() {
// If this is the second stream to get to the block info block, skip it.
- if (BitStream->hasBlockInfoRecords())
+ if (getBitStreamReader()->hasBlockInfoRecords())
return SkipBlock();
if (EnterSubBlock(bitc::BLOCKINFO_BLOCK_ID)) return true;
@@ -361,11 +362,13 @@
default: break; // Default behavior, ignore unknown content.
case bitc::BLOCKINFO_CODE_SETBID:
if (Record.size() < 1) return true;
- CurBlockInfo = &BitStream->getOrCreateBlockInfo((unsigned)Record[0]);
+ CurBlockInfo =
+ &getBitStreamReader()->getOrCreateBlockInfo((unsigned)Record[0]);
break;
case bitc::BLOCKINFO_CODE_BLOCKNAME: {
if (!CurBlockInfo) return true;
- if (BitStream->isIgnoringBlockInfoNames()) break; // Ignore name.
+ if (getBitStreamReader()->isIgnoringBlockInfoNames())
+ break; // Ignore name.
std::string Name;
for (unsigned i = 0, e = Record.size(); i != e; ++i)
Name += (char)Record[i];
@@ -374,7 +377,8 @@
}
case bitc::BLOCKINFO_CODE_SETRECORDNAME: {
if (!CurBlockInfo) return true;
- if (BitStream->isIgnoringBlockInfoNames()) break; // Ignore name.
+ if (getBitStreamReader()->isIgnoringBlockInfoNames())
+ break; // Ignore name.
std::string Name;
for (unsigned i = 1, e = Record.size(); i != e; ++i)
Name += (char)Record[i];