Move the bitcode error enum to the include directory.

This will let users in other libraries know which error occurred. In particular,
it will be possible to check if the parsing failed or if the file is not
bitcode.

llvm-svn: 214209
This commit is contained in:
Rafael Espindola 2014-07-29 20:22:46 +00:00
parent 9e6e0751b3
commit c3f2e73006
3 changed files with 280 additions and 276 deletions

View File

@ -139,6 +139,38 @@ namespace llvm {
BufEnd = BufPtr+Size;
return false;
}
const std::error_category &BitcodeErrorCategory();
enum class BitcodeError {
BitcodeStreamInvalidSize,
ConflictingMETADATA_KINDRecords,
CouldNotFindFunctionInStream,
ExpectedConstant,
InsufficientFunctionProtos,
InvalidBitcodeSignature,
InvalidBitcodeWrapperHeader,
InvalidConstantReference,
InvalidID, // A read identifier is not found in the table it should be in.
InvalidInstructionWithNoBB,
InvalidRecord, // A read record doesn't have the expected size or structure
InvalidTypeForValue, // Type read OK, but is invalid for its use
InvalidTYPETable,
InvalidType, // We were unable to read a type
MalformedBlock, // We are unable to advance in the stream.
MalformedGlobalInitializerSet,
InvalidMultipleBlocks, // We found multiple blocks of a kind that should
// have only one
NeverResolvedValueFoundInFunction,
InvalidValue // Invalid version, inst number, attr number, etc
};
inline std::error_code make_error_code(BitcodeError E) {
return std::error_code(static_cast<int>(E), BitcodeErrorCategory());
}
} // End llvm namespace
namespace std {
template <> struct is_error_code_enum<llvm::BitcodeError> : std::true_type {};
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -193,35 +193,8 @@ class BitcodeReader : public GVMaterializer {
/// not need this flag.
bool UseRelativeIDs;
static const std::error_category &BitcodeErrorCategory();
public:
enum ErrorType {
BitcodeStreamInvalidSize,
ConflictingMETADATA_KINDRecords,
CouldNotFindFunctionInStream,
ExpectedConstant,
InsufficientFunctionProtos,
InvalidBitcodeSignature,
InvalidBitcodeWrapperHeader,
InvalidConstantReference,
InvalidID, // A read identifier is not found in the table it should be in.
InvalidInstructionWithNoBB,
InvalidRecord, // A read record doesn't have the expected size or structure
InvalidTypeForValue, // Type read OK, but is invalid for its use
InvalidTYPETable,
InvalidType, // We were unable to read a type
MalformedBlock, // We are unable to advance in the stream.
MalformedGlobalInitializerSet,
InvalidMultipleBlocks, // We found multiple blocks of a kind that should
// have only one
NeverResolvedValueFoundInFunction,
InvalidValue // Invalid version, inst number, attr number, etc
};
std::error_code Error(ErrorType E) {
return std::error_code(E, BitcodeErrorCategory());
}
std::error_code Error(BitcodeError E) { return make_error_code(E); }
explicit BitcodeReader(MemoryBuffer *buffer, LLVMContext &C)
: Context(C), TheModule(nullptr), Buffer(buffer), LazyStreamer(nullptr),