Skip to content

Commit 9fab498

Browse files
committed
cmd/compile/internal/typecheck: remove some un-used functions
CL 405094 removed the only caller of markBreak/setHasBreak and isTermNodes/isTermNode. importlist variable is only used in old frontend. Change-Id: I9472f2c0017b6200847999f2cea0e9021a1b14e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/484435 TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]> Reviewed-by: Keith Randall <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 7045100 commit 9fab498

File tree

1 file changed

+0
-143
lines changed

1 file changed

+0
-143
lines changed

src/cmd/compile/internal/typecheck/typecheck.go

Lines changed: 0 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ func Callee(n ir.Node) ir.Node {
4646
return typecheck(n, ctxExpr|ctxCallee)
4747
}
4848

49-
var importlist []*ir.Func
50-
5149
var traceIndent []byte
5250

5351
func tracePrint(title string, n ir.Node) func(np *ir.Node) {
@@ -1674,147 +1672,6 @@ func checkunsafesliceorstring(op ir.Op, np *ir.Node) bool {
16741672
return true
16751673
}
16761674

1677-
// markBreak marks control statements containing break statements with SetHasBreak(true).
1678-
func markBreak(fn *ir.Func) {
1679-
var labels map[*types.Sym]ir.Node
1680-
var implicit ir.Node
1681-
1682-
var mark func(ir.Node) bool
1683-
mark = func(n ir.Node) bool {
1684-
switch n.Op() {
1685-
default:
1686-
ir.DoChildren(n, mark)
1687-
1688-
case ir.OBREAK:
1689-
n := n.(*ir.BranchStmt)
1690-
if n.Label == nil {
1691-
setHasBreak(implicit)
1692-
} else {
1693-
setHasBreak(labels[n.Label])
1694-
}
1695-
1696-
case ir.OFOR, ir.OSWITCH, ir.OSELECT, ir.ORANGE:
1697-
old := implicit
1698-
implicit = n
1699-
var sym *types.Sym
1700-
switch n := n.(type) {
1701-
case *ir.ForStmt:
1702-
sym = n.Label
1703-
case *ir.RangeStmt:
1704-
sym = n.Label
1705-
case *ir.SelectStmt:
1706-
sym = n.Label
1707-
case *ir.SwitchStmt:
1708-
sym = n.Label
1709-
}
1710-
if sym != nil {
1711-
if labels == nil {
1712-
// Map creation delayed until we need it - most functions don't.
1713-
labels = make(map[*types.Sym]ir.Node)
1714-
}
1715-
labels[sym] = n
1716-
}
1717-
ir.DoChildren(n, mark)
1718-
if sym != nil {
1719-
delete(labels, sym)
1720-
}
1721-
implicit = old
1722-
}
1723-
return false
1724-
}
1725-
1726-
mark(fn)
1727-
}
1728-
1729-
func setHasBreak(n ir.Node) {
1730-
switch n := n.(type) {
1731-
default:
1732-
base.Fatalf("setHasBreak %+v", n.Op())
1733-
case nil:
1734-
// ignore
1735-
case *ir.ForStmt:
1736-
n.HasBreak = true
1737-
case *ir.RangeStmt:
1738-
n.HasBreak = true
1739-
case *ir.SelectStmt:
1740-
n.HasBreak = true
1741-
case *ir.SwitchStmt:
1742-
n.HasBreak = true
1743-
}
1744-
}
1745-
1746-
// isTermNodes reports whether the Nodes list ends with a terminating statement.
1747-
func isTermNodes(l ir.Nodes) bool {
1748-
s := l
1749-
c := len(s)
1750-
if c == 0 {
1751-
return false
1752-
}
1753-
return isTermNode(s[c-1])
1754-
}
1755-
1756-
// isTermNode reports whether the node n, the last one in a
1757-
// statement list, is a terminating statement.
1758-
func isTermNode(n ir.Node) bool {
1759-
switch n.Op() {
1760-
// NOTE: OLABEL is treated as a separate statement,
1761-
// not a separate prefix, so skipping to the last statement
1762-
// in the block handles the labeled statement case by
1763-
// skipping over the label. No case OLABEL here.
1764-
1765-
case ir.OBLOCK:
1766-
n := n.(*ir.BlockStmt)
1767-
return isTermNodes(n.List)
1768-
1769-
case ir.OGOTO, ir.ORETURN, ir.OTAILCALL, ir.OPANIC, ir.OFALL:
1770-
return true
1771-
1772-
case ir.OFOR:
1773-
n := n.(*ir.ForStmt)
1774-
if n.Cond != nil {
1775-
return false
1776-
}
1777-
if n.HasBreak {
1778-
return false
1779-
}
1780-
return true
1781-
1782-
case ir.OIF:
1783-
n := n.(*ir.IfStmt)
1784-
return isTermNodes(n.Body) && isTermNodes(n.Else)
1785-
1786-
case ir.OSWITCH:
1787-
n := n.(*ir.SwitchStmt)
1788-
if n.HasBreak {
1789-
return false
1790-
}
1791-
def := false
1792-
for _, cas := range n.Cases {
1793-
if !isTermNodes(cas.Body) {
1794-
return false
1795-
}
1796-
if len(cas.List) == 0 { // default
1797-
def = true
1798-
}
1799-
}
1800-
return def
1801-
1802-
case ir.OSELECT:
1803-
n := n.(*ir.SelectStmt)
1804-
if n.HasBreak {
1805-
return false
1806-
}
1807-
for _, cas := range n.Cases {
1808-
if !isTermNodes(cas.Body) {
1809-
return false
1810-
}
1811-
}
1812-
return true
1813-
}
1814-
1815-
return false
1816-
}
1817-
18181675
func Conv(n ir.Node, t *types.Type) ir.Node {
18191676
if types.IdenticalStrict(n.Type(), t) {
18201677
return n

0 commit comments

Comments
 (0)