aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Bitcode
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2013-02-09 07:07:29 +0000
committerChris Lattner <sabre@nondot.org>2013-02-09 07:07:29 +0000
commitb24f5b7c0838f22abc6f1ba5de2a17d25293cd17 (patch)
tree99411c5a206f3b0dd2171225813672990b30cd3e /include/llvm/Bitcode
parente001f27e5ebc325b5b142f3661d04ba39251e07b (diff)
downloadexternal_llvm-b24f5b7c0838f22abc6f1ba5de2a17d25293cd17.zip
external_llvm-b24f5b7c0838f22abc6f1ba5de2a17d25293cd17.tar.gz
external_llvm-b24f5b7c0838f22abc6f1ba5de2a17d25293cd17.tar.bz2
Fix the underlying problem that was causing read(0) to be called: sometimes the
bitcode writer would generate abbrev records saying that the abbrev should be filled with fixed zero-bit bitfields (this happens in the .bc writer when the number of types used in a module is exactly one, since log2(1) == 0). In this case, just handle it as a literal zero. We can't "just fix" the writer without breaking compatibility with existing bc files, so have the abbrev reader do the substitution. Strengthen the assert in read to reject reads of zero bits so we catch such crimes in the future, and remove the special case designed to handle this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174801 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Bitcode')
-rw-r--r--include/llvm/Bitcode/BitstreamReader.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/llvm/Bitcode/BitstreamReader.h b/include/llvm/Bitcode/BitstreamReader.h
index 1b29c3e..56a6108 100644
--- a/include/llvm/Bitcode/BitstreamReader.h
+++ b/include/llvm/Bitcode/BitstreamReader.h
@@ -343,8 +343,8 @@ public:
uint32_t Read(unsigned NumBits) {
- assert(NumBits <= 32 && "Cannot return more than 32 bits!");
- if (NumBits == 0) return 0;
+ assert(NumBits && NumBits <= 32 &&
+ "Cannot return zero or more than 32 bits!");
// If the field is fully contained by CurWord, return it quickly.
if (BitsInCurWord >= NumBits) {