aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2022-02-04 17:13:02 +0100
committerNikita Popov <npopov@redhat.com>2022-02-04 17:14:45 +0100
commitf392e9d264cf2ceb446cf2251d4b3a1ab95e1f65 (patch)
tree9076b20c32c98c8237c8ecdcfbcb49b8ac43cab5 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent85243124cf7ab25df3dec14f802f6eca9cf68b39 (diff)
downloadllvm-f392e9d264cf2ceb446cf2251d4b3a1ab95e1f65.zip
llvm-f392e9d264cf2ceb446cf2251d4b3a1ab95e1f65.tar.gz
llvm-f392e9d264cf2ceb446cf2251d4b3a1ab95e1f65.tar.bz2
[BitcodeReader] Resolve error handling todo
If possible, forward the inner error instead of creating a new one.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 720ab56..51159c6 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -429,7 +429,7 @@ protected:
std::pair<StringRef, ArrayRef<uint64_t>>
readNameFromStrtab(ArrayRef<uint64_t> Record);
- bool readBlockInfo();
+ Error readBlockInfo();
// Contains an arbitrary and optional string identifying the bitcode producer
std::string ProducerIdentification;
@@ -3211,17 +3211,17 @@ Error BitcodeReader::rememberAndSkipFunctionBodies() {
}
}
-bool BitcodeReaderBase::readBlockInfo() {
+Error BitcodeReaderBase::readBlockInfo() {
Expected<Optional<BitstreamBlockInfo>> MaybeNewBlockInfo =
Stream.ReadBlockInfoBlock();
if (!MaybeNewBlockInfo)
- return true; // FIXME Handle the error.
+ return MaybeNewBlockInfo.takeError();
Optional<BitstreamBlockInfo> NewBlockInfo =
std::move(MaybeNewBlockInfo.get());
if (!NewBlockInfo)
- return true;
+ return error("Malformed block");
BlockInfo = std::move(*NewBlockInfo);
- return false;
+ return Error::success();
}
Error BitcodeReader::parseComdatRecord(ArrayRef<uint64_t> Record) {
@@ -3639,8 +3639,8 @@ Error BitcodeReader::parseModule(uint64_t ResumeBit,
return Err;
break;
case bitc::BLOCKINFO_BLOCK_ID:
- if (readBlockInfo())
- return error("Malformed block");
+ if (Error Err = readBlockInfo())
+ return Err;
break;
case bitc::PARAMATTR_BLOCK_ID:
if (Error Err = parseAttributeBlock())
@@ -5913,8 +5913,8 @@ Error ModuleSummaryIndexBitcodeReader::parseModule() {
break;
case bitc::BLOCKINFO_BLOCK_ID:
// Need to parse these to get abbrev ids (e.g. for VST)
- if (readBlockInfo())
- return error("Malformed block");
+ if (Error Err = readBlockInfo())
+ return Err;
break;
case bitc::VALUE_SYMTAB_BLOCK_ID:
// Should have been parsed earlier via VSTOffset, unless there