Commit c41608f4 authored by Robert Griesemer's avatar Robert Griesemer

cmd/compile: remove more superfluous int(lineno) conversions

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