Change all of the bytecode reader primitives to throw exceptions instead of
returning error codes. Because they don't return an error code, they can
return the value read, which simplifies the code and makes the reader more
efficient (yaay!).
Also eliminate the special case code for little endian machines.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10871 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h
index 54a38e4..deb1206 100644
--- a/lib/Bytecode/Reader/ReaderInternals.h
+++ b/lib/Bytecode/Reader/ReaderInternals.h
@@ -214,23 +214,11 @@
typedef PlaceholderDef<ConstantPlaceHolderHelper> ConstPHolder;
-// Some common errors we find
-static const std::string Error_readvbr = "read_vbr(): error reading.";
-static const std::string Error_read = "read(): error reading.";
-static const std::string Error_inputdata = "input_data(): error reading.";
-static const std::string Error_DestSlot = "No destination slot found.";
-
static inline void readBlock(const unsigned char *&Buf,
const unsigned char *EndBuf,
unsigned &Type, unsigned &Size) {
-#ifdef DEBUG_OUTPUT
- bool Result = read(Buf, EndBuf, Type) || read(Buf, EndBuf, Size);
- std::cerr << "StartLoc = " << ((unsigned)Buf & 4095)
- << " Type = " << Type << " Size = " << Size << "\n";
- if (Result) throw Error_read;
-#else
- if (read(Buf, EndBuf, Type) || read(Buf, EndBuf, Size)) throw Error_read;
-#endif
+ Type = read(Buf, EndBuf);
+ Size = read(Buf, EndBuf);
}
} // End llvm namespace