llvm.org GIT mirror llvm / 913837d
Bitcode: Fix more unsigned integer overflow bugs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251464 91177308-0d34-0410-b5e6-96231b3b80d8 Peter Collingbourne 4 years ago
2 changed file(s) with 10 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
4646
4747 struct Block {
4848 unsigned PrevCodeSize;
49 unsigned StartSizeWord;
49 size_t StartSizeWord;
5050 std::vector> PrevAbbrevs;
51 Block(unsigned PCS, unsigned SSW) : PrevCodeSize(PCS), StartSizeWord(SSW) {}
51 Block(unsigned PCS, size_t SSW) : PrevCodeSize(PCS), StartSizeWord(SSW) {}
5252 };
5353
5454 /// BlockScope - This tracks the current blocks that we have entered.
7272 reinterpret_cast(&Value + 1));
7373 }
7474
75 unsigned GetBufferOffset() const {
75 size_t GetBufferOffset() const {
7676 return Out.size();
7777 }
7878
79 unsigned GetWordIndex() const {
80 unsigned Offset = GetBufferOffset();
79 size_t GetWordIndex() const {
80 size_t Offset = GetBufferOffset();
8181 assert((Offset & 3) == 0 && "Not 32-bit aligned");
8282 return Offset / 4;
8383 }
210210 EmitVBR(CodeLen, bitc::CodeLenWidth);
211211 FlushToWord();
212212
213 unsigned BlockSizeWordIndex = GetWordIndex();
213 size_t BlockSizeWordIndex = GetWordIndex();
214214 unsigned OldCodeSize = CurCodeSize;
215215
216216 // Emit a placeholder, which will be replaced when the block is popped.
241241 FlushToWord();
242242
243243 // Compute the size of the block, in words, not counting the size field.
244 unsigned SizeInWords = GetWordIndex() - B.StartSizeWord - 1;
244 size_t SizeInWords = GetWordIndex() - B.StartSizeWord - 1;
245245 uint64_t BitNo = uint64_t(B.StartSizeWord) * 32;
246246
247247 // Update the block size field in the header of this sub-block.
150150 // Last function offset found in the VST.
151151 uint64_t LastFunctionBlockBit = 0;
152152 bool SeenValueSymbolTable = false;
153 unsigned VSTOffset = 0;
153 uint64_t VSTOffset = 0;
154154 // Contains an arbitrary and optional string identifying the bitcode producer
155155 std::string ProducerIdentification;
156156
387387
388388 ErrorOr recordValue(SmallVectorImpl &Record,
389389 unsigned NameIndex, Triple &TT);
390 std::error_code parseValueSymbolTable(unsigned Offset = 0);
390 std::error_code parseValueSymbolTable(uint64_t Offset = 0);
391391 std::error_code parseConstants();
392392 std::error_code rememberAndSkipFunctionBodies();
393393 std::error_code rememberAndSkipFunctionBody();
17631763
17641764 /// Parse the value symbol table at either the current parsing location or
17651765 /// at the given bit offset if provided.
1766 std::error_code BitcodeReader::parseValueSymbolTable(unsigned Offset) {
1766 std::error_code BitcodeReader::parseValueSymbolTable(uint64_t Offset) {
17671767 uint64_t CurrentBit;
17681768 // Pass in the Offset to distinguish between calling for the module-level
17691769 // VST (where we want to jump to the VST offset) and the function-level