Skip to content

Commit 75831d2

Browse files
committed
go/ssa: add position data in indexed range loops
Indexed range loops are lacking position data in their SSA representation, so add the position data into an index operation This improves the problem described in golang/go#31008 by providing position data with the nilness message
1 parent 2a6ccf2 commit 75831d2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

go/ssa/builder.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,6 +1746,7 @@ func (b *builder) rangeIndexed(fn *Function, x Value, tv types.Type, pos token.P
17461746
Index: k,
17471747
}
17481748
instr.setType(t.Elem())
1749+
instr.setPos(x.Pos())
17491750
v = fn.emit(instr)
17501751

17511752
case *types.Pointer: // *array
@@ -1754,6 +1755,7 @@ func (b *builder) rangeIndexed(fn *Function, x Value, tv types.Type, pos token.P
17541755
Index: k,
17551756
}
17561757
instr.setType(types.NewPointer(t.Elem().Underlying().(*types.Array).Elem()))
1758+
instr.setPos(x.Pos())
17571759
v = emitLoad(fn, fn.emit(instr))
17581760

17591761
case *types.Slice:
@@ -1762,6 +1764,7 @@ func (b *builder) rangeIndexed(fn *Function, x Value, tv types.Type, pos token.P
17621764
Index: k,
17631765
}
17641766
instr.setType(types.NewPointer(t.Elem()))
1767+
instr.setPos(x.Pos())
17651768
v = emitLoad(fn, fn.emit(instr))
17661769

17671770
default:

0 commit comments

Comments
 (0)