]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove some unused params in gc
authorDaniel Martí <mvdan@mvdan.cc>
Wed, 9 Aug 2017 07:13:09 +0000 (16:13 +0900)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 9 Aug 2017 22:29:19 +0000 (22:29 +0000)
Mostly node and position parameters that are no longer used.

Also remove an unnecessary node variable while at it.

Found with github.com/mvdan/unparam.

Change-Id: I88f9bd5d20bfc5b0f6f63ea81869daa246175061
Reviewed-on: https://go-review.googlesource.com/54130
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/alg.go
src/cmd/compile/internal/gc/bimport.go
src/cmd/compile/internal/gc/closure.go
src/cmd/compile/internal/gc/dcl.go
src/cmd/compile/internal/gc/init.go
src/cmd/compile/internal/gc/noder.go
src/cmd/compile/internal/gc/subr.go
src/cmd/compile/internal/gc/typecheck.go
src/cmd/compile/internal/gc/walk.go

index 0b4c9c7b3f64b9c850b55d6c81fa7c650e6ff3f5..e98df71b34b678b9a55f029f82e7703ae32c97d0 100644 (file)
@@ -292,7 +292,7 @@ func genhash(sym *types.Sym, t *types.Type) {
                dumplist("genhash body", fn.Nbody)
        }
 
-       funcbody(fn)
+       funcbody()
        Curfn = fn
        fn.Func.SetDupok(true)
        fn = typecheck(fn, Etop)
@@ -476,7 +476,7 @@ func geneq(sym *types.Sym, t *types.Type) {
                dumplist("geneq body", fn.Nbody)
        }
 
-       funcbody(fn)
+       funcbody()
        Curfn = fn
        fn.Func.SetDupok(true)
        fn = typecheck(fn, Etop)
index 8cc8903dcd5e70ca94630db41d547c4b0dc9af17..ba542b4719efead1403602f9dbe9661300bfd169 100644 (file)
@@ -200,7 +200,7 @@ func Import(imp *types.Pkg, in *bufio.Reader) {
                                body = []*Node{nod(OEMPTY, nil, nil)}
                        }
                        f.Func.Inl.Set(body)
