[llvm] r214218 - Have a single enum for "not a bitcode" error.
Rafael Espindola
rafael.espindola at gmail.com
Tue Jul 29 14:01:24 PDT 2014
Author: rafael
Date: Tue Jul 29 16:01:24 2014
New Revision: 214218
URL: http://llvm.org/viewvc/llvm-project?rev=214218&view=rev
Log:
Have a single enum for "not a bitcode" error.
This is more convenient for callers. No functionality change, this will
be used in a next patch to the gold plugin.
Modified:
llvm/trunk/include/llvm/Bitcode/ReaderWriter.h
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
Modified: llvm/trunk/include/llvm/Bitcode/ReaderWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/ReaderWriter.h?rev=214218&r1=214217&r2=214218&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Bitcode/ReaderWriter.h (original)
+++ llvm/trunk/include/llvm/Bitcode/ReaderWriter.h Tue Jul 29 16:01:24 2014
@@ -142,7 +142,6 @@ namespace llvm {
const std::error_category &BitcodeErrorCategory();
enum class BitcodeError {
- BitcodeStreamInvalidSize,
ConflictingMETADATA_KINDRecords,
CouldNotFindFunctionInStream,
ExpectedConstant,
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=214218&r1=214217&r2=214218&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Tue Jul 29 16:01:24 2014
@@ -3350,12 +3350,8 @@ std::error_code BitcodeReader::InitStrea
const unsigned char *BufPtr = (const unsigned char*)Buffer->getBufferStart();
const unsigned char *BufEnd = BufPtr+Buffer->getBufferSize();
- if (Buffer->getBufferSize() & 3) {
- if (!isRawBitcode(BufPtr, BufEnd) && !isBitcodeWrapper(BufPtr, BufEnd))
- return Error(BitcodeError::InvalidBitcodeSignature);
- else
- return Error(BitcodeError::BitcodeStreamInvalidSize);
- }
+ if (Buffer->getBufferSize() & 3)
+ return Error(BitcodeError::InvalidBitcodeSignature);
// If we have a wrapper header, parse it and ignore the non-bc file contents.
// The magic number is 0x0B17C0DE stored in little endian.
@@ -3378,7 +3374,7 @@ std::error_code BitcodeReader::InitLazyS
unsigned char buf[16];
if (Bytes->readBytes(0, 16, buf) == -1)
- return Error(BitcodeError::BitcodeStreamInvalidSize);
+ return Error(BitcodeError::InvalidBitcodeSignature);
if (!isBitcode(buf, buf + 16))
return Error(BitcodeError::InvalidBitcodeSignature);
@@ -3401,8 +3397,6 @@ class BitcodeErrorCategoryType : public
std::string message(int IE) const override {
BitcodeError E = static_cast<BitcodeError>(IE);
switch (E) {
- case BitcodeError::BitcodeStreamInvalidSize:
- return "Bitcode stream length should be >= 16 bytes and a multiple of 4";
case BitcodeError::ConflictingMETADATA_KINDRecords:
return "Conflicting METADATA_KIND records";
case BitcodeError::CouldNotFindFunctionInStream:
More information about the llvm-commits
mailing list