mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.typeparams] all: merge dev.regabi (07569da) into dev.typeparams
Conflicts: - test/fixedbugs/issue27595.go - test/fixedbugs/issue30087.go - test/used.go Merge List: + 2020-12-2807569dac4e[dev.regabi] all: merge master (1d78139) into dev.regabi + 2020-12-2876136be027[dev.regabi] cmd/compile: check for recursive import in ImportBody + 2020-12-28fda7ec3a3f[dev.regabi] cmd/compile: remove Name.IsDDD, etc + 2020-12-28098a6490b9[dev.regabi] cmd/compile: remove Declare in makepartialcall + 2020-12-28137f0d2e06[dev.regabi] cmd/compile: remove unnecessary Name.Sym call + 2020-12-283383b5c74a[dev.regabi] cmd/compile: flatten dependency graph [generated] + 2020-12-28f8afb8216a[dev.regabi] cmd/compile: rename CommStmt and CaseStmt [generated] + 2020-12-285f3bd59a0d[dev.regabi] cmd/compile: remove some unneeded code in package ir + 2020-12-283bdafb0d82[dev.regabi] cmd/compile: remove CommStmt.List + 2020-12-282ecf52b841[dev.regabi] cmd/compile: separate CommStmt from CaseStmt + 2020-12-28ed9772e130[dev.regabi] cmd/compile: add explicit file name in types generation + 2020-12-28a59d26603f[dev.regabi] cmd/compile: use []*CaseStmt in {Select,Switch}Stmt + 2020-12-28fbc4458c06[dev.regabi] cmd/compile: simplify some tree traversal code + 2020-12-286c67677541[dev.regabi] cmd/compile: simplify FuncName and PkgFuncName + 2020-12-28676d794b81[dev.regabi] cmd/compile: remove refersToCommonName + 2020-12-28c98548e110[dev.regabi] cmd/compile: merge ascompatee, ascompatee1, and reorder3 + 2020-12-284c215c4fa9[dev.regabi] cmd/compile: simplify and optimize reorder3 + 2020-12-28e6c973198d[dev.regabi] cmd/compile: stop mangling SelectorExpr.Sel for ODOTMETH + 2020-12-28135ce1c485[dev.regabi] cmd/compile: desugar OMETHEXPR into ONAME during walk + 2020-12-280f732f8c91[dev.regabi] cmd/compile: minor walkExpr cleanups + 2020-12-280de8eafd98[dev.regabi] cmd/compile: remove SelectorExpr.Offset field + 2020-12-28a4f335f420[dev.regabi] cmd/compile: always use a Field for ODOTPTR expressions + 2020-12-261d78139128runtime/cgo: fix Android build with NDK 22 + 2020-12-252018b68a65net/mail: don't use MDT in test + 2020-12-25e4f293d853[dev.regabi] cmd/compile: fix OCALLMETH desugaring + 2020-12-251d9a1f67d5[dev.regabi] cmd/compile: don't emit reflect data for method types + 2020-12-25396b6c2e7c[dev.regabi] cmd/compile: cleanup assignment typechecking + 2020-12-25e24d2f3d05[dev.regabi] cmd/compile: remove typ from RangeStmt + 2020-12-252785c691c2[dev.regabi] cmd/compile: cleanup devirtualization docs + 2020-12-254b1d0fe66f[dev.regabi] cmd/compile: new devirtualization pkg [generated] + 2020-12-24082cc8b7d9[dev.regabi] cmd/compile: change ir.IsAssignable -> ir.IsAddressable + 2020-12-2427b248b307[dev.regabi] cmd/compile: separate range stmt Vars to Key, Value nodes + 2020-12-2340818038bf[dev.regabi] cmd/compile: change CaseStmt.Vars to Var + 2020-12-23b116404444runtime: shift timeHistogram buckets and allow negative durations + 2020-12-238db7e2fecdruntime: fix allocs-by-size and frees-by-size buckets + 2020-12-23fb96f07e1aruntime: fix nStackRoots comment about stack roots + 2020-12-23d1502b3c72lib/time, time/tzdata: update tzdata to 2020e + 2020-12-2330c99cbb7acmd/go: add the Retract field to 'go help mod edit' definition of the GoMod struct + 2020-12-2349d0b239cbdoc: fix a typo in contribute.html + 2020-12-239eeed291bc[dev.regabi] cmd/compile: eliminate usage of ir.Node in liveness + 2020-12-23d1d64e4cea[dev.regabi] cmd/compile: split SliceExpr.List into separate fields + 2020-12-2398a73030b0cmd/go: in 'go get', promote named implicit dependencies to explicit + 2020-12-23d19018e8f1[dev.regabi] cmd/compile: split SliceHeaderExpr.LenCap into separate fields + 2020-12-2353f082b0ee[dev.regabi] cmd/compile: cleanup export code further + 2020-12-2331267f82e1[dev.regabi] cmd/compile: simplify function/interface/struct typechecking + 2020-12-23addade2cce[dev.regabi] cmd/compile: prefer types constructors over typecheck + 2020-12-2318ebfb49e9[dev.regabi] cmd/compile: cleanup noder + 2020-12-2387a592b356[dev.regabi] cmd/compile: cleanup import/export code + 2020-12-235898025026[dev.regabi] cmd/compile: update mkbuiltin.go to use new type constructors + 2020-12-2363c96c2ee7[dev.regabi] cmd/compile: update mkbuiltin.go and re-enable TestBuiltin + 2020-12-23fd6ba1c8a2os/signal: fix a deadlock with syscall.AllThreadsSyscall() use + 2020-12-23b0b0d98283runtime: linux iscgo support for not blocking nptl signals + 2020-12-22223331fc0ccmd/go/internal/modload: add hint for missing implicit dependency Change-Id: Iecb8a7dfb401b6ab383e97101cd81bfc201683f6
This commit is contained in:
commit
a800acaae1
90 changed files with 8552 additions and 8722 deletions
|
|
@ -510,11 +510,7 @@ func (p *noder) importDecl(imp *syntax.ImportDecl) {
|
|||
func (p *noder) varDecl(decl *syntax.VarDecl) []ir.Node {
|
||||
names := p.declNames(ir.ONAME, decl.NameList)
|
||||
typ := p.typeExprOrNil(decl.Type)
|
||||
|
||||
var exprs []ir.Node
|
||||
if decl.Values != nil {
|
||||
exprs = p.exprList(decl.Values)
|
||||
}
|
||||
exprs := p.exprList(decl.Values)
|
||||
|
||||
if pragma, ok := decl.Pragma.(*pragmas); ok {
|
||||
if len(pragma.Embeds) > 0 {
|
||||
|
|
@ -753,10 +749,14 @@ func (p *noder) param(param *syntax.Field, dddOk, final bool) *ir.Field {
|
|||
}
|
||||
|
||||
func (p *noder) exprList(expr syntax.Expr) []ir.Node {
|
||||
if list, ok := expr.(*syntax.ListExpr); ok {
|
||||
return p.exprs(list.ElemList)
|
||||
switch expr := expr.(type) {
|
||||
case nil:
|
||||
return nil
|
||||
case *syntax.ListExpr:
|
||||
return p.exprs(expr.ElemList)
|
||||
default:
|
||||
return []ir.Node{p.expr(expr)}
|
||||
}
|
||||
return []ir.Node{p.expr(expr)}
|
||||
}
|
||||
|
||||
func (p *noder) exprs(exprs []syntax.Expr) []ir.Node {
|
||||
|
|
@ -775,17 +775,14 @@ func (p *noder) expr(expr syntax.Expr) ir.Node {
|
|||
case *syntax.Name:
|
||||
return p.mkname(expr)
|
||||
case *syntax.BasicLit:
|
||||
n := ir.NewLiteral(p.basicLit(expr))
|
||||
n := ir.NewBasicLit(p.pos(expr), p.basicLit(expr))
|
||||
if expr.Kind == syntax.RuneLit {
|
||||
n.SetType(types.UntypedRune)
|
||||
}
|
||||
n.SetDiag(expr.Bad) // avoid follow-on errors if there was a syntax error
|
||||
return n
|
||||
case *syntax.CompositeLit:
|
||||
n := ir.NewCompLitExpr(p.pos(expr), ir.OCOMPLIT, nil, nil)
|
||||
if expr.Type != nil {
|
||||
n.Ntype = ir.Node(p.expr(expr.Type)).(ir.Ntype)
|
||||
}
|
||||
n := ir.NewCompLitExpr(p.pos(expr), ir.OCOMPLIT, p.typeExpr(expr.Type), nil)
|
||||
l := p.exprs(expr.ElemList)
|
||||
for i, e := range l {
|
||||
l[i] = p.wrapname(expr.ElemList[i], e)
|
||||
|
|
@ -818,17 +815,16 @@ func (p *noder) expr(expr syntax.Expr) ir.Node {
|
|||
if expr.Full {
|
||||
op = ir.OSLICE3
|
||||
}
|
||||
n := ir.NewSliceExpr(p.pos(expr), op, p.expr(expr.X))
|
||||
x := p.expr(expr.X)
|
||||
var index [3]ir.Node
|
||||
for i, x := range &expr.Index {
|
||||
if x != nil {
|
||||
index[i] = p.expr(x)
|
||||
for i, n := range &expr.Index {
|
||||
if n != nil {
|
||||
index[i] = p.expr(n)
|
||||
}
|
||||
}
|
||||
n.SetSliceBounds(index[0], index[1], index[2])
|
||||
return n
|
||||
return ir.NewSliceExpr(p.pos(expr), op, x, index[0], index[1], index[2])
|
||||
case *syntax.AssertExpr:
|
||||
return ir.NewTypeAssertExpr(p.pos(expr), p.expr(expr.X), p.typeExpr(expr.Type).(ir.Ntype))
|
||||
return ir.NewTypeAssertExpr(p.pos(expr), p.expr(expr.X), p.typeExpr(expr.Type))
|
||||
case *syntax.Operation:
|
||||
if expr.Op == syntax.Add && expr.Y != nil {
|
||||
return p.sum(expr)
|
||||
|
|
@ -852,8 +848,7 @@ func (p *noder) expr(expr syntax.Expr) ir.Node {
|
|||
}
|
||||
return ir.NewBinaryExpr(pos, op, x, y)
|
||||
case *syntax.CallExpr:
|
||||
n := ir.NewCallExpr(p.pos(expr), ir.OCALL, p.expr(expr.Fun), nil)
|
||||
n.Args.Set(p.exprs(expr.ArgList))
|
||||
n := ir.NewCallExpr(p.pos(expr), ir.OCALL, p.expr(expr.Fun), p.exprs(expr.ArgList))
|
||||
n.IsDDD = expr.HasDots
|
||||
return n
|
||||
|
||||
|
|
@ -1120,7 +1115,7 @@ func (p *noder) stmt(stmt syntax.Stmt) ir.Node {
|
|||
func (p *noder) stmtFall(stmt syntax.Stmt, fallOK bool) ir.Node {
|
||||
p.setlineno(stmt)
|
||||
switch stmt := stmt.(type) {
|
||||
case *syntax.EmptyStmt:
|
||||
case nil, *syntax.EmptyStmt:
|
||||
return nil
|
||||
case *syntax.LabeledStmt:
|
||||
return p.labeledStmt(stmt, fallOK)
|
||||
|
|
@ -1193,12 +1188,7 @@ func (p *noder) stmtFall(stmt syntax.Stmt, fallOK bool) ir.Node {
|
|||
}
|
||||
return ir.NewGoDeferStmt(p.pos(stmt), op, p.expr(stmt.Call))
|
||||
case *syntax.ReturnStmt:
|
||||
var results []ir.Node
|
||||
if stmt.Results != nil {
|
||||
results = p.exprList(stmt.Results)
|
||||
}
|
||||
n := ir.NewReturnStmt(p.pos(stmt), nil)
|
||||
n.Results.Set(results)
|
||||
n := ir.NewReturnStmt(p.pos(stmt), p.exprList(stmt.Results))
|
||||
if len(n.Results) == 0 && ir.CurFunc != nil {
|
||||
for _, ln := range ir.CurFunc.Dcl {
|
||||
if ln.Class_ == ir.PPARAM {
|
||||
|
|
@ -1292,14 +1282,11 @@ func (p *noder) blockStmt(stmt *syntax.BlockStmt) []ir.Node {
|
|||
|
||||
func (p *noder) ifStmt(stmt *syntax.IfStmt) ir.Node {
|
||||
p.openScope(stmt.Pos())
|
||||
n := ir.NewIfStmt(p.pos(stmt), nil, nil, nil)
|
||||
if stmt.Init != nil {
|
||||
*n.PtrInit() = []ir.Node{p.stmt(stmt.Init)}
|
||||
init := p.stmt(stmt.Init)
|
||||
n := ir.NewIfStmt(p.pos(stmt), p.expr(stmt.Cond), p.blockStmt(stmt.Then), nil)
|
||||
if init != nil {
|
||||
*n.PtrInit() = []ir.Node{init}
|
||||
}
|
||||
if stmt.Cond != nil {
|
||||
n.Cond = p.expr(stmt.Cond)
|
||||
}
|
||||
n.Body.Set(p.blockStmt(stmt.Then))
|
||||
if stmt.Else != nil {
|
||||
e := p.stmt(stmt.Else)
|
||||
if e.Op() == ir.OBLOCK {
|
||||
|
|
@ -1320,53 +1307,46 @@ func (p *noder) forStmt(stmt *syntax.ForStmt) ir.Node {
|
|||
panic("unexpected RangeClause")
|
||||
}
|
||||
|
||||
n := ir.NewRangeStmt(p.pos(r), nil, p.expr(r.X), nil)
|
||||
n := ir.NewRangeStmt(p.pos(r), nil, nil, p.expr(r.X), nil)
|
||||
if r.Lhs != nil {
|
||||
n.Def = r.Def
|
||||
n.Vars.Set(p.assignList(r.Lhs, n, n.Def))
|
||||
lhs := p.assignList(r.Lhs, n, n.Def)
|
||||
n.Key = lhs[0]
|
||||
if len(lhs) > 1 {
|
||||
n.Value = lhs[1]
|
||||
}
|
||||
}
|
||||
n.Body.Set(p.blockStmt(stmt.Body))
|
||||
p.closeAnotherScope()
|
||||
return n
|
||||
}
|
||||
|
||||
n := ir.NewForStmt(p.pos(stmt), nil, nil, nil, nil)
|
||||
if stmt.Init != nil {
|
||||
*n.PtrInit() = []ir.Node{p.stmt(stmt.Init)}
|
||||
}
|
||||
if stmt.Cond != nil {
|
||||
n.Cond = p.expr(stmt.Cond)
|
||||
}
|
||||
if stmt.Post != nil {
|
||||
n.Post = p.stmt(stmt.Post)
|
||||
}
|
||||
n.Body.Set(p.blockStmt(stmt.Body))
|
||||
n := ir.NewForStmt(p.pos(stmt), p.stmt(stmt.Init), p.expr(stmt.Cond), p.stmt(stmt.Post), p.blockStmt(stmt.Body))
|
||||
p.closeAnotherScope()
|
||||
return n
|
||||
}
|
||||
|
||||
func (p *noder) switchStmt(stmt *syntax.SwitchStmt) ir.Node {
|
||||
p.openScope(stmt.Pos())
|
||||
n := ir.NewSwitchStmt(p.pos(stmt), nil, nil)
|
||||
if stmt.Init != nil {
|
||||
*n.PtrInit() = []ir.Node{p.stmt(stmt.Init)}
|
||||
}
|
||||
if stmt.Tag != nil {
|
||||
n.Tag = p.expr(stmt.Tag)
|
||||
|
||||
init := p.stmt(stmt.Init)
|
||||
n := ir.NewSwitchStmt(p.pos(stmt), p.expr(stmt.Tag), nil)
|
||||
if init != nil {
|
||||
*n.PtrInit() = []ir.Node{init}
|
||||
}
|
||||
|
||||
var tswitch *ir.TypeSwitchGuard
|
||||
if l := n.Tag; l != nil && l.Op() == ir.OTYPESW {
|
||||
tswitch = l.(*ir.TypeSwitchGuard)
|
||||
}
|
||||
n.Cases.Set(p.caseClauses(stmt.Body, tswitch, stmt.Rbrace))
|
||||
n.Cases = p.caseClauses(stmt.Body, tswitch, stmt.Rbrace)
|
||||
|
||||
p.closeScope(stmt.Rbrace)
|
||||
return n
|
||||
}
|
||||
|
||||
func (p *noder) caseClauses(clauses []*syntax.CaseClause, tswitch *ir.TypeSwitchGuard, rbrace syntax.Pos) []ir.Node {
|
||||
nodes := make([]ir.Node, 0, len(clauses))
|
||||
func (p *noder) caseClauses(clauses []*syntax.CaseClause, tswitch *ir.TypeSwitchGuard, rbrace syntax.Pos) []*ir.CaseClause {
|
||||
nodes := make([]*ir.CaseClause, 0, len(clauses))
|
||||
for i, clause := range clauses {
|
||||
p.setlineno(clause)
|
||||
if i > 0 {
|
||||
|
|
@ -1374,14 +1354,11 @@ func (p *noder) caseClauses(clauses []*syntax.CaseClause, tswitch *ir.TypeSwitch
|
|||
}
|
||||
p.openScope(clause.Pos())
|
||||
|
||||
n := ir.NewCaseStmt(p.pos(clause), nil, nil)
|
||||
if clause.Cases != nil {
|
||||
n.List.Set(p.exprList(clause.Cases))
|
||||
}
|
||||
n := ir.NewCaseStmt(p.pos(clause), p.exprList(clause.Cases), nil)
|
||||
if tswitch != nil && tswitch.Tag != nil {
|
||||
nn := typecheck.NewName(tswitch.Tag.Sym())
|
||||
typecheck.Declare(nn, typecheck.DeclContext)
|
||||
n.Vars = []ir.Node{nn}
|
||||
n.Var = nn
|
||||
// keep track of the instances for reporting unused
|
||||
nn.Defn = tswitch
|
||||
}
|
||||
|
|
@ -1416,13 +1393,11 @@ func (p *noder) caseClauses(clauses []*syntax.CaseClause, tswitch *ir.TypeSwitch
|
|||
}
|
||||
|
||||
func (p *noder) selectStmt(stmt *syntax.SelectStmt) ir.Node {
|
||||
n := ir.NewSelectStmt(p.pos(stmt), nil)
|
||||
n.Cases.Set(p.commClauses(stmt.Body, stmt.Rbrace))
|
||||
return n
|
||||
return ir.NewSelectStmt(p.pos(stmt), p.commClauses(stmt.Body, stmt.Rbrace))
|
||||
}
|
||||
|
||||
func (p *noder) commClauses(clauses []*syntax.CommClause, rbrace syntax.Pos) []ir.Node {
|
||||
nodes := make([]ir.Node, 0, len(clauses))
|
||||
func (p *noder) commClauses(clauses []*syntax.CommClause, rbrace syntax.Pos) []*ir.CommClause {
|
||||
nodes := make([]*ir.CommClause, len(clauses))
|
||||
for i, clause := range clauses {
|
||||
p.setlineno(clause)
|
||||
if i > 0 {
|
||||
|
|
@ -1430,12 +1405,7 @@ func (p *noder) commClauses(clauses []*syntax.CommClause, rbrace syntax.Pos) []i
|
|||
}
|
||||
p.openScope(clause.Pos())
|
||||
|
||||
n := ir.NewCaseStmt(p.pos(clause), nil, nil)
|
||||
if clause.Comm != nil {
|
||||
n.List = []ir.Node{p.stmt(clause.Comm)}
|
||||
}
|
||||
n.Body.Set(p.stmts(clause.Body))
|
||||
nodes = append(nodes, n)
|
||||
nodes[i] = ir.NewCommStmt(p.pos(clause), p.stmt(clause.Comm), p.stmts(clause.Body))
|
||||
}
|
||||
if len(clauses) > 0 {
|
||||
p.closeScope(rbrace)
|
||||
|
|
@ -2001,7 +1971,6 @@ func oldname(s *types.Sym) ir.Node {
|
|||
c = typecheck.NewName(s)
|
||||
c.Class_ = ir.PAUTOHEAP
|
||||
c.SetIsClosureVar(true)
|
||||
c.SetIsDDD(n.IsDDD())
|
||||
c.Defn = n
|
||||
|
||||
// Link into list of active closure variables.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue