]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: fix -W=3 output after the # line
authorDan Scales <danscales@google.com>
Tue, 5 Oct 2021 00:54:51 +0000 (17:54 -0700)
committerDan Scales <danscales@google.com>
Wed, 6 Oct 2021 23:19:38 +0000 (23:19 +0000)
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>
src/cmd/compile/internal/ir/fmt.go

index 29505357ccaa9325bc29c17bbc6541ac0cdc704a..033188547b61ca65c35e4d4e671db419e30e7bdb 100644 (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()