mirror of
https://github.com/golang/go
synced 2024-11-26 17:07:09 -07:00
cmd/compile: add types.RecalcSize
This is the only case where Align is assigned outside of package types. Rather than adding a SetAlign method, adding a RecalcSize function is a bit more descriptive. Change-Id: I1b3c01ebd0e41183665baa63c926592865bbbd0b Reviewed-on: https://go-review.googlesource.com/c/go/+/345479 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
e7eee5e265
commit
62f88b6dc8
@ -37,8 +37,7 @@ func (g *irgen) funcBody(fn *ir.Func, recv *syntax.Field, sig *syntax.FuncType,
|
|||||||
// calculated its size, including parameter offsets. Now that we've
|
// calculated its size, including parameter offsets. Now that we've
|
||||||
// created the parameter Names, force a recalculation to ensure
|
// created the parameter Names, force a recalculation to ensure
|
||||||
// their offsets are correct.
|
// their offsets are correct.
|
||||||
typ.Align = 0
|
types.RecalcSize(typ)
|
||||||
types.CalcSize(typ)
|
|
||||||
|
|
||||||
if block != nil {
|
if block != nil {
|
||||||
typecheck.DeclContext = ir.PAUTO
|
typecheck.DeclContext = ir.PAUTO
|
||||||
|
@ -562,6 +562,14 @@ func CalcStructSize(s *Type) {
|
|||||||
s.Width = calcStructOffset(s, s, 0, 1) // sets align
|
s.Width = calcStructOffset(s, s, 0, 1) // sets align
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// RecalcSize is like CalcSize, but recalculates t's size even if it
|
||||||
|
// has already been calculated before. It does not recalculate other
|
||||||
|
// types.
|
||||||
|
func RecalcSize(t *Type) {
|
||||||
|
t.Align = 0
|
||||||
|
CalcSize(t)
|
||||||
|
}
|
||||||
|
|
||||||
// when a type's width should be known, we call CheckSize
|
// when a type's width should be known, we call CheckSize
|
||||||
// to compute it. during a declaration like
|
// to compute it. during a declaration like
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user