Commit 3de8498b authored by Daniel Martí's avatar Daniel Martí Committed by Matthew Dempsky

cmd/compile: remove some unused params in gc

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