llvm.org GIT mirror llvm / 251da88
Fix left shifts by too large exponents in MCParser (which happened only on error recovery path). This bug was reported by UBSan. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216915 91177308-0d34-0410-b5e6-96231b3b80d8 Alexey Samsonov 6 years ago
1 changed file(s) with 8 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
26002600 if (!isUInt<32>(FillExpr) && FillSize > 4)
26012601 Warning(ExprLoc, "'.fill' directive pattern has been truncated to 32-bits");
26022602
2603 int64_t NonZeroFillSize = FillSize > 4 ? 4 : FillSize;
2604 FillExpr &= ~0ULL >> (64 - NonZeroFillSize * 8);
2605
2606 for (uint64_t i = 0, e = NumValues; i != e; ++i) {
2607 getStreamer().EmitIntValue(FillExpr, NonZeroFillSize);
2608 if (NonZeroFillSize < FillSize)
2609 getStreamer().EmitIntValue(0, FillSize - NonZeroFillSize);
2603 if (NumValues > 0) {
2604 int64_t NonZeroFillSize = FillSize > 4 ? 4 : FillSize;
2605 FillExpr &= ~0ULL >> (64 - NonZeroFillSize * 8);
2606 for (uint64_t i = 0, e = NumValues; i != e; ++i) {
2607 getStreamer().EmitIntValue(FillExpr, NonZeroFillSize);
2608 if (NonZeroFillSize < FillSize)
2609 getStreamer().EmitIntValue(0, FillSize - NonZeroFillSize);
2610 }
26102611 }
26112612
26122613 return false;