aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/typecheck/typecheck.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2020-12-26 22:23:45 -0800
committerMatthew Dempsky <mdempsky@google.com>2020-12-28 07:45:09 +0000
commita59d26603f0dffbe6e914bc9ab29a2f9f70e5408 (patch)
treeb3d8bccf6f264b2dff1d9ae7ff8a4bc9ae28885f /src/cmd/compile/internal/typecheck/typecheck.go
parentfbc4458c068459940c63952bcc6a697728f508fc (diff)
downloadgo-a59d26603f0dffbe6e914bc9ab29a2f9f70e5408.tar.gz
go-a59d26603f0dffbe6e914bc9ab29a2f9f70e5408.zip
[dev.regabi] cmd/compile: use []*CaseStmt in {Select,Switch}Stmt
Select and switch statements only ever contain case statements, so change their Cases fields from Nodes to []*CaseStmt. This allows removing a bunch of type assertions throughout the compiler. CaseStmt should be renamed to CaseClause, and SelectStmt should probably have its own CommClause type instead (like in go/ast and cmd/compile/internal/syntax), but this is a good start. Passes toolstash -cmp. Change-Id: I2d41d616d44512c2be421e1e2ff13d0ee8b238ad Reviewed-on: https://go-review.googlesource.com/c/go/+/280442 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/typecheck.go')
-rw-r--r--src/cmd/compile/internal/typecheck/typecheck.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go
index b779f9ceb0..dabfee3bf9 100644
--- a/src/cmd/compile/internal/typecheck/typecheck.go
+++ b/src/cmd/compile/internal/typecheck/typecheck.go
@@ -2103,7 +2103,6 @@ func isTermNode(n ir.Node) bool {
}
def := false
for _, cas := range n.Cases {
- cas := cas.(*ir.CaseStmt)
if !isTermNodes(cas.Body) {
return false
}
@@ -2119,7 +2118,6 @@ func isTermNode(n ir.Node) bool {
return false
}
for _, cas := range n.Cases {
- cas := cas.(*ir.CaseStmt)
if !isTermNodes(cas.Body) {
return false
}
@@ -2218,9 +2216,6 @@ func deadcodeslice(nn *ir.Nodes) {
case ir.OBLOCK:
n := n.(*ir.BlockStmt)
deadcodeslice(&n.List)
- case ir.OCASE:
- n := n.(*ir.CaseStmt)
- deadcodeslice(&n.Body)
case ir.OFOR:
n := n.(*ir.ForStmt)
deadcodeslice(&n.Body)
@@ -2233,10 +2228,14 @@ func deadcodeslice(nn *ir.Nodes) {
deadcodeslice(&n.Body)
case ir.OSELECT:
n := n.(*ir.SelectStmt)
- deadcodeslice(&n.Cases)
+ for _, cas := range n.Cases {
+ deadcodeslice(&cas.Body)
+ }
case ir.OSWITCH:
n := n.(*ir.SwitchStmt)
- deadcodeslice(&n.Cases)
+ for _, cas := range n.Cases {
+ deadcodeslice(&cas.Body)
+ }
}
if cut {