[llvm] r291026 - Change BitstreamCursor::skipRecord to return the record code (NFC)
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 4 14:54:14 PST 2017
Author: mehdi_amini
Date: Wed Jan 4 16:54:14 2017
New Revision: 291026
URL: http://llvm.org/viewvc/llvm-project?rev=291026&view=rev
Log:
Change BitstreamCursor::skipRecord to return the record code (NFC)
Modified:
llvm/trunk/include/llvm/Bitcode/BitstreamReader.h
llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp
Modified: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamReader.h?rev=291026&r1=291025&r2=291026&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Bitcode/BitstreamReader.h (original)
+++ llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Wed Jan 4 16:54:14 2017
@@ -477,8 +477,8 @@ public:
return CurAbbrevs[AbbrevNo].get();
}
- /// Read the current record and discard it.
- void skipRecord(unsigned AbbrevID);
+ /// Read the current record and discard it, returning the code for the record.
+ unsigned skipRecord(unsigned AbbrevID);
unsigned readRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals,
StringRef *Blob = nullptr);
Modified: llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp?rev=291026&r1=291025&r2=291026&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp Wed Jan 4 16:54:14 2017
@@ -93,20 +93,29 @@ static void skipAbbreviatedField(Bitstre
}
/// skipRecord - Read the current record and discard it.
-void BitstreamCursor::skipRecord(unsigned AbbrevID) {
+unsigned BitstreamCursor::skipRecord(unsigned AbbrevID) {
// Skip unabbreviated records by reading past their entries.
if (AbbrevID == bitc::UNABBREV_RECORD) {
unsigned Code = ReadVBR(6);
- (void)Code;
unsigned NumElts = ReadVBR(6);
for (unsigned i = 0; i != NumElts; ++i)
(void)ReadVBR64(6);
- return;
+ return Code;
}
const BitCodeAbbrev *Abbv = getAbbrev(AbbrevID);
+ const BitCodeAbbrevOp &CodeOp = Abbv->getOperandInfo(0);
+ unsigned Code;
+ if (CodeOp.isLiteral())
+ Code = CodeOp.getLiteralValue();
+ else {
+ if (CodeOp.getEncoding() == BitCodeAbbrevOp::Array ||
+ CodeOp.getEncoding() == BitCodeAbbrevOp::Blob)
+ report_fatal_error("Abbreviation starts with an Array or a Blob");
+ Code = readAbbreviatedField(*this, CodeOp);
+ }
- for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) {
+ for (unsigned i = 1, e = Abbv->getNumOperandInfos(); i < e; ++i) {
const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i);
if (Op.isLiteral())
continue;
@@ -164,6 +173,7 @@ void BitstreamCursor::skipRecord(unsigne
// Skip over the blob.
JumpToBit(NewEnd);
}
+ return Code;
}
unsigned BitstreamCursor::readRecord(unsigned AbbrevID,
More information about the llvm-commits
mailing list