aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/ir
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-05-18 16:34:44 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-05-19 06:33:22 +0000
commitc2966ae272b7ddd44ee6f93beb32da925e8336df (patch)
treeb7f182c34fda4c5e3bda16ddd78c4e418b917e60 /src/cmd/compile/internal/ir
parentfb79f6955e8d13fd6c98f6bd036819d7cc6dfad6 (diff)
downloadgo-c2966ae272b7ddd44ee6f93beb32da925e8336df.tar.gz
go-c2966ae272b7ddd44ee6f93beb32da925e8336df.zip
[dev.typeparams] cmd/compile/internal/ir: more position details in dump
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>
Diffstat (limited to 'src/cmd/compile/internal/ir')
-rw-r--r--src/cmd/compile/internal/ir/fmt.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/ir/fmt.go b/src/cmd/compile/internal/ir/fmt.go
index f2ae0f7606..4ac5f3fea2 100644
--- a/src/cmd/compile/internal/ir/fmt.go
+++ b/src/cmd/compile/internal/ir/fmt.go
@@ -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())
}
}