Commit b2e7eae7 authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile: remove Local flags on Type and Node

These are redundant with checking x.Sym.Pkg == localpkg.

Passes toolstash-check -all.

Change-Id: Iebe25f7932cd15a036141b468ad75c239abcdcf7
Reviewed-on: https://go-review.googlesource.com/66670
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
parent e59fe206
...@@ -495,7 +495,6 @@ func walkclosure(func_ *Node, init *Nodes) *Node { ...@@ -495,7 +495,6 @@ func walkclosure(func_ *Node, init *Nodes) *Node {
} }
typ := tostruct(fields) typ := tostruct(fields)
typ.SetNoalg(true) typ.SetNoalg(true)
typ.SetLocal(true)
clos := nod(OCOMPLIT, nil, nod(OIND, typenod(typ), nil)) clos := nod(OCOMPLIT, nil, nod(OIND, typenod(typ), nil))
clos.Esc = func_.Esc clos.Esc = func_.Esc
...@@ -689,7 +688,6 @@ func walkpartialcall(n *Node, init *Nodes) *Node { ...@@ -689,7 +688,6 @@ func walkpartialcall(n *Node, init *Nodes) *Node {
namedfield("R", n.Left.Type), namedfield("R", n.Left.Type),
}) })
typ.SetNoalg(true) typ.SetNoalg(true)
typ.SetLocal(true)
clos := nod(OCOMPLIT, nil, nod(OIND, typenod(typ), nil)) clos := nod(OCOMPLIT, nil, nod(OIND, typenod(typ), nil))
clos.Esc = n.Esc clos.Esc = n.Esc
......
...@@ -975,7 +975,7 @@ func addmethod(msym *types.Sym, t *types.Type, local, nointerface bool) { ...@@ -975,7 +975,7 @@ func addmethod(msym *types.Sym, t *types.Type, local, nointerface bool) {
return return
} }
if local && !mt.Local() { if local && mt.Sym.Pkg != localpkg {
yyerror("cannot define new methods on non-local type %v", mt) yyerror("cannot define new methods on non-local type %v", mt)
return return
} }
......
...@@ -322,7 +322,6 @@ func (p *noder) typeDecl(decl *syntax.TypeDecl) *Node { ...@@ -322,7 +322,6 @@ func (p *noder) typeDecl(decl *syntax.TypeDecl) *Node {
n := p.declName(decl.Name) n := p.declName(decl.Name)
n.Op = OTYPE n.Op = OTYPE
declare(n, dclcontext) declare(n, dclcontext)
n.SetLocal(true)
// decl.Type may be nil but in that case we got a syntax error during parsing // decl.Type may be nil but in that case we got a syntax error during parsing
typ := p.typeExprOrNil(decl.Type) typ := p.typeExprOrNil(decl.Type)
......
...@@ -166,7 +166,6 @@ func bmap(t *types.Type) *types.Type { ...@@ -166,7 +166,6 @@ func bmap(t *types.Type) *types.Type {
// link up fields // link up fields
bucket.SetNoalg(true) bucket.SetNoalg(true)
bucket.SetLocal(t.Local())
bucket.SetFields(field[:]) bucket.SetFields(field[:])
dowidth(bucket) dowidth(bucket)
...@@ -262,7 +261,6 @@ func hmap(t *types.Type) *types.Type { ...@@ -262,7 +261,6 @@ func hmap(t *types.Type) *types.Type {
hmap := types.New(TSTRUCT) hmap := types.New(TSTRUCT)
hmap.SetNoalg(true) hmap.SetNoalg(true)
hmap.SetLocal(t.Local())
hmap.SetFields(fields) hmap.SetFields(fields)
dowidth(hmap) dowidth(hmap)
...@@ -1167,7 +1165,7 @@ func dtypesym(t *types.Type) *types.Sym { ...@@ -1167,7 +1165,7 @@ func dtypesym(t *types.Type) *types.Sym {
if myimportpath != "runtime" || (tbase != types.Types[tbase.Etype] && tbase != types.Bytetype && tbase != types.Runetype && tbase != types.Errortype) { // int, float, etc if myimportpath != "runtime" || (tbase != types.Types[tbase.Etype] && tbase != types.Bytetype && tbase != types.Runetype && tbase != types.Errortype) { // int, float, etc
// named types from other files are defined only by those files // named types from other files are defined only by those files
if tbase.Sym != nil && !tbase.Local() { if tbase.Sym != nil && tbase.Sym.Pkg != localpkg {
return s return s
} }
// TODO(mdempsky): Investigate whether this can happen. // TODO(mdempsky): Investigate whether this can happen.
......
...@@ -342,7 +342,6 @@ func selecttype(size int64) *types.Type { ...@@ -342,7 +342,6 @@ func selecttype(size int64) *types.Type {
namedfield("releasetime", types.Types[TUINT64]), namedfield("releasetime", types.Types[TUINT64]),
}) })
scase.SetNoalg(true) scase.SetNoalg(true)
scase.SetLocal(true)
sel := tostruct([]*Node{ sel := tostruct([]*Node{
namedfield("tcase", types.Types[TUINT16]), namedfield("tcase", types.Types[TUINT16]),
...@@ -354,7 +353,6 @@ func selecttype(size int64) *types.Type { ...@@ -354,7 +353,6 @@ func selecttype(size int64) *types.Type {
namedfield("pollorderarr", types.NewArray(types.Types[TUINT16], size)), namedfield("pollorderarr", types.NewArray(types.Types[TUINT16], size)),
}) })
sel.SetNoalg(true) sel.SetNoalg(true)
sel.SetLocal(true)
return sel return sel
} }
...@@ -86,7 +86,6 @@ const ( ...@@ -86,7 +86,6 @@ const (
_, nodeAddrtaken // address taken, even if not moved to heap _, nodeAddrtaken // address taken, even if not moved to heap
_, nodeImplicit _, nodeImplicit
_, nodeIsddd // is the argument variadic _, nodeIsddd // is the argument variadic
_, nodeLocal // type created in this file (see also Type.Local)
_, nodeDiag // already printed error about this _, nodeDiag // already printed error about this
_, nodeColas // OAS resulting from := _, nodeColas // OAS resulting from :=
_, nodeNonNil // guaranteed to be non-nil _, nodeNonNil // guaranteed to be non-nil
...@@ -113,7 +112,6 @@ func (n *Node) Assigned() bool { return n.flags&nodeAssigned != 0 } ...@@ -113,7 +112,6 @@ func (n *Node) Assigned() bool { return n.flags&nodeAssigned != 0 }
func (n *Node) Addrtaken() bool { return n.flags&nodeAddrtaken != 0 } func (n *Node) Addrtaken() bool { return n.flags&nodeAddrtaken != 0 }
func (n *Node) Implicit() bool { return n.flags&nodeImplicit != 0 } func (n *Node) Implicit() bool { return n.flags&nodeImplicit != 0 }
func (n *Node) Isddd() bool { return n.flags&nodeIsddd != 0 } func (n *Node) Isddd() bool { return n.flags&nodeIsddd != 0 }
func (n *Node) Local() bool { return n.flags&nodeLocal != 0 }
func (n *Node) Diag() bool { return n.flags&nodeDiag != 0 } func (n *Node) Diag() bool { return n.flags&nodeDiag != 0 }
func (n *Node) Colas() bool { return n.flags&nodeColas != 0 } func (n *Node) Colas() bool { return n.flags&nodeColas != 0 }
func (n *Node) NonNil() bool { return n.flags&nodeNonNil != 0 } func (n *Node) NonNil() bool { return n.flags&nodeNonNil != 0 }
...@@ -139,7 +137,6 @@ func (n *Node) SetAssigned(b bool) { n.flags.set(nodeAssigned, b) } ...@@ -139,7 +137,6 @@ func (n *Node) SetAssigned(b bool) { n.flags.set(nodeAssigned, b) }
func (n *Node) SetAddrtaken(b bool) { n.flags.set(nodeAddrtaken, b) } func (n *Node) SetAddrtaken(b bool) { n.flags.set(nodeAddrtaken, b) }
func (n *Node) SetImplicit(b bool) { n.flags.set(nodeImplicit, b) } func (n *Node) SetImplicit(b bool) { n.flags.set(nodeImplicit, b) }
func (n *Node) SetIsddd(b bool) { n.flags.set(nodeIsddd, b) } func (n *Node) SetIsddd(b bool) { n.flags.set(nodeIsddd, b) }
func (n *Node) SetLocal(b bool) { n.flags.set(nodeLocal, b) }
func (n *Node) SetDiag(b bool) { n.flags.set(nodeDiag, b) } func (n *Node) SetDiag(b bool) { n.flags.set(nodeDiag, b) }
func (n *Node) SetColas(b bool) { n.flags.set(nodeColas, b) } func (n *Node) SetColas(b bool) { n.flags.set(nodeColas, b) }
func (n *Node) SetNonNil(b bool) { n.flags.set(nodeNonNil, b) } func (n *Node) SetNonNil(b bool) { n.flags.set(nodeNonNil, b) }
......
...@@ -3524,7 +3524,6 @@ func copytype(n *Node, t *types.Type) { ...@@ -3524,7 +3524,6 @@ func copytype(n *Node, t *types.Type) {
t = n.Type t = n.Type
t.Sym = n.Sym t.Sym = n.Sym
t.SetLocal(n.Local())
if n.Name != nil { if n.Name != nil {
t.Vargen = n.Name.Vargen t.Vargen = n.Name.Vargen
} }
......
...@@ -162,22 +162,19 @@ type Type struct { ...@@ -162,22 +162,19 @@ type Type struct {
} }
const ( const (
typeLocal = 1 << iota // created in this file typeNotInHeap = 1 << iota // type cannot be heap allocated
typeNotInHeap // type cannot be heap allocated
typeBroke // broken type definition typeBroke // broken type definition
typeNoalg // suppress hash and eq algorithm generation typeNoalg // suppress hash and eq algorithm generation
typeDeferwidth typeDeferwidth
typeRecur typeRecur
) )
func (t *Type) Local() bool { return t.flags&typeLocal != 0 }
func (t *Type) NotInHeap() bool { return t.flags&typeNotInHeap != 0 } func (t *Type) NotInHeap() bool { return t.flags&typeNotInHeap != 0 }
func (t *Type) Broke() bool { return t.flags&typeBroke != 0 } func (t *Type) Broke() bool { return t.flags&typeBroke != 0 }
func (t *Type) Noalg() bool { return t.flags&typeNoalg != 0 } func (t *Type) Noalg() bool { return t.flags&typeNoalg != 0 }
func (t *Type) Deferwidth() bool { return t.flags&typeDeferwidth != 0 } func (t *Type) Deferwidth() bool { return t.flags&typeDeferwidth != 0 }
func (t *Type) Recur() bool { return t.flags&typeRecur != 0 } func (t *Type) Recur() bool { return t.flags&typeRecur != 0 }
func (t *Type) SetLocal(b bool) { t.flags.set(typeLocal, b) }
func (t *Type) SetNotInHeap(b bool) { t.flags.set(typeNotInHeap, b) } func (t *Type) SetNotInHeap(b bool) { t.flags.set(typeNotInHeap, b) }
func (t *Type) SetBroke(b bool) { t.flags.set(typeBroke, b) } func (t *Type) SetBroke(b bool) { t.flags.set(typeBroke, b) }
func (t *Type) SetNoalg(b bool) { t.flags.set(typeNoalg, b) } func (t *Type) SetNoalg(b bool) { t.flags.set(typeNoalg, b) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment