]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove more superfluous int(lineno) conversions
authorRobert Griesemer <gri@golang.org>
Thu, 3 Mar 2016 01:34:42 +0000 (17:34 -0800)
committerRobert Griesemer <gri@golang.org>
Thu, 3 Mar 2016 04:05:45 +0000 (04:05 +0000)
Change-Id: Ia3e5d62b9d38a6c356baec8eb88b2bdabff5820f
Reviewed-on: https://go-review.googlesource.com/20150
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Robert Griesemer <gri@golang.org>

13 files changed:
src/cmd/compile/internal/gc/align.go
src/cmd/compile/internal/gc/closure.go
src/cmd/compile/internal/gc/const.go
src/cmd/compile/internal/gc/dcl.go
src/cmd/compile/internal/gc/esc.go
src/cmd/compile/internal/gc/gen.go
src/cmd/compile/internal/gc/order.go
src/cmd/compile/internal/gc/range.go
src/cmd/compile/internal/gc/select.go
src/cmd/compile/internal/gc/sinit.go
src/cmd/compile/internal/gc/swt.go
src/cmd/compile/internal/gc/typecheck.go
src/cmd/compile/internal/gc/walk.go

index 3d2d12ec316327f6129131c24a7d06f25e98678c..03c6a0e936303b213e3ab15638e4083d9406e4ec 100644 (file)
@@ -123,15 +123,12 @@ func dowidth(t *Type) {
        }
 
        if t.Width == -2 {
-               lno := int(lineno)
-               lineno = int32(t.Lineno)
                if !t.Broke {
                        t.Broke = true
-                       Yyerror("invalid recursive type %v", t)
+                       yyerrorl(int32(t.Lineno), "invalid recursive type %v", t)
                }
 
                t.Width = 0
-               lineno = int32(lno)
                return
        }
 