-                       funcbody(f)
+                       funcbody()
                } else {
                        // function already imported - read body but discard declarations
                        dclcontext = PDISCARD // throw away any declarations
index 143e1969c7d796ae79949b7dd78d40394d1df854..a3a0970f716a8b340bd4e097b8a08b9ecc5ed651 100644 (file)
@@ -19,7 +19,7 @@ func (p *noder) funcLit(expr *syntax.FuncLit) *Node {
        n.Func.Depth = funcdepth
        n.Func.Outerfunc = Curfn
 
-       old := p.funchdr(n, expr.Pos())
+       old := p.funchdr(n)
 
        // steal ntype's argument names and
        // leave a fresh copy in their place.
@@ -60,7 +60,7 @@ func (p *noder) funcLit(expr *syntax.FuncLit) *Node {
 
        n.Nbody.Set(body)
        n.Func.Endlineno = lineno
-       p.funcbody(n, expr.Body.Rbrace, old)
+       p.funcbody(old)
 
        // closure-specific variables are hanging off the
        // ordinary ones in the symbol table; see oldname.
index b8a5a90a0368a1c0d693b91ac1a54d6e37c396ec..78d9184cf367b03a8c4f87a1026871dde3ad868b 100644 (file)
@@ -519,7 +519,7 @@ func funcstart(n *Node) {
 // finish the body.
 // called in auto-declaration context.
 // returns in extern-declaration context.
-func funcbody(n *Node) {
+func funcbody() {
        // change the declaration context from auto to extern
        if dclcontext != PAUTO {
                Fatalf("funcbody: unexpected dclcontext %d", dclcontext)
index 93ae2410cd97d38d46ea563182587f5b8f0544f6..fcdec06ae766f25b58a38f171863fba65e5d3fd9 100644 (file)
@@ -198,7 +198,7 @@ func fninit(n []*Node) {
        exportsym(fn.Func.Nname)
 
        fn.Nbody.Set(r)
-       funcbody(fn)
+       funcbody()
 
        Curfn = fn
        fn = typecheck(fn, Etop)
index 3977be1d733db08ae5bd95199bdc7f39fe9e12dd..5872640ecaa59580d856663c29f0f4fa2bc80ed5 100644 (file)
@@ -78,15 +78,15 @@ type noder struct {
        scope      ScopeID
 }
 
-func (p *noder) funchdr(n *Node, pos src.Pos) ScopeID {
+func (p *noder) funchdr(n *Node) ScopeID {
        old := p.scope
        p.scope = 0
        funchdr(n)
        return old
 }
 
-func (p *noder) funcbody(n *Node, pos src.Pos, old ScopeID) {
-       funcbody(n)
+func (p *noder) funcbody(old ScopeID) {
+       funcbody()
        p.scope = old
 }
 
@@ -382,9 +382,8 @@ func (p *noder) funcDecl(fun *syntax.FuncDecl) *Node {
                declare(f.Func.Nname, PFUNC)
        }
 
-       oldScope := p.funchdr(f, fun.Pos())
+       oldScope := p.funchdr(f)
 
-       endPos := fun.Pos()
        if fun.Body != nil {
                if f.Noescape() {
                        yyerrorl(f.Pos, "can only use //go:noescape with external func implementations")
@@ -396,7 +395,6 @@ func (p *noder) funcDecl(fun *syntax.FuncDecl) *Node {
                }
                f.Nbody.Set(body)
 
-               endPos = fun.Body.Rbrace
                lineno = Ctxt.PosTable.XPos(fun.Body.Rbrace)
                f.Func.Endlineno = lineno
        } else {
@@ -405,7 +403,7 @@ func (p *noder) funcDecl(fun *syntax.FuncDecl) *Node {
                }
        }
 
-       p.funcbody(f, endPos, oldScope)
+       p.funcbody(oldScope)
        return f
 }
 
index d79789c4febca2f02f429fe3fad93c4dc85aa683..309470f7b65147b5bf1c0cf355c2559788f1e4bb 100644 (file)
@@ -1765,7 +1765,7 @@ func genwrapper(rcvr *types.Type, method *types.Field, newnam *types.Sym, iface
                dumplist("genwrapper body", fn.Nbody)
        }
 
-       funcbody(fn)
+       funcbody()
        Curfn = fn
        types.Popdcl()
        if debug_dclstack != 0 {
index 795bdcdd358e300e00cb254ac938e418d012544c..ab68c515ad739394909f411b89ad95c28c426350 100644 (file)
@@ -1096,11 +1096,9 @@ OpSwitch:
        case OSEND:
                ok |= Etop
                n.Left = typecheck(n.Left, Erv)
-               l := n.Left
                n.Right = typecheck(n.Right, Erv)
                n.Left = defaultlit(n.Left, nil)
-               l = n.Left
-               t := l.Type
+               t := n.Left.Type
                if t == nil {
                        n.Type = nil
                        return n
@@ -1123,7 +1121,7 @@ OpSwitch:
                        n.Type = nil
                        return n
                }
-               n.Right = assignconv(r, l.Type.Elem(), "send")
+               n.Right = assignconv(r, t.Elem(), "send")
 
                // TODO: more aggressive
                n.Etype = 0
index 76031d160abb9ada73b7e84399a16374169a0d7b..4eefb34994c1660e94cac55e3eed872a906ecd38 100644 (file)
@@ -762,7 +762,7 @@ opswitch:
                }
                init.Append(r)
 
-               ll := ascompatet(n.Op, n.List, r.Type)
+               ll := ascompatet(n.List, r.Type)
                n = liststmt(ll)
 
        // x, y = <-c
@@ -1699,7 +1699,7 @@ func reduceSlice(n *Node) *Node {
        return n
 }
 
-func ascompatee1(op Op, l *Node, r *Node, init *Nodes) *Node {
+func ascompatee1(l *Node, r *Node, init *Nodes) *Node {
        // convas will turn map assigns into function calls,
        // making it impossible for reorder3 to work.
        n := nod(OAS, l, r)
@@ -1734,7 +1734,7 @@ func ascompatee(op Op, nl, nr []*Node, init *Nodes) []*Node {
                if op == ORETURN && samesafeexpr(nl[i], nr[i]) {
                        continue
                }
-               nn = append(nn, ascompatee1(op, nl[i], nr[i], init))
+               nn = append(nn, ascompatee1(nl[i], nr[i], init))
        }
 
        // cannot happen: caller checked that lists had same length
@@ -1767,7 +1767,7 @@ func fncall(l *Node, rt *types.Type) bool {
 // check assign type list to
 // a expression list. called in
 //     expr-list = func()
-func ascompatet(op Op, nl Nodes, nr *types.Type) []*Node {
+func ascompatet(nl Nodes, nr *types.Type) []*Node {
        if nl.Len() != nr.NumFields() {
                Fatalf("ascompatet: assignment count mismatch: %d = %d", nl.Len(), nr.NumFields())
        }
@@ -3853,7 +3853,7 @@ func walkprintfunc(n *Node, init *Nodes) *Node {
 
        fn.Nbody.Set1(a)
 
-       funcbody(fn)
+       funcbody()
 
        fn = typecheck(fn, Etop)
        typecheckslice(fn.Nbody.Slice(), Etop)