Various minor adjustments.
Change-Id: Iedfb97989f7bedaa3e9e8993b167e05f162434a7
Reviewed-on: https://go-review.googlesource.com/34136
Reviewed-by: David Lazar <lazard@golang.org>
}
func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
- s.SetLineno(v.Line)
+ s.SetPos(v.Line)
switch v.Op {
case ssa.OpAMD64ADDQ, ssa.OpAMD64ADDL:
r := v.Reg()
}
func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
- s.SetLineno(b.Line)
+ s.SetPos(b.Line)
switch b.Kind {
case ssa.BlockPlain:
}
func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
- s.SetLineno(v.Line)
+ s.SetPos(v.Line)
switch v.Op {
case ssa.OpInitMem:
// memory arg needs no code
}
func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
- s.SetLineno(b.Line)
+ s.SetPos(b.Line)
switch b.Kind {
case ssa.BlockPlain:
}
func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
- s.SetLineno(v.Line)
+ s.SetPos(v.Line)
switch v.Op {
case ssa.OpInitMem:
// memory arg needs no code
}
func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
- s.SetLineno(b.Line)
+ s.SetPos(b.Line)
switch b.Kind {
case ssa.BlockPlain:
if t.Width == -2 {
if !t.Broke {
t.Broke = true
- yyerrorl(t.Lineno, "invalid recursive type %v", t)
+ yyerrorl(t.Pos, "invalid recursive type %v", t)
}
t.Width = 0
defercalc++
lno := lineno
- lineno = t.Lineno
+ lineno = t.Pos
t.Width = -2
t.Align = 0
package main
func Mod32(x uint32) uint32 {
- return x % 3 // frontend rewrites it as HMUL with 2863311531, the LITERAL node has Lineno 0
+ return x % 3 // frontend rewrites it as HMUL with 2863311531, the LITERAL node has unknown Pos
}
`
func fileLine(n *Node) (file string, line int) {
if n != nil {
- file, line = Ctxt.LineHist.AbsFileLine(int(n.Lineno.Line()))
+ file, line = Ctxt.LineHist.AbsFileLine(int(n.Pos.Line()))
}
return
}
// for the issue.
if p.nesting > 100 {
p.int(0) // 0 methods to indicate empty interface
- yyerrorl(t.Lineno, "cannot export unnamed recursive interface")
+ yyerrorl(t.Pos, "cannot export unnamed recursive interface")
break
}
// after capturing (effectively constant).
func capturevars(xfunc *Node) {
lno := lineno
- lineno = xfunc.Lineno
+ lineno = xfunc.Pos
func_ := xfunc.Func.Closure
func_.Func.Enter.Set(nil)
if v.Name.Byval {
how = "value"
}
- Warnl(v.Lineno, "%v capturing by %s: %v (addr=%v assign=%v width=%d)", name, how, v.Sym, outermost.Addrtaken, outermost.Assigned, int32(v.Type.Width))
+ Warnl(v.Pos, "%v capturing by %s: %v (addr=%v assign=%v width=%d)", name, how, v.Sym, outermost.Addrtaken, outermost.Assigned, int32(v.Type.Width))
}
outer = typecheck(outer, Erv)
// It transform closure bodies to properly reference captured variables.
func transformclosure(xfunc *Node) {
lno := lineno
- lineno = xfunc.Lineno
+ lineno = xfunc.Pos
func_ := xfunc.Func.Closure
if func_.Func.Top&Ecall != 0 {
func closuredebugruntimecheck(r *Node) {
if Debug_closure > 0 {
if r.Esc == EscHeap {
- Warnl(r.Lineno, "heap closure, captured vars = %v", r.Func.Cvars)
+ Warnl(r.Pos, "heap closure, captured vars = %v", r.Func.Cvars)
} else {
- Warnl(r.Lineno, "stack closure, captured vars = %v", r.Func.Cvars)
+ Warnl(r.Pos, "stack closure, captured vars = %v", r.Func.Cvars)
}
}
if compiling_runtime && r.Esc == EscHeap {
- yyerrorl(r.Lineno, "heap-allocated closure, not allowed in runtime.")
+ yyerrorl(r.Pos, "heap-allocated closure, not allowed in runtime.")
}
}
// If no closure vars, don't bother wrapping.
if hasemptycvars(func_) {
if Debug_closure > 0 {
- Warnl(func_.Lineno, "closure converted to global")
+ Warnl(func_.Pos, "closure converted to global")
}
return func_.Func.Closure.Func.Nname
} else {
// named OLITERAL needs Name; most OLITERALs don't.
n.Name = new(Name)
}
- n.Lineno = lineno
+ n.Pos = lineno
s := n.Sym
// kludgy: typecheckok means we're past parsing. Eg genwrapper may declare out of package names later.
}
cl = lastconst
t = lasttype
- lno = vl[0].Lineno
+ lno = vl[0].Pos
} else {
lastconst = cl
lasttype = t
continue
}
if !colasname(n) {
- yyerrorl(defn.Lineno, "non-name %v on left side of :=", n)
+ yyerrorl(defn.Pos, "non-name %v on left side of :=", n)
nerr++
continue
}
if n.Sym.Flags&SymUniq == 0 {
- yyerrorl(defn.Lineno, "%v repeated on left side of :=", n.Sym)
+ yyerrorl(defn.Pos, "%v repeated on left side of :=", n.Sym)
n.Diag = true
nerr++
continue
}
if nnew == 0 && nerr == 0 {
- yyerrorl(defn.Lineno, "no new variables on left side of :=")
+ yyerrorl(defn.Pos, "no new variables on left side of :=")
}
}
func structfield(n *Node) *Field {
lno := lineno
- lineno = n.Lineno
+ lineno = n.Pos
if n.Op != ODCLFIELD {
Fatalf("structfield: oops %v\n", n)
continue
}
if seen[f.Sym] {
- lineno = f.Nname.Lineno
+ lineno = f.Nname.Pos
yyerror("duplicate %s %s", what, f.Sym.Name)
continue
}
func interfacefield(n *Node) *Field {
lno := lineno
- lineno = n.Lineno
+ lineno = n.Pos
if n.Op != ODCLFIELD {
Fatalf("interfacefield: oops %v\n", n)
visitBottomUp(xtop, func(list []*Node, recursive bool) {
// Functions with write barriers have depth 0.
for _, n := range list {
- if n.Func.WBLineno.IsKnown() && n.Func.Pragma&Yeswritebarrierrec == 0 {
- c.best[n] = nowritebarrierrecCall{target: nil, depth: 0, lineno: n.Func.WBLineno}
+ if n.Func.WBPos.IsKnown() && n.Func.Pragma&Yeswritebarrierrec == 0 {
+ c.best[n] = nowritebarrierrecCall{target: nil, depth: 0, lineno: n.Func.WBPos}
}
}
// yeswritebarrierrec function.
continue
}
- if !n.Func.WBLineno.IsKnown() {
+ if !n.Func.WBPos.IsKnown() {
c.curfn = n
c.visitcodelist(n.Nbody)
}
call = c.best[n]
}
err = fmt.Sprintf("write barrier prohibited by caller; %v%s", n.Func.Nname, err)
- yyerrorl(n.Func.WBLineno, err)
+ yyerrorl(n.Func.WBPos, err)
}
})
}
if ok && fnbest.depth+1 >= best.depth {
return
}
- c.best[c.curfn] = nowritebarrierrecCall{target: defn, depth: fnbest.depth + 1, lineno: n.Lineno}
+ c.best[c.curfn] = nowritebarrierrecCall{target: defn, depth: fnbest.depth + 1, lineno: n.Pos}
c.stable = false
}
if n.Esc != escapes[i] {
done = false
if Debug['m'] > 2 {
- Warnl(n.Lineno, "Reflooding %v %S", e.curfnSym(n), n)
+ Warnl(n.Pos, "Reflooding %v %S", e.curfnSym(n), n)
}
escapes[i] = n.Esc
e.escflood(n)
if Debug['m'] != 0 {
for _, n := range e.noesc {
if n.Esc == EscNone {
- Warnl(n.Lineno, "%v %S does not escape", e.curfnSym(n), n)
+ Warnl(n.Pos, "%v %S does not escape", e.curfnSym(n), n)
}
}
}
(n.Op == ONEW || n.Op == OPTRLIT) && n.Type.Elem().Width >= 1<<16 ||
n.Op == OMAKESLICE && !isSmallMakeSlice(n)) {
if Debug['m'] > 2 {
- Warnl(n.Lineno, "%v is too large for stack", n)
+ Warnl(n.Pos, "%v is too large for stack", n)
}
n.Esc = EscHeap
addrescapes(n)
// b escapes as well. If we ignore such OSLICEARR, we will conclude
// that b does not escape when b contents do.
if Debug['m'] != 0 {
- Warnl(n.Lineno, "%v ignoring self-assignment to %S", e.curfnSym(n), n.Left)
+ Warnl(n.Pos, "%v ignoring self-assignment to %S", e.curfnSym(n), n.Left)
}
break
slice2 := n.List.Second()
e.escassignDereference(&e.theSink, slice2, e.stepAssignWhere(n, slice2, "appended slice...", n)) // lose track of assign of dereference
if Debug['m'] > 3 {
- Warnl(n.Lineno, "%v special treatment of append(slice1, slice2...) %S", e.curfnSym(n), n)
+ Warnl(n.Pos, "%v special treatment of append(slice1, slice2...) %S", e.curfnSym(n), n)
}
}
e.escassignDereference(&e.theSink, n.List.First(), e.stepAssignWhere(n, n.List.First(), "appendee slice", n)) // The original elements are now leaked, too
a := v.Name.Defn
if !v.Name.Byval {
a = nod(OADDR, a, nil)
- a.Lineno = v.Lineno
+ a.Pos = v.Pos
e.nodeEscState(a).Loopdepth = e.loopdepth
a = typecheck(a, Erv)
}
// OCLOSURE is lowered to OPTRLIT,
// insert OADDR to account for the additional indirection.
a := nod(OADDR, src, nil)
- a.Lineno = src.Lineno
+ a.Pos = src.Pos
e.nodeEscState(a).Loopdepth = e.nodeEscState(src).Loopdepth
a.Type = ptrto(src.Type)
e.escflows(dst, a, e.stepAssign(nil, originalDst, src, dstwhy))
func (e *EscState) addDereference(n *Node) *Node {
ind := nod(OIND, n, nil)
e.nodeEscState(ind).Loopdepth = e.nodeEscState(n).Loopdepth
- ind.Lineno = n.Lineno
+ ind.Pos = n.Pos
t := n.Type
if t.IsKind(Tptr) {
// This should model our own sloppy use of OIND to encode
ret.Name.Curfn = Curfn
e.nodeEscState(ret).Loopdepth = e.loopdepth
ret.Used = true
- ret.Lineno = call.Lineno
+ ret.Pos = call.Pos
cE.Retval.Append(ret)
}
}
arg = nod(ODDDARG, nil, nil)
arr := typArray(n.Type.Elem(), int64(len(args)))
arg.Type = ptrto(arr) // make pointer so it will be tracked
- arg.Lineno = call.Lineno
+ arg.Pos = call.Pos
e.track(arg)
call.Right = arg
}
if param.Isddd && !call.Isddd {
// Introduce ODDDARG node to represent ... allocation.
arg = nod(ODDDARG, nil, nil)
- arg.Lineno = call.Lineno
+ arg.Pos = call.Pos
arr := typArray(param.Type.Elem(), int64(len(args)-i))
arg.Type = ptrto(arr) // make pointer so it will be tracked
e.track(arg)
if where == nil {
where = dst
}
- Warnl(src.Lineno, "\tfrom %v (%s) at %s", dst, step.why, where.Line())
+ Warnl(src.Pos, "\tfrom %v (%s) at %s", dst, step.why, where.Line())
}
for step := step0; step != nil && step.busy; step = step.parent {
step.busy = false
// 4. return *in
if Debug['m'] != 0 {
if Debug['m'] <= 2 {
- Warnl(src.Lineno, "leaking param: %S to result %v level=%v", src, dst.Sym, level.int())
+ Warnl(src.Pos, "leaking param: %S to result %v level=%v", src, dst.Sym, level.int())
step.describe(src)
} else {
- Warnl(src.Lineno, "leaking param: %S to result %v level=%v", src, dst.Sym, level)
+ Warnl(src.Pos, "leaking param: %S to result %v level=%v", src, dst.Sym, level)
}
}
if src.Esc&EscMask != EscReturn {
level.int() > 0 {
src.Esc = escMax(EscContentEscapes|src.Esc, EscNone)
if Debug['m'] != 0 {
- Warnl(src.Lineno, "mark escaped content: %S", src)
+ Warnl(src.Pos, "mark escaped content: %S", src)
step.describe(src)
}
}
if Debug['m'] != 0 {
if Debug['m'] <= 2 {
if osrcesc != src.Esc {
- Warnl(src.Lineno, "leaking param content: %S", src)
+ Warnl(src.Pos, "leaking param content: %S", src)
step.describe(src)
}
} else {
- Warnl(src.Lineno, "leaking param content: %S level=%v dst.eld=%v src.eld=%v dst=%S",
+ Warnl(src.Pos, "leaking param content: %S level=%v dst.eld=%v src.eld=%v dst=%S",
src, level, dstE.Loopdepth, modSrcLoopdepth, dst)
}
}
src.Esc = EscHeap
if Debug['m'] != 0 {
if Debug['m'] <= 2 {
- Warnl(src.Lineno, "leaking param: %S", src)
+ Warnl(src.Pos, "leaking param: %S", src)
step.describe(src)
} else {
- Warnl(src.Lineno, "leaking param: %S level=%v dst.eld=%v src.eld=%v dst=%S",
+ Warnl(src.Pos, "leaking param: %S level=%v dst.eld=%v src.eld=%v dst=%S",
src, level, dstE.Loopdepth, modSrcLoopdepth, dst)
}
}
// original variable.
if src.isClosureVar() {
if leaks && Debug['m'] != 0 {
- Warnl(src.Lineno, "leaking closure reference %S", src)
+ Warnl(src.Pos, "leaking closure reference %S", src)
step.describe(src)
}
e.escwalk(level, dst, src.Name.Defn, e.stepWalk(dst, src.Name.Defn, "closure-var", step))
p = p.Left // merely to satisfy error messages in tests
}
if Debug['m'] > 2 {
- Warnl(src.Lineno, "%S escapes to heap, level=%v, dst=%v dst.eld=%v, src.eld=%v",
+ Warnl(src.Pos, "%S escapes to heap, level=%v, dst=%v dst.eld=%v, src.eld=%v",
p, level, dst, dstE.Loopdepth, modSrcLoopdepth)
} else {
- Warnl(src.Lineno, "%S escapes to heap", p)
+ Warnl(src.Pos, "%S escapes to heap", p)
step.describe(src)
}
}
if leaks {
src.Esc = EscHeap
if Debug['m'] != 0 && osrcesc != src.Esc {
- Warnl(src.Lineno, "%S escapes to heap", src)
+ Warnl(src.Pos, "%S escapes to heap", src)
step.describe(src)
}
extraloopdepth = modSrcLoopdepth
if leaks {
src.Esc = EscHeap
if Debug['m'] != 0 && osrcesc != src.Esc {
- Warnl(src.Lineno, "%S escapes to heap", src)
+ Warnl(src.Pos, "%S escapes to heap", src)
step.describe(src)
}
extraloopdepth = modSrcLoopdepth
narg++
if f.Type.Etype == TUINTPTR {
if Debug['m'] != 0 {
- Warnl(fn.Lineno, "%v assuming %v is unsafe uintptr", funcSym(fn), name(f.Sym, narg))
+ Warnl(fn.Pos, "%v assuming %v is unsafe uintptr", funcSym(fn), name(f.Sym, narg))
}
f.Note = unsafeUintptrTag
}
narg++
if f.Type.Etype == TUINTPTR {
if Debug['m'] != 0 {
- Warnl(fn.Lineno, "%v marking %v as escaping uintptr", funcSym(fn), name(f.Sym, narg))
+ Warnl(fn.Pos, "%v marking %v as escaping uintptr", funcSym(fn), name(f.Sym, narg))
}
f.Note = uintptrEscapesTag
}
if f.Isddd && f.Type.Elem().Etype == TUINTPTR {
// final argument is ...uintptr.
if Debug['m'] != 0 {
- Warnl(fn.Lineno, "%v marking %v as escaping ...uintptr", funcSym(fn), name(f.Sym, narg))
+ Warnl(fn.Pos, "%v marking %v as escaping ...uintptr", funcSym(fn), name(f.Sym, narg))
}
f.Note = uintptrEscapesTag
}
fmt.Fprintf(s, " g(%d)", n.Name.Vargen)
}
- if n.Lineno.IsKnown() {
- fmt.Fprintf(s, " l(%d)", n.Lineno.Line())
+ if n.Pos.IsKnown() {
+ fmt.Fprintf(s, " l(%d)", n.Pos.Line())
}
if c == 0 && n.Xoffset != BADWIDTH {
Curfn = Curfn.Func.Closure
}
ln := lineno
- lineno = Curfn.Lineno
+ lineno = Curfn.Pos
moveToHeap(n)
Curfn = oldfn
lineno = ln
args := as.Rlist
as.Rlist.Set(nil)
- setlno(call, n.Lineno)
+ setlno(call, n.Pos)
as.Rlist.Set(args.Slice())
}
// don't clobber names, unless they're freshly synthesized
- if n.Op != ONAME || !n.Lineno.IsKnown() {
- n.Lineno = lno
+ if n.Op != ONAME || !n.Pos.IsKnown() {
+ n.Pos = lno
}
setlno(n.Left, lno)
// errors if a conflicting top-level name is
// introduced by a different file.
if !s.Def.Used && nsyntaxerrors == 0 {
- pkgnotused(s.Def.Lineno, s.Def.Name.Pkg.Path, s.Name)
+ pkgnotused(s.Def.Pos, s.Def.Name.Pkg.Path, s.Name)
}
s.Def = nil
continue
// throw away top-level name left over
// from previous import . "x"
if s.Def.Name != nil && s.Def.Name.Pack != nil && !s.Def.Name.Pack.Used && nsyntaxerrors == 0 {
- pkgnotused(s.Def.Name.Pack.Lineno, s.Def.Name.Pack.Name.Pkg.Path, "")
+ pkgnotused(s.Def.Name.Pack.Pos, s.Def.Name.Pack.Name.Pkg.Path, "")
s.Def.Name.Pack.Used = true
}
return
}
if my.Name == "init" {
- yyerrorl(pack.Lineno, "cannot import package as init - init must be a func")
+ yyerrorl(pack.Pos, "cannot import package as init - init must be a func")
return
}
if my.Name == "_" {
return
}
if my.Def != nil {
- lineno = pack.Lineno
+ lineno = pack.Pos
redeclare(my, "as imported package name")
}
my.Def = pack
- my.Lastlineno = pack.Lineno
+ my.Lastlineno = pack.Pos
my.Block = 1 // at top level
}
// TODO(mdempsky): Shouldn't happen. Fix package syntax.
return dst
}
- dst.Lineno = src.MakePos(p.baseline + int32(l) - 1)
+ dst.Pos = src.MakePos(p.baseline + int32(l) - 1)
return dst
}
Fatalf("staticinit")
}
- lineno = n.Lineno
+ lineno = n.Pos
l := n.Name.Defn.Left
r := n.Name.Defn.Right
return staticassign(l, r, out)
case OCLOSURE:
if hasemptycvars(r) {
if Debug_closure > 0 {
- Warnl(r.Lineno, "closure converted to global")
+ Warnl(r.Pos, "closure converted to global")
}
// Closures with no captured variables are globals,
// so the assignment can be done at link time.
}
var s state
- s.pushLine(fn.Lineno)
+ s.pushLine(fn.Pos)
defer s.popLine()
if fn.Func.Pragma&CgoUnsafeArgs != 0 {
s.noWB = true
}
defer func() {
- if s.WBLineno.IsKnown() {
- fn.Func.WBLineno = s.WBLineno
+ if s.WBPos.IsKnown() {
+ fn.Func.WBPos = s.WBPos
}
}()
// TODO(khr): build config just once at the start of the compiler binary
// Check that we used all labels
for name, lab := range s.labels {
if !lab.used() && !lab.reported && !lab.defNode.Used {
- yyerrorl(lab.defNode.Lineno, "label %v defined and not used", name)
+ yyerrorl(lab.defNode.Pos, "label %v defined and not used", name)
lab.reported = true
}
if lab.used() && !lab.defined() && !lab.reported {
- yyerrorl(lab.useNode.Lineno, "label %v not defined", name)
+ yyerrorl(lab.useNode.Pos, "label %v not defined", name)
lab.reported = true
}
}
cgoUnsafeArgs bool
noWB bool
- WBLineno src.Pos // line number of first write barrier. 0=no write barriers
+ WBPos src.Pos // line number of first write barrier. 0=no write barriers
}
type funcLine struct {
// stmt converts the statement n to SSA and adds it to s.
func (s *state) stmt(n *Node) {
- s.pushLine(n.Lineno)
+ s.pushLine(n.Pos)
defer s.popLine()
// If s.curBlock is nil, then we're about to generate dead code.
deref = true
res = res.Args[0]
}
- s.assign(n.List.First(), res, needwritebarrier(n.List.First(), n.Rlist.First()), deref, n.Lineno, 0, false)
- s.assign(n.List.Second(), resok, false, false, n.Lineno, 0, false)
+ s.assign(n.List.First(), res, needwritebarrier(n.List.First(), n.Rlist.First()), deref, n.Pos, 0, false)
+ s.assign(n.List.Second(), resok, false, false, n.Pos, 0, false)
return
case OAS2FUNC:
// This is future-proofing against non-scalar 2-result intrinsics.
// Currently we only have scalar ones, which result in no write barrier.
fakeret := &Node{Op: OINDREGSP}
- s.assign(n.List.First(), v1, needwritebarrier(n.List.First(), fakeret), false, n.Lineno, 0, false)
- s.assign(n.List.Second(), v2, needwritebarrier(n.List.Second(), fakeret), false, n.Lineno, 0, false)
+ s.assign(n.List.First(), v1, needwritebarrier(n.List.First(), fakeret), false, n.Pos, 0, false)
+ s.assign(n.List.Second(), v2, needwritebarrier(n.List.Second(), fakeret), false, n.Pos, 0, false)
return
case ODCL:
if !lab.defined() {
lab.defNode = n
} else {
- s.Error("label %v already defined at %v", sym, linestr(lab.defNode.Lineno))
+ s.Error("label %v already defined at %v", sym, linestr(lab.defNode.Pos))
lab.reported = true
}
// The label might already have a target block via a goto.
if samesafeexpr(n.Left, rhs.List.First()) {
if !s.canSSA(n.Left) {
if Debug_append > 0 {
- Warnl(n.Lineno, "append: len-only update")
+ Warnl(n.Pos, "append: len-only update")
}
s.append(rhs, true)
return
} else {
if Debug_append > 0 { // replicating old diagnostic message
- Warnl(n.Lineno, "append: len-only update (in local slice)")
+ Warnl(n.Pos, "append: len-only update (in local slice)")
}
}
}
}
}
- s.assign(n.Left, r, needwb, deref, n.Lineno, skip, isVolatile)
+ s.assign(n.Left, r, needwb, deref, n.Pos, skip, isVolatile)
case OIF:
bThen := s.f.NewBlock(ssa.BlockPlain)
if !(n.Op == ONAME || n.Op == OLITERAL && n.Sym != nil) {
// ONAMEs and named OLITERALs have the line number
// of the decl, not the use. See issue 14742.
- s.pushLine(n.Lineno)
+ s.pushLine(n.Pos)
defer s.popLine()
}
return s.newValue2(ssa.OpLoad, n.Type, addr, s.mem())
case OIND:
- p := s.exprPtr(n.Left, false, n.Lineno)
+ p := s.exprPtr(n.Left, false, n.Pos)
return s.newValue2(ssa.OpLoad, n.Type, p, s.mem())
case ODOT:
return s.newValue2(ssa.OpLoad, n.Type, p, s.mem())
case ODOTPTR:
- p := s.exprPtr(n.Left, false, n.Lineno)
+ p := s.exprPtr(n.Left, false, n.Pos)
p = s.newValue1I(ssa.OpOffPtr, p.Type, n.Xoffset, p)
return s.newValue2(ssa.OpLoad, n.Type, p, s.mem())
if ssa.IsStackAddr(addr) {
s.vars[&memVar] = s.newValue3I(ssa.OpStore, ssa.TypeMem, pt.Size(), addr, r[0], s.mem())
} else {
- s.insertWBstore(pt, addr, r[0], n.Lineno, 0)
+ s.insertWBstore(pt, addr, r[0], n.Pos, 0)
}
// load the value we just stored to avoid having to spill it
s.vars[&ptrVar] = s.newValue2(ssa.OpLoad, pt, addr, s.mem())
addr := s.newValue2(ssa.OpPtrIndex, pt, p2, s.constInt(Types[TINT], int64(i)))
if arg.store {
if haspointers(et) {
- s.insertWBstore(et, addr, arg.v, n.Lineno, 0)
+ s.insertWBstore(et, addr, arg.v, n.Pos, 0)
} else {
s.vars[&memVar] = s.newValue3I(ssa.OpStore, ssa.TypeMem, et.Size(), addr, arg.v, s.mem())
}
} else {
if haspointers(et) {
- s.insertWBmove(et, addr, arg.v, n.Lineno, arg.isVolatile)
+ s.insertWBmove(et, addr, arg.v, n.Pos, arg.isVolatile)
} else {
s.vars[&memVar] = s.newValue3I(ssa.OpMove, ssa.TypeMem, sizeAlignAuxInt(et), addr, arg.v, s.mem())
}
if x.Op == ssa.OpSelect0 || x.Op == ssa.OpSelect1 {
x = x.Args[0]
}
- Warnl(n.Lineno, "intrinsic substitution for %v with %s", n.Left.Sym.Name, x.LongString())
+ Warnl(n.Pos, "intrinsic substitution for %v with %s", n.Left.Sym.Name, x.LongString())
}
return v
}
// We can then pass that to defer or go.
n2 := newname(fn.Sym)
n2.Class = PFUNC
- n2.Lineno = fn.Lineno
+ n2.Pos = fn.Pos
n2.Type = Types[TUINT8] // dummy type for a static closure. Could use runtime.funcval if we had it.
closure = s.expr(n2)
// Note: receiver is already assigned in n.List, so we don't
return s.newValue2(ssa.OpPtrIndex, ptrto(n.Left.Type.Elem()), a, i), isVolatile
}
case OIND:
- return s.exprPtr(n.Left, bounded, n.Lineno), false
+ return s.exprPtr(n.Left, bounded, n.Pos), false
case ODOT:
p, isVolatile := s.addr(n.Left, bounded)
return s.newValue1I(ssa.OpOffPtr, t, n.Xoffset, p), isVolatile
case ODOTPTR:
- p := s.exprPtr(n.Left, bounded, n.Lineno)
+ p := s.exprPtr(n.Left, bounded, n.Pos)
return s.newValue1I(ssa.OpOffPtr, t, n.Xoffset, p), false
case OCLOSUREVAR:
return s.newValue1I(ssa.OpOffPtr, t, n.Xoffset,
if s.noWB {
s.Error("write barrier prohibited")
}
- if !s.WBLineno.IsKnown() {
- s.WBLineno = left.Line
+ if !s.WBPos.IsKnown() {
+ s.WBPos = left.Line
}
var val *ssa.Value
if s.noWB {
s.Error("write barrier prohibited")
}
- if !s.WBLineno.IsKnown() {
- s.WBLineno = left.Line
+ if !s.WBPos.IsKnown() {
+ s.WBPos = left.Line
}
s.storeTypeScalars(t, left, right, skip)
s.storeTypePtrsWB(t, left, right)
// Converting to an empty interface.
// Input could be an empty or nonempty interface.
if Debug_typeassert > 0 {
- Warnl(n.Lineno, "type assertion inlined")
+ Warnl(n.Pos, "type assertion inlined")
}
// Get itab/type field from input.
}
// converting to a nonempty interface needs a runtime call.
if Debug_typeassert > 0 {
- Warnl(n.Lineno, "type assertion not inlined")
+ Warnl(n.Pos, "type assertion not inlined")
}
if n.Left.Type.IsEmptyInterface() {
if commaok {
}
if Debug_typeassert > 0 {
- Warnl(n.Lineno, "type assertion inlined")
+ Warnl(n.Pos, "type assertion inlined")
}
// Converting to a concrete type.
typ := s.ifaceType(n.Left.Type, iface) // actual concrete type of input interface
if Debug_typeassert > 0 {
- Warnl(n.Lineno, "type assertion inlined")
+ Warnl(n.Pos, "type assertion inlined")
}
var tmp *Node // temporary for use with large types
fs = fs.Link
}
- lno := from.Left.Lineno
+ lno := from.Left.Pos
if block != nil {
yyerrorl(lno, "goto %v jumps into block starting at %v", from.Left.Sym, linestr(block.Lastlineno))
} else {
return pc
}
-// SetLineno sets the current source line number.
-func (s *SSAGenState) SetLineno(l src.Pos) {
- lineno = l
+// SetPos sets the current source position.
+func (s *SSAGenState) SetPos(pos src.Pos) {
+ lineno = pos
}
// genssa appends entries to ptxt for each instruction in f.
)
type Error struct {
- lineno src.Pos
- msg string
+ pos src.Pos
+ msg string
}
var errors []Error
return
}
old := fmt.Sprintf("%v: undefined: %v\n", n.Line(), n.Left)
- if len(errors) > 0 && errors[len(errors)-1].lineno == n.Lineno && errors[len(errors)-1].msg == old {
+ if len(errors) > 0 && errors[len(errors)-1].pos.Line() == n.Pos.Line() && errors[len(errors)-1].msg == old {
errors[len(errors)-1].msg = fmt.Sprintf("%v: undefined: %v in %v\n", n.Line(), n.Left, n)
}
}
-func adderr(line src.Pos, format string, args ...interface{}) {
+func adderr(pos src.Pos, format string, args ...interface{}) {
errors = append(errors, Error{
- lineno: line,
- msg: fmt.Sprintf("%v: %s\n", linestr(line), fmt.Sprintf(format, args...)),
+ pos: pos,
+ msg: fmt.Sprintf("%v: %s\n", linestr(pos), fmt.Sprintf(format, args...)),
})
}
-// byLineno sorts errors by lineno.
-type byLineno []Error
+// byPos sorts errors by source position.
+type byPos []Error
-func (x byLineno) Len() int { return len(x) }
-func (x byLineno) Less(i, j int) bool { return x[i].lineno.Before(x[j].lineno) }
-func (x byLineno) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
+func (x byPos) Len() int { return len(x) }
+func (x byPos) Less(i, j int) bool { return x[i].pos.Before(x[j].pos) }
+func (x byPos) Swap(i, j int) { x[i], x[j] = x[j], x[i] }
// flusherrors sorts errors seen so far by line number, prints them to stdout,
// and empties the errors array.
if len(errors) == 0 {
return
}
- sort.Stable(byLineno(errors))
+ sort.Stable(byPos(errors))
for i := 0; i < len(errors); i++ {
if i == 0 || errors[i].msg != errors[i-1].msg {
fmt.Printf("%s", errors[i].msg)
fallthrough
default:
- lineno = n.Lineno
+ lineno = n.Pos
if !lineno.IsKnown() {
if Debug['K'] != 0 {
Warn("setlineno: unknown position (line 0)")
if n == 0 {
// can't possibly be used - there were no symbols
- yyerrorl(pack.Lineno, "imported and not used: %q", opkg.Path)
+ yyerrorl(pack.Pos, "imported and not used: %q", opkg.Path)
}
}
n.Op = op
n.Left = nleft
n.Right = nright
- n.Lineno = lineno
+ n.Pos = lineno
n.Xoffset = BADWIDTH
n.Orig = n
switch op {
m.Right = treecopy(n.Right, lineno)
m.List.Set(listtreecopy(n.List.Slice(), lineno))
if lineno.IsKnown() {
- m.Lineno = lineno
+ m.Pos = lineno
}
if m.Name != nil && n.Op != ODCLFIELD {
Dump("treecopy", n)
// don't have the same iota value.
m := *n
if lineno.IsKnown() {
- m.Lineno = lineno
+ m.Pos = lineno
}
m.SetIota(iota_)
return &m
n := nod(OBLOCK, nil, nil)
n.List.Set(l)
if len(l) != 0 {
- n.Lineno = l[0].Lineno
+ n.Pos = l[0].Pos
}
return n
}
}
for _, n := range prev {
if eqtype(n.Left.Type, c.node.Left.Type) {
- yyerrorl(c.node.Lineno, "duplicate case %v in type switch\n\tprevious case at %v", c.node.Left.Type, n.Line())
+ yyerrorl(c.node.Pos, "duplicate case %v in type switch\n\tprevious case at %v", c.node.Left.Type, n.Line())
// avoid double-reporting errors
continue Outer
}
// Possibly still more uses. If you find any, document them.
Xoffset int64
- Lineno src.Pos
+ Pos src.Pos
Esc uint16 // EscXXX
Label int32 // largest auto-generated label in this function
Endlineno src.Pos
- WBLineno src.Pos // line number of first write barrier
+ WBPos src.Pos // position of first write barrier
Pragma Pragma // go:xxx function annotations
Dupok bool // duplicate definitions ok
Sym *Sym // symbol containing name, for named types
Vargen int32 // unique name for OTYPE/ONAME
- Lineno src.Pos // line at which this type was declared, implicitly or explicitly
+ Pos src.Pos // position at which this type was declared, implicitly or explicitly
Etype EType // kind of type
Noalg bool // suppress hash and eq algorithm generation
// typ returns a new Type of the specified kind.
func typ(et EType) *Type {
t := &Type{
- Etype: et,
- Width: BADWIDTH,
- Lineno: lineno,
+ Etype: et,
+ Width: BADWIDTH,
+ Pos: lineno,
}
t.Orig = t
// TODO(josharian): lazily initialize some of these?
break
}
sprint_depchain(&fmt_, typecheck_tcstack, n, n)
- yyerrorl(n.Lineno, "constant definition loop%s", fmt_)
+ yyerrorl(n.Pos, "constant definition loop%s", fmt_)
}
if nsavederrors+nerrors == 0 {
if alg == ANOEQ {
if bad.Etype == TFORW {
// queue check for map until all the types are done settling.
- mapqueue = append(mapqueue, mapqueueval{l, n.Lineno})
+ mapqueue = append(mapqueue, mapqueueval{l, n.Pos})
} else if bad.Etype != TANY {
// no need to queue, key is already bad
yyerror("invalid map key type %v", l.Type)
if n.Op == ONONAME {
if !n.Diag {
n.Diag = true
- if n.Lineno.IsKnown() {
- lineno = n.Lineno
+ if n.Pos.IsKnown() {
+ lineno = n.Pos
}
// Note: adderrorname looks for this string and
e := n.Name.Defn
n.Name.Defn = nil
if e == nil {
- lineno = n.Lineno
+ lineno = n.Pos
Dump("typecheckdef nil defn", n)
yyerror("xxx")
}
)
func (n *Node) Line() string {
- return Ctxt.LineHist.LineString(int(n.Lineno.Line()))
+ return Ctxt.LineHist.LineString(int(n.Pos.Line()))
}
var atExitFuncs []func()
if defn.Left.Used {
continue
}
- lineno = defn.Left.Lineno
+ lineno = defn.Left.Pos
yyerror("%v declared and not used", ln.Sym)
defn.Left.Used = true // suppress repeats
} else {
- lineno = ln.Lineno
+ lineno = ln.Pos
yyerror("%v declared and not used", ln.Sym)
}
}
func applywritebarrier(n *Node) *Node {
if n.Left != nil && n.Right != nil && needwritebarrier(n.Left, n.Right) {
if Debug_wb > 1 {
- Warnl(n.Lineno, "marking %v for barrier", n.Left)
+ Warnl(n.Pos, "marking %v for barrier", n.Left)
}
n.Op = OASWB
return n
// Enter and Exit lists.
func heapmoves() {
lno := lineno
- lineno = Curfn.Lineno
+ lineno = Curfn.Pos
nn := paramstoheap(Curfn.Type.Recvs())
nn = append(nn, paramstoheap(Curfn.Type.Params())...)
nn = append(nn, paramstoheap(Curfn.Type.Results())...)
opr = brcom(opr)
}
cmp := nod(opr, lhs, rhs)
- cmp.Lineno = n.Lineno
+ cmp.Pos = n.Pos
cmp = addinit(cmp, l.Ninit.Slice())
cmp = addinit(cmp, r.Ninit.Slice())
// Typecheck the AST rooted at cmp...
}
func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
- s.SetLineno(v.Line)
+ s.SetPos(v.Line)
switch v.Op {
case ssa.OpInitMem:
// memory arg needs no code
}
func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
- s.SetLineno(b.Line)
+ s.SetPos(b.Line)
switch b.Kind {
case ssa.BlockPlain:
}
func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
- s.SetLineno(v.Line)
+ s.SetPos(v.Line)
switch v.Op {
case ssa.OpInitMem:
// memory arg needs no code
}
func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
- s.SetLineno(b.Line)
+ s.SetPos(b.Line)
switch b.Kind {
case ssa.BlockPlain:
}
func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
- s.SetLineno(v.Line)
+ s.SetPos(v.Line)
switch v.Op {
case ssa.OpInitMem:
// memory arg needs no code
}
func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
- s.SetLineno(b.Line)
+ s.SetPos(b.Line)
switch b.Kind {
}
func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
- s.SetLineno(v.Line)
+ s.SetPos(v.Line)
switch v.Op {
case ssa.OpS390XSLD, ssa.OpS390XSLW,
ssa.OpS390XSRD, ssa.OpS390XSRW,
}
func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
- s.SetLineno(b.Line)
+ s.SetPos(b.Line)
switch b.Kind {
case ssa.BlockPlain:
}
func ssaGenValue(s *gc.SSAGenState, v *ssa.Value) {
- s.SetLineno(v.Line)
+ s.SetPos(v.Line)
if gc.Thearch.Use387 {
if ssaGenValue387(s, v) {
}
func ssaGenBlock(s *gc.SSAGenState, b, next *ssa.Block) {
- s.SetLineno(b.Line)
+ s.SetPos(b.Line)
if gc.Thearch.Use387 {
// Empty the 387's FP stack before the block ends.