From f3758443424dd6e411e2ac0108efdefd2ad7b294 Mon Sep 17 00:00:00 2001 From: Dan Scales Date: Mon, 4 Oct 2021 17:54:51 -0700 Subject: [PATCH] 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 TryBot-Result: Go Bot Trust: Dan Scales Reviewed-by: Matthew Dempsky --- src/cmd/compile/internal/ir/fmt.go | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/cmd/compile/internal/ir/fmt.go b/src/cmd/compile/internal/ir/fmt.go index 29505357cc..033188547b 100644 --- a/src/cmd/compile/internal/ir/fmt.go +++ b/src/cmd/compile/internal/ir/fmt.go @@ -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()