cgen: generate 123u (instead of 123) even more

This commit is contained in:
Nigel Tao committed 2023-06-04 22:09:19 +10:00
1 parent 677a1c5b8e
commit 9c3ca6257d
3 files changed
+4742 -4758

No files matched your search

-2
View File
@@ -40,8 +40,6 @@ var (
mibi = big.NewInt(1 << 20)
maxInt64 = big.NewInt((1 << 63) - 1)
maxUint8 = big.NewInt((1 << 8) - 1)
maxUint16 = big.NewInt((1 << 16) - 1)
maxUint32 = big.NewInt((1 << 32) - 1)
+1 -15
View File
@@ -32,22 +32,8 @@ func (g *gen) writeExpr(b *buffer, n *a.Expr, sideEffectsOnly bool, depth uint32
if cv := n.ConstValue(); cv != nil {
if typ := n.MType(); typ.IsNumTypeOrIdeal() {
b.writes(cv.String())
if cv.Sign() < 0 {
// No-op.
} else if cv.Cmp(maxInt64) > 0 {
if cv.Sign() >= 0 {
b.writeb('u')
} else {
// Appending a 'u' is currently targeted to only those
// constants used by std/jpeg/decode_idct_default.wuffs
//
// TODO: don't be so shy about it. It's narrow for now, to make
// only the smallest generated-code change that fixes
// https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=59018
// but we should generate 123u instead of 123 more broadly.
const minIncl = 0xFFFFADFD
if i := cv.Int64(); minIncl <= i {
b.writeb('u')
}
}
} else if typ.IsNullptr() {
b.writes("NULL")