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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214218 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2014-07-29 21:01:24 +00:00
parent 8b891ea63e
commit 63252a0aa3
2 changed files with 3 additions and 10 deletions

View File

@ -142,7 +142,6 @@ namespace llvm {
const std::error_category &BitcodeErrorCategory(); const std::error_category &BitcodeErrorCategory();
enum class BitcodeError { enum class BitcodeError {
BitcodeStreamInvalidSize,
ConflictingMETADATA_KINDRecords, ConflictingMETADATA_KINDRecords,
CouldNotFindFunctionInStream, CouldNotFindFunctionInStream,
ExpectedConstant, ExpectedConstant,

View File

@ -3350,12 +3350,8 @@ std::error_code BitcodeReader::InitStreamFromBuffer() {
const unsigned char *BufPtr = (const unsigned char*)Buffer->getBufferStart(); const unsigned char *BufPtr = (const unsigned char*)Buffer->getBufferStart();
const unsigned char *BufEnd = BufPtr+Buffer->getBufferSize(); const unsigned char *BufEnd = BufPtr+Buffer->getBufferSize();
if (Buffer->getBufferSize() & 3) { if (Buffer->getBufferSize() & 3)
if (!isRawBitcode(BufPtr, BufEnd) && !isBitcodeWrapper(BufPtr, BufEnd)) return Error(BitcodeError::InvalidBitcodeSignature);
return Error(BitcodeError::InvalidBitcodeSignature);
else
return Error(BitcodeError::BitcodeStreamInvalidSize);
}
// If we have a wrapper header, parse it and ignore the non-bc file contents. // If we have a wrapper header, parse it and ignore the non-bc file contents.
// The magic number is 0x0B17C0DE stored in little endian. // The magic number is 0x0B17C0DE stored in little endian.
@ -3378,7 +3374,7 @@ std::error_code BitcodeReader::InitLazyStream() {
unsigned char buf[16]; unsigned char buf[16];
if (Bytes->readBytes(0, 16, buf) == -1) if (Bytes->readBytes(0, 16, buf) == -1)
return Error(BitcodeError::BitcodeStreamInvalidSize); return Error(BitcodeError::InvalidBitcodeSignature);
if (!isBitcode(buf, buf + 16)) if (!isBitcode(buf, buf + 16))
return Error(BitcodeError::InvalidBitcodeSignature); return Error(BitcodeError::InvalidBitcodeSignature);
@ -3401,8 +3397,6 @@ class BitcodeErrorCategoryType : public std::error_category {
std::string message(int IE) const override { std::string message(int IE) const override {
BitcodeError E = static_cast<BitcodeError>(IE); BitcodeError E = static_cast<BitcodeError>(IE);
switch (E) { switch (E) {
case BitcodeError::BitcodeStreamInvalidSize:
return "Bitcode stream length should be >= 16 bytes and a multiple of 4";
case BitcodeError::ConflictingMETADATA_KINDRecords: case BitcodeError::ConflictingMETADATA_KINDRecords:
return "Conflicting METADATA_KIND records"; return "Conflicting METADATA_KIND records";
case BitcodeError::CouldNotFindFunctionInStream: case BitcodeError::CouldNotFindFunctionInStream: