1
0
mirror of https://github.com/golang/go synced 2024-11-23 01:40:03 -07:00

cmd/compile: simplify outerfn check in closureName

Since CL 523275, outerfn is always non-nil.

Change-Id: I42cfff90546e506e04a74fb4f754a25f1eadddc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/598636
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Cuong Manh Le 2024-07-17 00:55:11 +07:00 committed by Gopher Robot
parent 2e8b3425a2
commit 2edf00cf0d

View File

@ -421,7 +421,7 @@ var globClosgen int32
// closureName generates a new unique name for a closure within outerfn at pos. // closureName generates a new unique name for a closure within outerfn at pos.
func closureName(outerfn *Func, pos src.XPos, why Op) *types.Sym { func closureName(outerfn *Func, pos src.XPos, why Op) *types.Sym {
if outerfn != nil && outerfn.OClosure != nil && outerfn.OClosure.Func.RangeParent != nil { if outerfn.OClosure != nil && outerfn.OClosure.Func.RangeParent != nil {
outerfn = outerfn.OClosure.Func.RangeParent outerfn = outerfn.OClosure.Func.RangeParent
} }
pkg := types.LocalPkg pkg := types.LocalPkg
@ -431,7 +431,7 @@ func closureName(outerfn *Func, pos src.XPos, why Op) *types.Sym {
default: default:
base.FatalfAt(pos, "closureName: bad Op: %v", why) base.FatalfAt(pos, "closureName: bad Op: %v", why)
case OCLOSURE: case OCLOSURE:
if outerfn == nil || outerfn.OClosure == nil { if outerfn.OClosure == nil {
suffix = ".func" suffix = ".func"
} }
case ORANGE: case ORANGE:
@ -446,7 +446,7 @@ func closureName(outerfn *Func, pos src.XPos, why Op) *types.Sym {
// There may be multiple functions named "_". In those // There may be multiple functions named "_". In those
// cases, we can't use their individual Closgens as it // cases, we can't use their individual Closgens as it
// would lead to name clashes. // would lead to name clashes.
if outerfn != nil && !IsBlank(outerfn.Nname) { if !IsBlank(outerfn.Nname) {
pkg = outerfn.Sym().Pkg pkg = outerfn.Sym().Pkg
outer = FuncName(outerfn) outer = FuncName(outerfn)