@@ -14,6 +14,7 @@ import (
14
14
"cmd/compile/internal/ssagen"
15
15
"cmd/compile/internal/typecheck"
16
16
"cmd/compile/internal/types"
17
+ "cmd/internal/src"
17
18
"cmd/internal/sys"
18
19
)
19
20
@@ -58,7 +59,7 @@ func walkConvInterface(n *ir.ConvExpr, init *ir.Nodes) ir.Node {
58
59
} else {
59
60
typeWord = reflectdata .ITabAddr (fromType , toType )
60
61
}
61
- l := ir .NewBinaryExpr (base .Pos , ir .OEFACE , typeWord , dataWord (n .X , init , n .Esc () != ir .EscNone ))
62
+ l := ir .NewBinaryExpr (base .Pos , ir .OEFACE , typeWord , dataWord (n .Pos (), n . X , init , n .Esc () != ir .EscNone ))
62
63
l .SetType (toType )
63
64
l .SetTypecheck (n .Typecheck ())
64
65
return l
@@ -75,7 +76,7 @@ func walkConvInterface(n *ir.ConvExpr, init *ir.Nodes) ir.Node {
75
76
itab := ir .NewUnaryExpr (base .Pos , ir .OITAB , c )
76
77
itab .SetType (types .Types [types .TUINTPTR ].PtrTo ())
77
78
itab .SetTypecheck (1 )
78
- data := ir .NewUnaryExpr (base .Pos , ir .OIDATA , c )
79
+ data := ir .NewUnaryExpr (n .Pos () , ir .OIDATA , c )
79
80
data .SetType (types .Types [types .TUINT8 ].PtrTo ()) // Type is generic pointer - we're just passing it through.
80
81
data .SetTypecheck (1 )
81
82
@@ -112,7 +113,7 @@ func walkConvInterface(n *ir.ConvExpr, init *ir.Nodes) ir.Node {
112
113
// Returns the data word (the second word) used to represent n in an interface.
113
114
// n must not be of interface type.
114
115
// esc describes whether the result escapes.
115
- func dataWord (n ir.Node , init * ir.Nodes , escapes bool ) ir.Node {
116
+ func dataWord (pos src. XPos , n ir.Node , init * ir.Nodes , escapes bool ) ir.Node {
116
117
fromType := n .Type ()
117
118
118
119
// If it's a pointer, it is its own representation.
@@ -184,16 +185,16 @@ func dataWord(n ir.Node, init *ir.Nodes, escapes bool) ir.Node {
184
185
fromType .IsPtrShaped () && argType .IsPtrShaped ():
185
186
// can directly convert (e.g. named type to underlying type, or one pointer to another)
186
187
// TODO: never happens because pointers are directIface?
187
- arg = ir .NewConvExpr (n . Pos () , ir .OCONVNOP , argType , n )
188
+ arg = ir .NewConvExpr (pos , ir .OCONVNOP , argType , n )
188
189
case fromType .IsInteger () && argType .IsInteger ():
189
190
// can directly convert (e.g. int32 to uint32)
190
- arg = ir .NewConvExpr (n . Pos () , ir .OCONV , argType , n )
191
+ arg = ir .NewConvExpr (pos , ir .OCONV , argType , n )
191
192
default :
192
193
// unsafe cast through memory
193
194
arg = copyExpr (n , fromType , init )
194
195
var addr ir.Node = typecheck .NodAddr (arg )
195
- addr = ir .NewConvExpr (n . Pos () , ir .OCONVNOP , argType .PtrTo (), addr )
196
- arg = ir .NewStarExpr (n . Pos () , addr )
196
+ addr = ir .NewConvExpr (pos , ir .OCONVNOP , argType .PtrTo (), addr )
197
+ arg = ir .NewStarExpr (pos , addr )
197
198
arg .SetType (argType )
198
199
}
199
200
args = []ir.Node {arg }
@@ -206,7 +207,7 @@ func dataWord(n ir.Node, init *ir.Nodes, escapes bool) ir.Node {
206
207
// walkConvIData walks an OCONVIDATA node.
207
208
func walkConvIData (n * ir.ConvExpr , init * ir.Nodes ) ir.Node {
208
209
n .X = walkExpr (n .X , init )
209
- return dataWord (n .X , init , n .Esc () != ir .EscNone )
210
+ return dataWord (n .Pos (), n . X , init , n .Esc () != ir .EscNone )
210
211
}
211
212
212
213
// walkBytesRunesToString walks an OBYTES2STR or ORUNES2STR node.
0 commit comments