Skip to content

Commit ac4f524

Browse files
vovapifindleyr
authored andcommitted
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 nilness output by providing position data with the message. Updates golang/go#31008 Change-Id: I664c8668bc74207e770657e21129d20fd70e7af6 GitHub-Last-Rev: 75831d2 GitHub-Pull-Request: #190 Reviewed-on: https://go-review.googlesource.com/c/tools/+/208599 Run-TryBot: Robert Findley <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 89082a3 commit ac4f524

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)