@@ -144,7 +141,7 @@ func dowidth(t *Type) {
        // defer checkwidth calls until after we're done
        defercalc++
 
-       lno := int(lineno)
+       lno := lineno
        lineno = int32(t.Lineno)
        t.Width = -2
        t.Align = 0
@@ -320,7 +317,7 @@ func dowidth(t *Type) {
                t.Align = uint8(w)
        }
 
-       lineno = int32(lno)
+       lineno = lno
 
        if defercalc == 1 {
                resumecheckwidth()
index 72b5a74f6aaebb9f8c409324b086a0f95ec8d2a0..40829d0e31ac36d105c02ed3742c7ae31a2ff3df 100644 (file)
@@ -219,7 +219,7 @@ func makeclosure(func_ *Node) *Node {
 func capturevars(xfunc *Node) {
        var outer *Node
 
-       lno := int(lineno)
+       lno := lineno
        lineno = xfunc.Lineno
 
        func_ := xfunc.Func.Closure
@@ -268,13 +268,13 @@ func capturevars(xfunc *Node) {
                func_.Func.Enter.Append(outer)
        }
 
-       lineno = int32(lno)
+       lineno = lno
 }
 
 // transformclosure is called in a separate phase after escape analysis.
 // It transform closure bodies to properly reference captured variables.
 func transformclosure(xfunc *Node) {
-       lno := int(lineno)
+       lno := lineno
        lineno = xfunc.Lineno
        func_ := xfunc.Func.Closure
 
@@ -401,7 +401,7 @@ func transformclosure(xfunc *Node) {
                }
        }
 
-       lineno = int32(lno)
+       lineno = lno
 }
 
 func walkclosure(func_ *Node, init **NodeList) *Node {
index 059f832fa7b78af599fdd6ffb588024fe1758a8e..ed39dde724f3fd90ee9a748f48a561fc6d7491db 100644 (file)
@@ -630,7 +630,7 @@ func evconst(n *Node) {
 
        nr := n.Right
        var rv Val
-       var lno int
+       var lno int32
        var wr EType
        var v Val
        var norig *Node
@@ -1104,10 +1104,9 @@ ret:
        n.SetVal(v)
 
        // check range.
-       lno = int(setlineno(n))
-
+       lno = setlineno(n)
        overflow(v, n.Type)
-       lineno = int32(lno)
+       lineno = lno
 
        // truncate precision for non-ideal float.
        if v.Ctype() == CTFLT && n.Type.Etype != TIDEAL {
@@ -1258,7 +1257,7 @@ func defaultlit(np **Node, t *Type) {
                *np = n
        }
 
-       lno := int(setlineno(n))
+       lno := setlineno(n)
        ctype := idealkind(n)
        var t1 *Type
        switch ctype {
@@ -1269,7 +1268,7 @@ func defaultlit(np **Node, t *Type) {
                }
 
                if n.Val().Ctype() == CTNIL {
-                       lineno = int32(lno)
+                       lineno = lno
                        if n.Diag == 0 {
                                Yyerror("use of untyped nil")
                                n.Diag = 1
@@ -1314,7 +1313,7 @@ func defaultlit(np **Node, t *Type) {
                goto num
        }
 
-       lineno = int32(lno)
+       lineno = lno
        return
 
 num:
@@ -1341,7 +1340,7 @@ num:
                overflow(n.Val(), t1)
        }
        Convlit(np, t1)
-       lineno = int32(lno)
+       lineno = lno
        return
 }
 
index da0c4575bf8799668e10eae2f80cd55c1a110da9..893fb6bf69ac112d7fa05bf3781e17b8668388c4 100644 (file)
@@ -755,7 +755,7 @@ func checkembeddedtype(t *Type) {
 }
 
 func structfield(n *Node) *Type {
-       lno := int(lineno)
+       lno := lineno
        lineno = n.Lineno
 
        if n.Op != ODCLFIELD {
@@ -802,14 +802,14 @@ func structfield(n *Node) *Type {
                f.Sym = f.Nname.Sym
        }
 
-       lineno = int32(lno)
+       lineno = lno
        return f
 }
 
 var uniqgen uint32
 
 func checkdupfields(t *Type, what string) {
-       lno := int(lineno)
+       lno := lineno
 
        for ; t != nil; t = t.Down {
                if t.Sym != nil && t.Nname != nil && !isblank(t.Nname) {
@@ -822,7 +822,7 @@ func checkdupfields(t *Type, what string) {
                }
        }
 
-       lineno = int32(lno)
+       lineno = lno
 }
 
 // convert a parsed id/type list into
@@ -888,7 +888,7 @@ func tofunargs(l *NodeList) *Type {
 }
 
 func interfacefield(n *Node) *Type {
-       lno := int(lineno)
+       lno := lineno
        lineno = n.Lineno
 
        if n.Op != ODCLFIELD {
@@ -950,7 +950,7 @@ func interfacefield(n *Node) *Type {
                f.Broke = true
        }
 
-       lineno = int32(lno)
+       lineno = lno
        return f
 }
 
index 30eacc6670bf82666464d26aac929285fd6cb499..aa74408705f696cf1cdad73584ae71dce15cafc1 100644 (file)
@@ -602,7 +602,7 @@ func esc(e *EscState, n *Node, up *Node) {
                return
        }
 
-       lno := int(setlineno(n))
+       lno := setlineno(n)
 
        // ninit logically runs at a different loopdepth than the rest of the for loop.
        esclist(e, n.Ninit, n)
@@ -944,7 +944,7 @@ func esc(e *EscState, n *Node, up *Node) {
                }
        }
 
-       lineno = int32(lno)
+       lineno = lno
 }
 
 // Assert that expr somehow gets assigned to dst, if non nil.  for
@@ -1012,7 +1012,7 @@ func escassign(e *EscState, dst *Node, src *Node) {
                dst = &e.theSink
        }
 
-       lno := int(setlineno(src))
+       lno := setlineno(src)
        e.pdepth++
 
        switch src.Op {
@@ -1120,7 +1120,7 @@ func escassign(e *EscState, dst *Node, src *Node) {
        }
 
        e.pdepth--
-       lineno = int32(lno)
+       lineno = lno
 }
 
 // Common case for escapes is 16 bits 000000000xxxEEEE
index 13fac83875500f64091aa23d2ce89e5e6a713f19..92ee2aed142ed83fb0564d22565b8873ed482307 100644 (file)
@@ -162,7 +162,7 @@ func checkgoto(from *Node, to *Node) {
                fs = fs.Link
        }
        if fs != to.Sym {
-               lno := int(lineno)
+               lno := lineno
                setlineno(from)
 
                // decide what to complain about.
@@ -196,7 +196,7 @@ func checkgoto(from *Node, to *Node) {
                } else {
                        Yyerror("goto %v jumps over declaration of %v at %v", from.Left.Sym, dcl, linestr(dcl.Lastlineno))
                }
-               lineno = int32(lno)
+               lineno = lno
        }
 }
 
index 88a19f9015caa1102e54585aeaf33938e43cd158..5071d3e49545128b8c9c227a2fe1fee72a0ace0a 100644 (file)
@@ -485,7 +485,7 @@ func orderstmt(n *Node, order *Order) {
                return
        }
 
-       lno := int(setlineno(n))
+       lno := setlineno(n)
 
        orderinit(n, order)
 
@@ -975,7 +975,7 @@ func orderstmt(n *Node, order *Order) {
                cleantemp(t, order)
        }
 
-       lineno = int32(lno)
+       lineno = lno
 }
 
 // Orderexprlist orders the expression list l into order.
@@ -1007,7 +1007,7 @@ func orderexpr(np **Node, order *Order, lhs *Node) {
                return
        }
 
-       lno := int(setlineno(n))
+       lno := setlineno(n)
        orderinit(n, order)
 
        switch n.Op {
@@ -1218,7 +1218,7 @@ func orderexpr(np **Node, order *Order, lhs *Node) {
                }
        }
 
-       lineno = int32(lno)
+       lineno = lno
 
        *np = n
 }
index 2270d71621e689d695b4ea01d56f2f767ee49dfc..b6fd388b0a77a9b7b6a5303f8c18bd3c137e20e9 100644 (file)
@@ -143,7 +143,7 @@ func walkrange(n *Node) {
        t := n.Type
 
        a := n.Right
-       lno := int(setlineno(a))
+       lno := setlineno(a)
        n.Right = nil
 
        var v1 *Node
@@ -167,7 +167,7 @@ func walkrange(n *Node) {
 
        case TARRAY:
                if memclrrange(n, v1, v2, a) {
-                       lineno = int32(lno)
+                       lineno = lno
                        return
                }
 
@@ -323,7 +323,7 @@ func walkrange(n *Node) {
        n.Nbody.Set(append(body, n.Nbody.Slice()...))
        walkstmt(&n)
 
-       lineno = int32(lno)
+       lineno = lno
 }
 
 // Lower n into runtime·memclr if possible, for
index 02439475002be291ad832066a15ee5614ac00ed8..5c3eea8efb5efa1099c26dfaf1166c3cf3b43451 100644 (file)
@@ -10,7 +10,7 @@ func typecheckselect(sel *Node) {
        var n *Node
 
        var def *Node
-       lno := int(setlineno(sel))
+       lno := setlineno(sel)
        count := 0
        typechecklist(sel.Ninit, Etop)
        for l := sel.List; l != nil; l = l.Next {
@@ -83,7 +83,7 @@ func typecheckselect(sel *Node) {
        }
 
        sel.Xoffset = int64(count)
-       lineno = int32(lno)
+       lineno = lno
 }
 
 func walkselect(sel *Node) {
@@ -91,7 +91,7 @@ func walkselect(sel *Node) {
                Fatalf("double walkselect") // already rewrote
        }
 
-       lno := int(setlineno(sel))
+       lno := setlineno(sel)
        i := count(sel.List)
 
        // optimization: zero-case select
@@ -322,7 +322,7 @@ func walkselect(sel *Node) {
 out:
        sel.List = nil
        walkstmtslice(sel.Nbody.Slice())
-       lineno = int32(lno)
+       lineno = lno
 }
 
 // Keep in sync with src/runtime/runtime2.go and src/runtime/select.go.
index bee045f567f7001621c8940c1324c330e0c88e99..c3b2b66b6251e519fbd2ecf1a088abf0f086dd1e 100644 (file)
@@ -246,9 +246,9 @@ func initreorder(l *NodeList, out *[]*Node) {
 func initfix(l *NodeList) []*Node {
        var lout []*Node
        initplans = make(map[*Node]*InitPlan)
-       lno := int(lineno)
+       lno := lineno
        initreorder(l, &lout)
-       lineno = int32(lno)
+       lineno = lno
        initplans = nil
        return lout
 }
index 7ad66c3e70a9884928c06db1480f533368ec2ec1..1835642b9555061a9841596fefa86694342ce84f 100644 (file)
@@ -58,7 +58,7 @@ type caseClause struct {
 
 // typecheckswitch typechecks a switch statement.
 func typecheckswitch(n *Node) {
-       lno := int(lineno)
+       lno := lineno
        typechecklist(n.Ninit, Etop)
 
        var nilonly string
@@ -184,7 +184,7 @@ func typecheckswitch(n *Node) {
                typecheckslice(ncase.Nbody.Slice(), Etop)
        }
 
-       lineno = int32(lno)
+       lineno = lno
 }
 
 // walkswitch walks a switch statement.
@@ -290,7 +290,7 @@ func (s *exprSwitch) walkCases(cc []*caseClause) *Node {
                var cas *NodeList
                for _, c := range cc {
                        n := c.node
-                       lno := int(setlineno(n))
+                       lno := setlineno(n)
 
                        a := Nod(OIF, nil, nil)
                        if (s.kind != switchKindTrue && s.kind != switchKindFalse) || assignop(n.Left.Type, s.exprname.Type, nil) == OCONVIFACE || assignop(s.exprname.Type, n.Left.Type, nil) == OCONVIFACE {
@@ -306,7 +306,7 @@ func (s *exprSwitch) walkCases(cc []*caseClause) *Node {
                        a.Nbody.Set([]*Node{n.Right}) // goto l
 
                        cas = list(cas, a)
-                       lineno = int32(lno)
+                       lineno = lno
                }
                return liststmt(cas)
        }
index 05a1b26f7424f57f2897f73fcb22fcf3d024894b..17ea693d3174648ed3edd93a4c10acef09565cc1 100644 (file)
@@ -122,7 +122,7 @@ func typecheck(np **Node, top int) *Node {
                return nil
        }
 
-       lno := int(setlineno(n))
+       lno := setlineno(n)
 
        // Skip over parens.
        for n.Op == OPAREN {
@@ -142,7 +142,7 @@ func typecheck(np **Node, top int) *Node {
                        break
 
                default:
-                       lineno = int32(lno)
+                       lineno = lno
                        return n
                }
        }
@@ -176,7 +176,7 @@ func typecheck(np **Node, top int) *Node {
                        Yyerror("typechecking loop involving %v%s", n, fmt_)
                }
 
-               lineno = int32(lno)
+               lineno = lno
                return n
        }
 
@@ -192,7 +192,7 @@ func typecheck(np **Node, top int) *Node {
        typecheck_tcstack[last] = nil
        typecheck_tcstack = typecheck_tcstack[:last]
 
-       lineno = int32(lno)
+       lineno = lno
        return n
 }
 
@@ -2612,7 +2612,7 @@ func typecheckaste(op Op, call *Node, isddd bool, tstruct *Type, nl *NodeList, d
        var n1 int
        var n2 int
 
-       lno := int(lineno)
+       lno := lineno
 
        if tstruct.Broke {
                goto out
@@ -2749,7 +2749,7 @@ func typecheckaste(op Op, call *Node, isddd bool, tstruct *Type, nl *NodeList, d
        }
 
 out:
-       lineno = int32(lno)
+       lineno = lno
        return
 
 notenough:
@@ -3552,7 +3552,7 @@ func copytype(n *Node, t *Type) {
        }
 
        // Double-check use of type as embedded type.
-       lno := int(lineno)
+       lno := lineno
 
        if embedlineno != 0 {
                lineno = int32(embedlineno)
@@ -3561,7 +3561,7 @@ func copytype(n *Node, t *Type) {
                }
        }
 
-       lineno = int32(lno)
+       lineno = lno
 
        // Queue check for map until all the types are done settling.
        if maplineno != 0 {
@@ -3572,7 +3572,7 @@ func copytype(n *Node, t *Type) {
 
 func typecheckdeftype(n *Node) {
        ntypecheckdeftype++
-       lno := int(lineno)
+       lno := lineno
        setlineno(n)
        n.Type.Sym = n.Sym
        n.Typecheck = 1
@@ -3596,7 +3596,7 @@ func typecheckdeftype(n *Node) {
        copytype(n, t)
 
 ret:
-       lineno = int32(lno)
+       lineno = lno
 
        // if there are no type definitions going on, it's safe to
        // try to resolve the method types for the interfaces
@@ -3619,7 +3619,7 @@ ret:
                        maptype(l.N.Type, Types[TBOOL])
                }
 
-               lineno = int32(lno)
+               lineno = lno
        }
 
        ntypecheckdeftype--
@@ -3635,7 +3635,7 @@ func queuemethod(n *Node) {
 }
 
 func typecheckdef(n *Node) *Node {
-       lno := int(lineno)
+       lno := lineno
        setlineno(n)
 
        if n.Op == ONONAME {
@@ -3806,7 +3806,7 @@ ret:
        typecheckdefstack[last] = nil
        typecheckdefstack = typecheckdefstack[:last]
 
-       lineno = int32(lno)
+       lineno = lno
        n.Walkdef = 1
        return n
 }
index f72176b6c9f2757c043252bf45011d09911e41d7..2abc8df43c0ab8be3236ce19942434b9cf8b217b 100644 (file)
@@ -25,7 +25,7 @@ func walk(fn *Node) {
                dumpslice(s, Curfn.Nbody.Slice())
        }
 
-       lno := int(lineno)
+       lno := lineno
 
        // Final typecheck for any unused variables.
        // It's hard to be on the heap when not-used, but best to be consistent about &~PHEAP here and below.
@@ -60,7 +60,7 @@ func walk(fn *Node) {
                }
        }
 
-       lineno = int32(lno)
+       lineno = lno
        if nerrors != 0 {
                return
        }