diff options
author | Chris Lattner <sabre@nondot.org> | 2013-01-20 02:13:19 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2013-01-20 02:13:19 +0000 |
commit | 5a4251c767adb7a47ad7a53719398ee1342cc400 (patch) | |
tree | e6983f469c4292614612673dfdb605a87663ddfc /lib/Bitcode/Reader/BitstreamReader.cpp | |
parent | 099b636562a83dc9acc6bf36ca32d710ac6d62c9 (diff) |
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
Diffstat (limited to 'lib/Bitcode/Reader/BitstreamReader.cpp')
-rw-r--r-- | lib/Bitcode/Reader/BitstreamReader.cpp | 24 |
1 files changed, 14 insertions, 10 deletions
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; |