[llvm] 6599d00 - [Bitstream] Delete skipAbbreviatedField which duplicates readAbbreviatedField
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 25 18:55:10 PST 2019
Author: Fangrui Song
Date: 2019-12-25T18:55:02-08:00
New Revision: 6599d004679e04f0d9e9c5b6c8503e463db79a1f
URL: https://github.com/llvm/llvm-project/commit/6599d004679e04f0d9e9c5b6c8503e463db79a1f
DIFF: https://github.com/llvm/llvm-project/commit/6599d004679e04f0d9e9c5b6c8503e463db79a1f.diff
LOG: [Bitstream] Delete skipAbbreviatedField which duplicates readAbbreviatedField
Added:
Modified:
llvm/lib/Bitstream/Reader/BitstreamReader.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Bitstream/Reader/BitstreamReader.cpp b/llvm/lib/Bitstream/Reader/BitstreamReader.cpp
index a4a97ced5457..92d7c91a1d35 100644
--- a/llvm/lib/Bitstream/Reader/BitstreamReader.cpp
+++ b/llvm/lib/Bitstream/Reader/BitstreamReader.cpp
@@ -88,37 +88,6 @@ static Expected<uint64_t> readAbbreviatedField(BitstreamCursor &Cursor,
llvm_unreachable("invalid abbreviation encoding");
}
-static Error skipAbbreviatedField(BitstreamCursor &Cursor,
- const BitCodeAbbrevOp &Op) {
- assert(!Op.isLiteral() && "Not to be used with literals!");
-
- // Decode the value as we are commanded.
- switch (Op.getEncoding()) {
- case BitCodeAbbrevOp::Array:
- case BitCodeAbbrevOp::Blob:
- llvm_unreachable("Should not reach here");
- case BitCodeAbbrevOp::Fixed:
- assert((unsigned)Op.getEncodingData() <= Cursor.MaxChunkSize);
- if (Expected<unsigned> Res = Cursor.Read((unsigned)Op.getEncodingData()))
- break;
- else
- return Res.takeError();
- case BitCodeAbbrevOp::VBR:
- assert((unsigned)Op.getEncodingData() <= Cursor.MaxChunkSize);
- if (Expected<uint64_t> Res =
- Cursor.ReadVBR64((unsigned)Op.getEncodingData()))
- break;
- else
- return Res.takeError();
- case BitCodeAbbrevOp::Char6:
- if (Expected<unsigned> Res = Cursor.Read(6))
- break;
- else
- return Res.takeError();
- }
- return ErrorSuccess();
-}
-
/// skipRecord - Read the current record and discard it.
Expected<unsigned> BitstreamCursor::skipRecord(unsigned AbbrevID) {
// Skip unabbreviated records by reading past their entries.
@@ -163,9 +132,10 @@ Expected<unsigned> BitstreamCursor::skipRecord(unsigned AbbrevID) {
if (Op.getEncoding() != BitCodeAbbrevOp::Array &&
Op.getEncoding() != BitCodeAbbrevOp::Blob) {
- if (Error Err = skipAbbreviatedField(*this, Op))
- return std::move(Err);
- continue;
+ if (Expected<uint64_t> MaybeField = readAbbreviatedField(*this, Op))
+ continue;
+ else
+ return MaybeField.takeError();
}
if (Op.getEncoding() == BitCodeAbbrevOp::Array) {
More information about the llvm-commits
mailing list