Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Side by Side Diff: include/llvm/Bitcode/NaCl/NaClBitstreamWriter.h

Issue 1139673004: Harden writer of munged bitcode for fuzzing (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Fix issues in last patch. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 //===- NaClBitstreamWriter.h - NaCl bitstream writer ------------*- C++ -*-===// 1 //===- NaClBitstreamWriter.h - NaCl bitstream writer ------------*- C++ -*-===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This header defines the BitstreamWriter class. This class can be used to 10 // This header defines the BitstreamWriter class. This class can be used to
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 } 142 }
143 143
144 void initFromHeader(const NaClBitcodeHeader &Header) { 144 void initFromHeader(const NaClBitcodeHeader &Header) {
145 AlignBitcodeRecords = Header.getAlignBitcodeRecords(); 145 AlignBitcodeRecords = Header.getAlignBitcodeRecords();
146 } 146 }
147 147
148 /// \brief Retrieve the current position in the stream, in bits. 148 /// \brief Retrieve the current position in the stream, in bits.
149 uint64_t GetCurrentBitNo() const { return GetBufferOffset() * 8 + CurBit; } 149 uint64_t GetCurrentBitNo() const { return GetBufferOffset() * 8 + CurBit; }
150 150
151 /// \brief Returns the maximum abbreviation index allowed for the
152 /// current block.
153 size_t getMaxCurAbbrevIndex() const {
154 return CurAbbrevs.size() + naclbitc::DEFAULT_MAX_ABBREV;
155 }
156
151 //===--------------------------------------------------------------------===// 157 //===--------------------------------------------------------------------===//
152 // Basic Primitives for emitting bits to the stream. 158 // Basic Primitives for emitting bits to the stream.
153 //===--------------------------------------------------------------------===// 159 //===--------------------------------------------------------------------===//
154 160
155 void Emit(uint32_t Val, unsigned NumBits) { 161 void Emit(uint32_t Val, unsigned NumBits) {
156 assert(NumBits && NumBits <= 32 && "Invalid value size!"); 162 assert(NumBits && NumBits <= 32 && "Invalid value size!");
157 assert((Val & ~(~0U >> (32-NumBits))) == 0 && "High bits set!"); 163 assert((Val & ~(~0U >> (32-NumBits))) == 0 && "High bits set!");
158 CurValue |= Val << CurBit; 164 CurValue |= Val << CurBit;
159 if (CurBit + NumBits < 32) { 165 if (CurBit + NumBits < 32) {
160 CurBit += NumBits; 166 CurBit += NumBits;
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 Info.Abbrevs.push_back(Abbv); 531 Info.Abbrevs.push_back(Abbv);
526 532
527 return Info.Abbrevs.size()-1+naclbitc::FIRST_APPLICATION_ABBREV; 533 return Info.Abbrevs.size()-1+naclbitc::FIRST_APPLICATION_ABBREV;
528 } 534 }
529 }; 535 };
530 536
531 537
532 } // End llvm namespace 538 } // End llvm namespace
533 539
534 #endif 540 #endif
OLDNEW
« no previous file with comments | « include/llvm/Bitcode/NaCl/NaClBitcodeMunge.h ('k') | lib/Bitcode/NaCl/TestUtils/NaClBitcodeMunge.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698