@@ -46,8 +46,6 @@ func Callee(n ir.Node) ir.Node {
46
46
return typecheck (n , ctxExpr | ctxCallee )
47
47
}
48
48
49
- var importlist []* ir.Func
50
-
51
49
var traceIndent []byte
52
50
53
51
func tracePrint (title string , n ir.Node ) func (np * ir.Node ) {
@@ -1674,147 +1672,6 @@ func checkunsafesliceorstring(op ir.Op, np *ir.Node) bool {
1674
1672
return true
1675
1673
}
1676
1674
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
-
1818
1675
func Conv (n ir.Node , t * types.Type ) ir.Node {
1819
1676
if types .IdenticalStrict (n .Type (), t ) {
1820
1677
return n
0 commit comments