1
0
mirror of https://github.com/golang/go synced 2024-11-17 12:54:47 -07:00

cmd/compile: fix -W=3 output after the # line

I've noticed for a while that there is some duplicated and some useful
information being put out in -W=3 mode after the comment marker (besides
the position).

dumpNodeHeader puts out a comment marker '#' before putting out the
position of a node (which is for almost all nodes). Therefore, we shouldn't
print out anything on the same line after calling dumpNodeHeader().

But we happen to be putting out a duplicate type of the node in some
cases. Also, we put out the Sym() associate with the node after
dumpNodeHeader(). So, I got rid of the duplicate type print-out, and moved
the print-out of n.Sym() to be inside dumpNodeHeader() before the
position information. Also, moved the tc flag to be right after the type
information, which seems like it makes more sense.

Change-Id: I05210fbf9f3b2d8e3b73fc0ceab26a7bce5dc104
Reviewed-on: https://go-review.googlesource.com/c/go/+/354355
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Dan Scales 2021-10-04 17:54:51 -07:00
parent 4707a6c284
commit f375844342

View File

@ -1061,8 +1061,8 @@ func dumpNodeHeader(w io.Writer, n Node) {
}
}
if n.Typecheck() != 0 {
fmt.Fprintf(w, " tc(%d)", n.Typecheck())
if n.Sym() != nil && n.Op() != ONAME && n.Op() != ONONAME && n.Op() != OTYPE {
fmt.Fprintf(w, " %+v", n.Sym())
}
// Print Node-specific fields of basic type in header line.
@ -1132,6 +1132,9 @@ func dumpNodeHeader(w io.Writer, n Node) {
}
fmt.Fprintf(w, " %+v", n.Type())
}
if n.Typecheck() != 0 {
fmt.Fprintf(w, " tc(%d)", n.Typecheck())
}
if n.Pos().IsKnown() {
fmt.Fprint(w, " # ")
@ -1248,13 +1251,6 @@ func dumpNode(w io.Writer, n Node, depth int) {
return
}
if n.Sym() != nil {
fmt.Fprintf(w, " %+v", n.Sym())
}
if n.Type() != nil {
fmt.Fprintf(w, " %+v", n.Type())
}
v := reflect.ValueOf(n).Elem()
t := reflect.TypeOf(n).Elem()
nf := t.NumField()