diff options
author | Matthew Dempsky <mdempsky@google.com> | 2020-12-23 05:40:11 -0800 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2020-12-23 14:09:23 +0000 |
commit | d19018e8f1970e2232b35931546ef60cdc0734d1 (patch) | |
tree | a62e5d2fe732b11be58d5005ec793eeed4dc1610 /src/cmd/compile/internal/typecheck/expr.go | |
parent | 53f082b0ee81f14d1b1a1c997e2f8e9164af37bc (diff) | |
download | go-d19018e8f1970e2232b35931546ef60cdc0734d1.tar.gz go-d19018e8f1970e2232b35931546ef60cdc0734d1.zip |
[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 <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/expr.go')
-rw-r--r-- | src/cmd/compile/internal/typecheck/expr.go | 18 |
1 files changed, 5 insertions, 13 deletions
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 } |