llvm.org GIT mirror llvm / c62a4b0
don't emit zero bit fields with Emit, fixing undefined behavior, PR7778 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111336 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 10 years ago
1 changed file(s) with 5 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
8787 //===--------------------------------------------------------------------===//
8888
8989 void Emit(uint32_t Val, unsigned NumBits) {
90 assert(NumBits <= 32 && "Invalid value size!");
90 assert(NumBits && NumBits <= 32 && "Invalid value size!");
9191 assert((Val & ~(~0U >> (32-NumBits))) == 0 && "High bits set!");
9292 CurValue |= Val << CurBit;
9393 if (CurBit + NumBits < 32) {
276276 switch (Op.getEncoding()) {
277277 default: assert(0 && "Unknown encoding!");
278278 case BitCodeAbbrevOp::Fixed:
279 Emit((unsigned)V, (unsigned)Op.getEncodingData());
279 if (Op.getEncodingData())
280 Emit((unsigned)V, (unsigned)Op.getEncodingData());
280281 break;
281282 case BitCodeAbbrevOp::VBR:
282 EmitVBR64(V, (unsigned)Op.getEncodingData());
283 if (Op.getEncodingData())
284 EmitVBR64(V, (unsigned)Op.getEncodingData());
283285 break;
284286 case BitCodeAbbrevOp::Char6:
285287 Emit(BitCodeAbbrevOp::EncodeChar6((char)V), 6);