summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2020-10-20 15:03:33 -0700
committerDan Scales <danscales@google.com>2020-10-20 23:37:53 +0000
commitf121e0eddd64aa0084b916e94c9a540edf859539 (patch)
tree403691327a0fe0573cfaf18421d58d1ef6d77449
parent3ca3ca51d70aac890fb023786db1fcbbeea139f1 (diff)
downloadgo-git-f121e0eddd64aa0084b916e94c9a540edf859539.tar.gz
cmd/compile: fix nodedump output for types of nodes
The Dbg dumping of complex types was broken, because (I think) of a recent change to handle recursive types correctly. Before this fix, the Dump output of a closure node (where the last thing on the line is the type of the node) was: . . CLOSURE l(8) esc(h) tc(1) FUNC-@0 after this change it is: . . CLOSURE l(8) esc(h) tc(1) FUNC-func(int) int The problem is that that the 'mode == Fdbg' code was immediately aborting the descent into tconv2, since it was calling down with the same node that was just entered into the hash table. Change-Id: Iee106b967cea1856dd92d4350681401dd34a23b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/264025 Trust: Dan Scales <danscales@google.com> Reviewed-by: Keith Randall <khr@golang.org>
-rw-r--r--src/cmd/compile/internal/gc/fmt.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/gc/fmt.go b/src/cmd/compile/internal/gc/fmt.go
index 9ba1789633..d7ed1d2ff0 100644
--- a/src/cmd/compile/internal/gc/fmt.go
+++ b/src/cmd/compile/internal/gc/fmt.go
@@ -792,6 +792,13 @@ func tconv2(b *bytes.Buffer, t *types.Type, flag FmtFlag, mode fmtMode, visited
return
}
+ if mode == FDbg {
+ b.WriteString(t.Etype.String())
+ b.WriteByte('-')
+ tconv2(b, t, flag, FErr, visited)
+ return
+ }
+
// At this point, we might call tconv2 recursively. Add the current type to the visited list so we don't
// try to print it recursively.
// We record the offset in the result buffer where the type's text starts. This offset serves as a reference
@@ -805,12 +812,6 @@ func tconv2(b *bytes.Buffer, t *types.Type, flag FmtFlag, mode fmtMode, visited
visited[t] = b.Len()
defer delete(visited, t)
- if mode == FDbg {
- b.WriteString(t.Etype.String())
- b.WriteByte('-')
- tconv2(b, t, flag, FErr, visited)
- return
- }
switch t.Etype {
case TPTR:
b.WriteByte('*')