mirror of
https://github.com/golang/go
synced 2024-09-29 14:14:29 -06:00
[dev.regabi] cmd/compile: simplify dwarfgen.declPos
The previous code was way overcomplicating things. To find out if a variable is a closure pseudo-variable, one only needs to check IsClosureVar. Checking Captured and Byval are only meant to be used by closure conversion. Passes toolstash -cmp. Change-Id: I22622cba36ba7f60b3275d17999a8b6bb7c6719a Reviewed-on: https://go-review.googlesource.com/c/go/+/280995 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
9ed1577779
commit
7d55669847
@ -127,22 +127,8 @@ func Info(fnsym *obj.LSym, infosym *obj.LSym, curfn interface{}) ([]dwarf.Scope,
|
||||
}
|
||||
|
||||
func declPos(decl *ir.Name) src.XPos {
|
||||
if decl.Defn != nil && (decl.Captured() || decl.Byval()) {
|
||||
// It's not clear which position is correct for captured variables here:
|
||||
// * decl.Pos is the wrong position for captured variables, in the inner
|
||||
// function, but it is the right position in the outer function.
|
||||
// * decl.Name.Defn is nil for captured variables that were arguments
|
||||
// on the outer function, however the decl.Pos for those seems to be
|
||||
// correct.
|
||||
// * decl.Name.Defn is the "wrong" thing for variables declared in the
|
||||
// header of a type switch, it's their position in the header, rather
|
||||
// than the position of the case statement. In principle this is the
|
||||
// right thing, but here we prefer the latter because it makes each
|
||||
// instance of the header variable local to the lexical block of its
|
||||
// case statement.
|
||||
// This code is probably wrong for type switch variables that are also
|
||||
// captured.
|
||||
return decl.Defn.Pos()
|
||||
if decl.IsClosureVar() {
|
||||
decl = decl.Defn.(*ir.Name)
|
||||
}
|
||||
return decl.Pos()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user