mirror of
https://github.com/golang/go
synced 2024-11-22 22:30:02 -07:00
[dev.regabi] cmd/compile: fix ICE during ir.Dump
fmt.go:dumpNodeHeader uses reflection to call all "func() bool"-typed methods on Nodes during printing, but the OnStack method that I added in CL 283233 isn't meant to be called on non-variables. dumpNodeHeader does already guard against panics, as happen in some other accessors, but not against Fatalf, as I was using in OnStack. So simply change OnStack to use panic too. Thanks to drchase@ for the report. Change-Id: I0cfac84a96292193401a32fc5e7fd3c48773e008 Reviewed-on: https://go-review.googlesource.com/c/go/+/284074 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
parent
35b9c66601
commit
4be7af23f9
@ -286,19 +286,18 @@ func (n *Name) SetLibfuzzerExtraCounter(b bool) { n.flags.set(nameLibfuzzerExtra
|
||||
|
||||
// OnStack reports whether variable n may reside on the stack.
|
||||
func (n *Name) OnStack() bool {
|
||||
if n.Op() != ONAME || n.Class == PFUNC {
|
||||
base.Fatalf("%v is not a variable", n)
|
||||
}
|
||||
if n.Op() == ONAME {
|
||||
switch n.Class {
|
||||
case PPARAM, PPARAMOUT, PAUTO:
|
||||
return n.Esc() != EscHeap
|
||||
case PEXTERN, PAUTOHEAP:
|
||||
return false
|
||||
default:
|
||||
base.FatalfAt(n.Pos(), "%v has unknown class %v", n, n.Class)
|
||||
panic("unreachable")
|
||||
}
|
||||
}
|
||||
// Note: fmt.go:dumpNodeHeader calls all "func() bool"-typed
|
||||
// methods, but it can only recover from panics, not Fatalf.
|
||||
panic(fmt.Sprintf("%v: not a variable: %v", base.FmtPos(n.Pos()), n))
|
||||
}
|
||||
|
||||
// MarkReadonly indicates that n is an ONAME with readonly contents.
|
||||
func (n *Name) MarkReadonly() {
|
||||
|
Loading…
Reference in New Issue
Block a user