From d19018e8f1970e2232b35931546ef60cdc0734d1 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Wed, 23 Dec 2020 05:40:11 -0800 Subject: [dev.regabi] cmd/compile: split SliceHeaderExpr.LenCap into separate fields Passes toolstash -cmp. Change-Id: Ifc98a408c154a05997963e2c731466842ebbf50e Reviewed-on: https://go-review.googlesource.com/c/go/+/279958 Run-TryBot: Matthew Dempsky TryBot-Result: Go Bot Trust: Matthew Dempsky Reviewed-by: Cuong Manh Le --- src/cmd/compile/internal/typecheck/expr.go | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src/cmd/compile/internal/typecheck/expr.go') diff --git a/src/cmd/compile/internal/typecheck/expr.go b/src/cmd/compile/internal/typecheck/expr.go index f940a2e73d..00615c506c 100644 --- a/src/cmd/compile/internal/typecheck/expr.go +++ b/src/cmd/compile/internal/typecheck/expr.go @@ -924,30 +924,22 @@ func tcSliceHeader(n *ir.SliceHeaderExpr) ir.Node { base.Fatalf("need unsafe.Pointer for OSLICEHEADER") } - if x := len(n.LenCap); x != 2 { - base.Fatalf("expected 2 params (len, cap) for OSLICEHEADER, got %d", x) - } - n.Ptr = Expr(n.Ptr) - l := Expr(n.LenCap[0]) - c := Expr(n.LenCap[1]) - l = DefaultLit(l, types.Types[types.TINT]) - c = DefaultLit(c, types.Types[types.TINT]) + n.Len = DefaultLit(Expr(n.Len), types.Types[types.TINT]) + n.Cap = DefaultLit(Expr(n.Cap), types.Types[types.TINT]) - if ir.IsConst(l, constant.Int) && ir.Int64Val(l) < 0 { + if ir.IsConst(n.Len, constant.Int) && ir.Int64Val(n.Len) < 0 { base.Fatalf("len for OSLICEHEADER must be non-negative") } - if ir.IsConst(c, constant.Int) && ir.Int64Val(c) < 0 { + if ir.IsConst(n.Cap, constant.Int) && ir.Int64Val(n.Cap) < 0 { base.Fatalf("cap for OSLICEHEADER must be non-negative") } - if ir.IsConst(l, constant.Int) && ir.IsConst(c, constant.Int) && constant.Compare(l.Val(), token.GTR, c.Val()) { + if ir.IsConst(n.Len, constant.Int) && ir.IsConst(n.Cap, constant.Int) && constant.Compare(n.Len.Val(), token.GTR, n.Cap.Val()) { base.Fatalf("len larger than cap for OSLICEHEADER") } - n.LenCap[0] = l - n.LenCap[1] = c return n } -- cgit v1.2.3-54-g00ecf