[dev.regabi] cmd/compile/internal/types: add pos/sym/typ params to NewField

These are almost always set, so might as well expect callers to
provide them. They're also all required by go/types's corresponding
New{Field,Func,Param,Var} functions, so this eases API compatibility.

Passes toolstash-check.

Change-Id: Ib3fa355d4961243cd285b41915e87652ae2c22f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/272386
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Matthew Dempsky 2020-11-23 00:15:40 -08:00
parent 762eda346a
commit e1047302bd
7 changed files with 37 additions and 82 deletions

View file

@ -73,10 +73,8 @@ func uncommonSize(t *types.Type) int { // Sizeof(runtime.uncommontype{})
}
func makefield(name string, t *types.Type) *types.Field {
f := types.NewField()
f.Type = t
f.Sym = (*types.Pkg)(nil).Lookup(name)
return f
sym := (*types.Pkg)(nil).Lookup(name)
return types.NewField(src.NoXPos, sym, t)
}
// bmap makes the map bucket type given the type of the map.
@ -301,13 +299,11 @@ func hiter(t *types.Type) *types.Type {
// stksize bytes of args.
func deferstruct(stksize int64) *types.Type {
makefield := func(name string, typ *types.Type) *types.Field {
f := types.NewField()
f.Type = typ
// Unlike the global makefield function, this one needs to set Pkg
// because these types might be compared (in SSA CSE sorting).
// TODO: unify this makefield and the global one above.
f.Sym = &types.Sym{Name: name, Pkg: localpkg}
return f
sym := &types.Sym{Name: name, Pkg: localpkg}
return types.NewField(src.NoXPos, sym, typ)
}
argtype := types.NewArray(types.Types[TUINT8], stksize)
argtype.Width = stksize