]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile/internal/ir: more position details in dump
authorMatthew Dempsky <mdempsky@google.com>
Tue, 18 May 2021 23:34:44 +0000 (16:34 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 19 May 2021 06:33:22 +0000 (06:33 +0000)
When dumping node positions, include column position and the full
inlining tree. These details are helpful for diagnosing "toolstash
-cmp" failures due to subtly changing positions.

Change-Id: I953292d6c01899fd98e2f315bafaa123c4d98ffd
Reviewed-on: https://go-review.googlesource.com/c/go/+/321089
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
src/cmd/compile/internal/ir/fmt.go

index f2ae0f7606ee7ba04d8b219f1330de8ecf18a121..4ac5f3fea294b95e1cb2790e30dbc78e06114316 100644 (file)
@@ -1114,16 +1114,21 @@ func dumpNodeHeader(w io.Writer, n Node) {
        }
 
        if n.Pos().IsKnown() {
-               pfx := ""
+               fmt.Fprint(w, " # ")
                switch n.Pos().IsStmt() {
                case src.PosNotStmt:
-                       pfx = "_" // "-" would be confusing
+                       fmt.Fprint(w, "_") // "-" would be confusing
                case src.PosIsStmt:
-                       pfx = "+"
+                       fmt.Fprint(w, "+")
+               }
+               for i, pos := range base.Ctxt.AllPos(n.Pos(), nil) {
+                       if i > 0 {
+                               fmt.Fprint(w, ",")
+                       }
+                       // TODO(mdempsky): Print line pragma details too.
+                       file := filepath.Base(pos.Filename())
+                       fmt.Fprintf(w, "%s:%d:%d", file, pos.Line(), pos.Col())
                }
-               pos := base.Ctxt.PosTable.Pos(n.Pos())
-               file := filepath.Base(pos.Filename())
-               fmt.Fprintf(w, " # %s%s:%d", pfx, file, pos.Line())
        }
 }