llvm.org GIT mirror llvm / 9ec471a
Don't allow MCStreamer::EmitIntValue to output 0-byte integers. It makes no sense and can hide bugs. In particular, it lead to left shift by 64 bits, which is an undefined behavior, properly reported by UBSan. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216134 91177308-0d34-0410-b5e6-96231b3b80d8 Alexey Samsonov 6 years ago
2 changed file(s) with 3 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
26112611
26122612 for (uint64_t i = 0, e = NumValues; i != e; ++i) {
26132613 getStreamer().EmitIntValue(FillExpr, NonZeroFillSize);
2614 getStreamer().EmitIntValue(0, FillSize - NonZeroFillSize);
2614 if (NonZeroFillSize < FillSize)
2615 getStreamer().EmitIntValue(0, FillSize - NonZeroFillSize);
26152616 }
26162617
26172618 return false;
7171 /// EmitIntValue - Special case of EmitValue that avoids the client having to
7272 /// pass in a MCExpr for constant integers.
7373 void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size) {
74 assert(Size <= 8 && "Invalid size");
74 assert(1 <= Size && Size <= 8 && "Invalid size");
7575 assert((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) &&
7676 "Invalid size");
7777 char buf[8];