From 5a4251c767adb7a47ad7a53719398ee1342cc400 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 20 Jan 2013 02:13:19 +0000 Subject: convert the bitstream reader itself and the IR .bc file parser to use the new advance() APIs, simplifying things and making a bunch of details more private to BitstreamCursor. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172947 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Reader/BitstreamReader.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'lib/Bitcode/Reader/BitstreamReader.cpp') diff --git a/lib/Bitcode/Reader/BitstreamReader.cpp b/lib/Bitcode/Reader/BitstreamReader.cpp index 84d5ca6150..83df57b8fb 100644 --- a/lib/Bitcode/Reader/BitstreamReader.cpp +++ b/lib/Bitcode/Reader/BitstreamReader.cpp @@ -306,17 +306,21 @@ bool BitstreamCursor::ReadBlockInfoBlock() { // Read all the records for this module. while (1) { - unsigned Code = ReadCode(); - if (Code == bitc::END_BLOCK) - return ReadBlockEnd(); - if (Code == bitc::ENTER_SUBBLOCK) { - ReadSubBlockID(); - if (SkipBlock()) return true; - continue; - } + BitstreamEntry Entry = advanceSkippingSubblocks(AF_DontAutoprocessAbbrevs); + switch (Entry.Kind) { + case llvm::BitstreamEntry::SubBlock: // Handled for us already. + case llvm::BitstreamEntry::Error: + return true; + case llvm::BitstreamEntry::EndBlock: + return false; + case llvm::BitstreamEntry::Record: + // The interesting case. + break; + } + // Read abbrev records, associate them with CurBID. - if (Code == bitc::DEFINE_ABBREV) { + if (Entry.ID == bitc::DEFINE_ABBREV) { if (!CurBlockInfo) return true; ReadAbbrevRecord(); @@ -330,7 +334,7 @@ bool BitstreamCursor::ReadBlockInfoBlock() { // Read a record. Record.clear(); - switch (ReadRecord(Code, Record)) { + switch (readRecord(Entry.ID, Record)) { default: break; // Default behavior, ignore unknown content. case bitc::BLOCKINFO_CODE_SETBID: if (Record.size() < 1) return true; -- cgit v1.2.3-70-g09d2