aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josharian@gmail.com>2020-04-13 23:29:17 -0700
committerJosh Bleecher Snyder <josharian@gmail.com>2020-04-14 17:43:56 +0000
commit02ab2c040e20dac433a2a7e1bfca29d3071733ae (patch)
tree11a2b06d54837a3158c54a68a1bc5355f565c322 /src
parentae253719a2f5ff26899d6c989fcfed3bbef3f926 (diff)
downloadgo-02ab2c040e20dac433a2a7e1bfca29d3071733ae.tar.xz
cmd/compile: make ifaceData accept a position
This lets us provide a better position in its use in swt.go. Change-Id: I7c0da6bd0adea81acfc9a591e6a01b241a5e0942 Reviewed-on: https://go-review.googlesource.com/c/go/+/228219 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/gc/subr.go14
-rw-r--r--src/cmd/compile/internal/gc/swt.go2
-rw-r--r--src/cmd/compile/internal/gc/walk.go4
3 files changed, 13 insertions, 7 deletions
diff --git a/src/cmd/compile/internal/gc/subr.go b/src/cmd/compile/internal/gc/subr.go
index 7805079a63..ff0fffb9bd 100644
--- a/src/cmd/compile/internal/gc/subr.go
+++ b/src/cmd/compile/internal/gc/subr.go
@@ -376,7 +376,13 @@ func newnamel(pos src.XPos, s *types.Sym) *Node {
// nodSym makes a Node with Op op and with the Left field set to left
// and the Sym field set to sym. This is for ODOT and friends.
func nodSym(op Op, left *Node, sym *types.Sym) *Node {
- n := nod(op, left, nil)
+ return nodlSym(lineno, op, left, sym)
+}
+
+// nodlSym makes a Node with position Pos, with Op op, and with the Left field set to left
+// and the Sym field set to sym. This is for ODOT and friends.
+func nodlSym(pos src.XPos, op Op, left *Node, sym *types.Sym) *Node {
+ n := nodl(pos, op, left, nil)
n.Sym = sym
return n
}
@@ -1896,11 +1902,11 @@ func itabType(itab *Node) *Node {
// ifaceData loads the data field from an interface.
// The concrete type must be known to have type t.
// It follows the pointer if !isdirectiface(t).
-func ifaceData(n *Node, t *types.Type) *Node {
+func ifaceData(pos src.XPos, n *Node, t *types.Type) *Node {
if t.IsInterface() {
Fatalf("ifaceData interface: %v", t)
}
- ptr := nodSym(OIDATA, n, nil)
+ ptr := nodlSym(pos, OIDATA, n, nil)
if isdirectiface(t) {
ptr.Type = t
ptr.SetTypecheck(1)
@@ -1909,7 +1915,7 @@ func ifaceData(n *Node, t *types.Type) *Node {
ptr.Type = types.NewPtr(t)
ptr.SetBounded(true)
ptr.SetTypecheck(1)
- ind := nod(ODEREF, ptr, nil)
+ ind := nodl(pos, ODEREF, ptr, nil)
ind.Type = t
ind.SetTypecheck(1)
return ind
diff --git a/src/cmd/compile/internal/gc/swt.go b/src/cmd/compile/internal/gc/swt.go
index 6c931f2dab..88c8ea8146 100644
--- a/src/cmd/compile/internal/gc/swt.go
+++ b/src/cmd/compile/internal/gc/swt.go
@@ -584,7 +584,7 @@ func walkTypeSwitch(sw *Node) {
if singleType.IsInterface() {
Fatalf("singleType interface should have been handled in Add")
}
- val = ifaceData(s.facename, singleType)
+ val = ifaceData(ncase.Pos, s.facename, singleType)
}
l := []*Node{
nodl(ncase.Pos, ODCL, caseVar, nil),
diff --git a/src/cmd/compile/internal/gc/walk.go b/src/cmd/compile/internal/gc/walk.go
index 56062f8c57..bf12455a5d 100644
--- a/src/cmd/compile/internal/gc/walk.go
+++ b/src/cmd/compile/internal/gc/walk.go
@@ -886,7 +886,7 @@ opswitch:
init.Append(nif)
// Build the result.
- e := nod(OEFACE, tmp, ifaceData(c, types.NewPtr(types.Types[TUINT8])))
+ e := nod(OEFACE, tmp, ifaceData(n.Pos, c, types.NewPtr(types.Types[TUINT8])))
e.Type = toType // assign type manually, typecheck doesn't understand OEFACE.
e.SetTypecheck(1)
n = e
@@ -3165,7 +3165,7 @@ func walkcompare(n *Node, init *Nodes) *Node {
eqtype = nod(andor, nonnil, match)
}
// Check for data equal.
- eqdata := nod(eq, ifaceData(l, r.Type), r)
+ eqdata := nod(eq, ifaceData(n.Pos, l, r.Type), r)
// Put it all together.
expr := nod(andor, eqtype, eqdata)
n = finishcompare(n, expr, init)