]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.regabi] cmd/compile: change ir.DoChildren to use bool result type
authorMatthew Dempsky <mdempsky@google.com>
Wed, 30 Dec 2020 03:46:31 +0000 (19:46 -0800)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 30 Dec 2020 04:24:02 +0000 (04:24 +0000)
commitf9b67f76a59cb9adf5d04e9b559cda98afb3c6f4
tree1a7cda5af5f4a0a240731e47dbeab510f26f6277
parent499851bac88dfa2a85c39a2123f092071098cada
[dev.regabi] cmd/compile: change ir.DoChildren to use bool result type

After using the IR visitor code for a bit, it seems clear that a
simple boolean result type is adequate for tree traversals. This CL
updates ir.DoChildren to use the same calling convention as ir.Any,
and updates mknode.go to generate code accordingly.

There were only two places where the error-based DoChildren API was
used within the compiler:

1. Within typechecking, marking statements that contain "break". This
code never returns errors anyway, so it's trivially updated to return
false instead.

2. Within inlining, the "hairy visitor" actually does make use of
returning errors. However, it threads through a reference to the
hairyVisitor anyway, where it would be trivial to store any needed
information instead. For the purpose of this CL, we provide
"errChildren" and "errList" helper functions that provide the previous
error-based semantics on top of the new bool-based API.

Passes toolstash -cmp.

Change-Id: I4bac9a697b4dbfb5f66eeac37d4a2ced2073d7d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/280675
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
src/cmd/compile/internal/inline/inl.go
src/cmd/compile/internal/ir/func.go
src/cmd/compile/internal/ir/mknode.go
src/cmd/compile/internal/ir/name.go
src/cmd/compile/internal/ir/node.go
src/cmd/compile/internal/ir/node_gen.go
src/cmd/compile/internal/ir/type.go
src/cmd/compile/internal/ir/visit.go
src/cmd/compile/internal/typecheck/typecheck.go