Skip to content

Commit

Permalink
add some optional flags to affect the way advance works.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172928 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed Jan 19, 2013
1 parent 00a312c commit 344fc23
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions include/llvm/Bitcode/BitstreamReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,14 +269,19 @@ class BitstreamCursor {
return BitStream;
}

/// Flags that modify the behavior of advance().
enum {
AF_DontPopBlockAtEnd = 1
};

/// advance - Advance the current bitstream, returning the next entry in the
/// stream.
BitstreamEntry advance() {
BitstreamEntry advance(unsigned Flags = 0) {
while (1) {
unsigned Code = ReadCode();
if (Code == bitc::END_BLOCK) {
if (ReadBlockEnd())
// Pop the end of the block unless Flags tells us not to.
if (!(Flags & AF_DontPopBlockAtEnd) && ReadBlockEnd())
return BitstreamEntry::getError();
return BitstreamEntry::getEndBlock();
}
Expand All @@ -297,10 +302,10 @@ class BitstreamCursor {

/// advanceSkippingSubblocks - This is a convenience function for clients that
/// don't expect any subblocks. This just skips over them automatically.
BitstreamEntry advanceSkippingSubblocks() {
BitstreamEntry advanceSkippingSubblocks(unsigned Flags = 0) {
while (1) {
// If we found a normal entry, return it.
BitstreamEntry Entry = advance();
BitstreamEntry Entry = advance(Flags);
if (Entry.Kind != BitstreamEntry::SubBlock)
return Entry;

Expand Down

0 comments on commit 344fc23

Please sign in to comment.