1
0
mirror of https://github.com/golang/go synced 2024-11-18 06:04:53 -07:00

cmd/compile: remove superfluous returns in fmt.go

Change-Id: Ie73fb460a3838c6d1b9348965a8b69c1bfa6a882
Reviewed-on: https://go-review.googlesource.com/28341
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dave Cheney <dave@cheney.net>
This commit is contained in:
Robert Griesemer 2016-08-31 17:49:49 -07:00
parent 0ca5f269d4
commit 58de26810c

View File

@ -664,7 +664,6 @@ func (t *Type) typefmt(s fmt.State, flag FmtFlag) {
return return
} }
fmt.Fprint(s, "*"+t.Elem().String()) fmt.Fprint(s, "*"+t.Elem().String())
return
case TARRAY: case TARRAY:
if t.isDDDArray() { if t.isDDDArray() {
@ -672,11 +671,9 @@ func (t *Type) typefmt(s fmt.State, flag FmtFlag) {
return return
} }
fmt.Fprintf(s, "[%d]%v", t.NumElem(), t.Elem()) fmt.Fprintf(s, "[%d]%v", t.NumElem(), t.Elem())
return
case TSLICE: case TSLICE:
fmt.Fprint(s, "[]"+t.Elem().String()) fmt.Fprint(s, "[]"+t.Elem().String())
return
case TCHAN: case TCHAN:
switch t.ChanDir() { switch t.ChanDir() {
@ -694,11 +691,9 @@ func (t *Type) typefmt(s fmt.State, flag FmtFlag) {
return return
} }
fmt.Fprint(s, "chan "+t.Elem().String()) fmt.Fprint(s, "chan "+t.Elem().String())
return
case TMAP: case TMAP:
fmt.Fprint(s, "map["+t.Key().String()+"]"+t.Val().String()) fmt.Fprint(s, "map["+t.Key().String()+"]"+t.Val().String())
return
case TINTER: case TINTER:
fmt.Fprint(s, "interface {") fmt.Fprint(s, "interface {")
@ -723,7 +718,6 @@ func (t *Type) typefmt(s fmt.State, flag FmtFlag) {
fmt.Fprint(s, " ") fmt.Fprint(s, " ")
} }
fmt.Fprint(s, "}") fmt.Fprint(s, "}")
return
case TFUNC: case TFUNC:
if flag&FmtShort != 0 { if flag&FmtShort != 0 {
@ -746,7 +740,6 @@ func (t *Type) typefmt(s fmt.State, flag FmtFlag) {
default: default:
fmt.Fprintf(s, " %v", t.Results()) fmt.Fprintf(s, " %v", t.Results())
} }
return
case TSTRUCT: case TSTRUCT:
if m := t.StructType().Map; m != nil { if m := t.StructType().Map; m != nil {
@ -798,7 +791,6 @@ func (t *Type) typefmt(s fmt.State, flag FmtFlag) {
} }
fmt.Fprint(s, "}") fmt.Fprint(s, "}")
} }
return
case TFORW: case TFORW:
if t.Sym != nil { if t.Sym != nil {
@ -806,23 +798,20 @@ func (t *Type) typefmt(s fmt.State, flag FmtFlag) {
return return
} }
fmt.Fprint(s, "undefined") fmt.Fprint(s, "undefined")
return
case TUNSAFEPTR: case TUNSAFEPTR:
fmt.Fprint(s, "unsafe.Pointer") fmt.Fprint(s, "unsafe.Pointer")
return
case TDDDFIELD: case TDDDFIELD:
fmt.Fprintf(s, "%v <%v> %v", t.Etype, t.Sym, t.DDDField()) fmt.Fprintf(s, "%v <%v> %v", t.Etype, t.Sym, t.DDDField())
return
case Txxx: case Txxx:
fmt.Fprint(s, "Txxx") fmt.Fprint(s, "Txxx")
return
}
default:
// Don't know how to handle - fall back to detailed prints. // Don't know how to handle - fall back to detailed prints.
fmt.Fprintf(s, "%v <%v> %v", t.Etype, t.Sym, t.Elem()) fmt.Fprintf(s, "%v <%v> %v", t.Etype, t.Sym, t.Elem())
}
} }
// Statements which may be rendered with a simplestmt as init. // Statements which may be rendered with a simplestmt as init.
@ -1162,15 +1151,12 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
switch n.Op { switch n.Op {
case OPAREN: case OPAREN:
fmt.Fprintf(s, "(%v)", n.Left) fmt.Fprintf(s, "(%v)", n.Left)
return
case ODDDARG: case ODDDARG:
fmt.Fprint(s, "... argument") fmt.Fprint(s, "... argument")
return
case OREGISTER: case OREGISTER:
fmt.Fprint(s, obj.Rconv(int(n.Reg))) fmt.Fprint(s, obj.Rconv(int(n.Reg)))
return
case OLITERAL: // this is a bit of a mess case OLITERAL: // this is a bit of a mess
if fmtmode == FErr { if fmtmode == FErr {
@ -1200,7 +1186,6 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
} }
fmt.Fprintf(s, "%s", n.Val()) fmt.Fprintf(s, "%s", n.Val())
return
// Special case: name used as local variable in export. // Special case: name used as local variable in export.
// _ becomes ~b%d internally; print as _ for export // _ becomes ~b%d internally; print as _ for export
@ -1210,10 +1195,8 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
return return
} }
fallthrough fallthrough
case OPACK, ONONAME: case OPACK, ONONAME:
fmt.Fprint(s, n.Sym.String()) fmt.Fprint(s, n.Sym.String())
return
case OTYPE: case OTYPE:
if n.Type == nil && n.Sym != nil { if n.Type == nil && n.Sym != nil {
@ -1221,7 +1204,6 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
return return
} }
fmt.Fprintf(s, "%v", n.Type) fmt.Fprintf(s, "%v", n.Type)
return
case OTARRAY: case OTARRAY:
if n.Left != nil { if n.Left != nil {
@ -1229,43 +1211,34 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
return return
} }
fmt.Fprintf(s, "[]%v", n.Right) // happens before typecheck fmt.Fprintf(s, "[]%v", n.Right) // happens before typecheck
return
case OTMAP: case OTMAP:
fmt.Fprintf(s, "map[%v]%v", n.Left, n.Right) fmt.Fprintf(s, "map[%v]%v", n.Left, n.Right)
return
case OTCHAN: case OTCHAN:
switch ChanDir(n.Etype) { switch ChanDir(n.Etype) {
case Crecv: case Crecv:
fmt.Fprintf(s, "<-chan %v", n.Left) fmt.Fprintf(s, "<-chan %v", n.Left)
return
case Csend: case Csend:
fmt.Fprintf(s, "chan<- %v", n.Left) fmt.Fprintf(s, "chan<- %v", n.Left)
return
default: default:
if n.Left != nil && n.Left.Op == OTCHAN && n.Left.Sym == nil && ChanDir(n.Left.Etype) == Crecv { if n.Left != nil && n.Left.Op == OTCHAN && n.Left.Sym == nil && ChanDir(n.Left.Etype) == Crecv {
fmt.Fprintf(s, "chan (%v)", n.Left) fmt.Fprintf(s, "chan (%v)", n.Left)
return
} else { } else {
fmt.Fprintf(s, "chan %v", n.Left) fmt.Fprintf(s, "chan %v", n.Left)
return
} }
} }
case OTSTRUCT: case OTSTRUCT:
fmt.Fprint(s, "<struct>") fmt.Fprint(s, "<struct>")
return
case OTINTER: case OTINTER:
fmt.Fprint(s, "<inter>") fmt.Fprint(s, "<inter>")
return
case OTFUNC: case OTFUNC:
fmt.Fprint(s, "<func>") fmt.Fprint(s, "<func>")
return
case OCLOSURE: case OCLOSURE:
if fmtmode == FErr { if fmtmode == FErr {
@ -1277,7 +1250,6 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
return return
} }
fmt.Fprintf(s, "%v { %v }", n.Type, n.Func.Closure.Nbody) fmt.Fprintf(s, "%v { %v }", n.Type, n.Func.Closure.Nbody)
return
case OCOMPLIT: case OCOMPLIT:
ptrlit := n.Right != nil && n.Right.Implicit && n.Right.Type != nil && n.Right.Type.IsPtr() ptrlit := n.Right != nil && n.Right.Implicit && n.Right.Type != nil && n.Right.Type.IsPtr()
@ -1295,13 +1267,10 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
fmt.Fprint(s, "composite literal") fmt.Fprint(s, "composite literal")
return return
} }
fmt.Fprintf(s, "(%v{ %.v })", n.Right, n.List) fmt.Fprintf(s, "(%v{ %.v })", n.Right, n.List)
return
case OPTRLIT: case OPTRLIT:
fmt.Fprintf(s, "&%v", n.Left) fmt.Fprintf(s, "&%v", n.Left)
return
case OSTRUCTLIT, OARRAYLIT, OSLICELIT, OMAPLIT: case OSTRUCTLIT, OARRAYLIT, OSLICELIT, OMAPLIT:
if fmtmode == FErr { if fmtmode == FErr {
@ -1309,7 +1278,6 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
return return
} }
fmt.Fprintf(s, "(%v{ %.v })", n.Type, n.List) fmt.Fprintf(s, "(%v{ %.v })", n.Type, n.List)
return
case OKEY: case OKEY:
if n.Left != nil && n.Right != nil { if n.Left != nil && n.Right != nil {
@ -1326,7 +1294,6 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
return return
} }
fmt.Fprint(s, ":") fmt.Fprint(s, ":")
return
case OCALLPART: case OCALLPART:
n.Left.exprfmt(s, nprec) n.Left.exprfmt(s, nprec)
@ -1335,7 +1302,6 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
return return
} }
fmt.Fprintf(s, ".%01v", n.Right.Sym) fmt.Fprintf(s, ".%01v", n.Right.Sym)
return
case OXDOT, ODOT, ODOTPTR, ODOTINTER, ODOTMETH: case OXDOT, ODOT, ODOTPTR, ODOTINTER, ODOTMETH:
n.Left.exprfmt(s, nprec) n.Left.exprfmt(s, nprec)
@ -1344,7 +1310,6 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
return return
} }
fmt.Fprintf(s, ".%01v", n.Sym) fmt.Fprintf(s, ".%01v", n.Sym)
return
case ODOTTYPE, ODOTTYPE2: case ODOTTYPE, ODOTTYPE2:
n.Left.exprfmt(s, nprec) n.Left.exprfmt(s, nprec)
@ -1353,12 +1318,10 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
return return
} }
fmt.Fprintf(s, ".(%v)", n.Type) fmt.Fprintf(s, ".(%v)", n.Type)
return
case OINDEX, OINDEXMAP: case OINDEX, OINDEXMAP:
n.Left.exprfmt(s, nprec) n.Left.exprfmt(s, nprec)
fmt.Fprintf(s, "[%v]", n.Right) fmt.Fprintf(s, "[%v]", n.Right)
return
case OSLICE, OSLICESTR, OSLICEARR, OSLICE3, OSLICE3ARR: case OSLICE, OSLICESTR, OSLICEARR, OSLICE3, OSLICE3ARR:
n.Left.exprfmt(s, nprec) n.Left.exprfmt(s, nprec)
@ -1378,11 +1341,9 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
} }
} }
fmt.Fprint(s, "]") fmt.Fprint(s, "]")
return
case OCOPY, OCOMPLEX: case OCOPY, OCOMPLEX:
fmt.Fprintf(s, "%#v(%v, %v)", n.Op, n.Left, n.Right) fmt.Fprintf(s, "%#v(%v, %v)", n.Op, n.Left, n.Right)
return
case OCONV, case OCONV,
OCONVIFACE, OCONVIFACE,
@ -1401,7 +1362,6 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
return return
} }
fmt.Fprintf(s, "%v(%.v)", n.Type, n.List) fmt.Fprintf(s, "%v(%.v)", n.Type, n.List)
return
case OREAL, case OREAL,
OIMAG, OIMAG,
@ -1425,7 +1385,6 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
return return
} }
fmt.Fprintf(s, "%#v(%.v)", n.Op, n.List) fmt.Fprintf(s, "%#v(%.v)", n.Op, n.List)
return
case OCALL, OCALLFUNC, OCALLINTER, OCALLMETH, OGETG: case OCALL, OCALLFUNC, OCALLINTER, OCALLMETH, OGETG:
n.Left.exprfmt(s, nprec) n.Left.exprfmt(s, nprec)
@ -1434,7 +1393,6 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
return return
} }
fmt.Fprintf(s, "(%.v)", n.List) fmt.Fprintf(s, "(%.v)", n.List)
return
case OMAKEMAP, OMAKECHAN, OMAKESLICE: case OMAKEMAP, OMAKECHAN, OMAKESLICE:
if n.List.Len() != 0 { // pre-typecheck if n.List.Len() != 0 { // pre-typecheck
@ -1450,7 +1408,6 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
return return
} }
fmt.Fprintf(s, "make(%v)", n.Type) fmt.Fprintf(s, "make(%v)", n.Type)
return
// Unary // Unary
case OPLUS, case OPLUS,
@ -1465,7 +1422,6 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
fmt.Fprint(s, " ") fmt.Fprint(s, " ")
} }
n.Left.exprfmt(s, nprec+1) n.Left.exprfmt(s, nprec+1)
return
// Binary // Binary
case OADD, case OADD,
@ -1491,7 +1447,6 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
n.Left.exprfmt(s, nprec) n.Left.exprfmt(s, nprec)
fmt.Fprintf(s, " %#v ", n.Op) fmt.Fprintf(s, " %#v ", n.Op)
n.Right.exprfmt(s, nprec+1) n.Right.exprfmt(s, nprec+1)
return
case OADDSTR: case OADDSTR:
i := 0 i := 0
@ -1502,17 +1457,16 @@ func (n *Node) exprfmt(s fmt.State, prec int) {
n1.exprfmt(s, nprec) n1.exprfmt(s, nprec)
i++ i++
} }
return
case OCMPSTR, OCMPIFACE: case OCMPSTR, OCMPIFACE:
n.Left.exprfmt(s, nprec) n.Left.exprfmt(s, nprec)
// TODO(marvin): Fix Node.EType type union. // TODO(marvin): Fix Node.EType type union.
fmt.Fprintf(s, " %#v ", Op(n.Etype)) fmt.Fprintf(s, " %#v ", Op(n.Etype))
n.Right.exprfmt(s, nprec+1) n.Right.exprfmt(s, nprec+1)
return
}
default:
fmt.Fprintf(s, "<node %v>", n.Op) fmt.Fprintf(s, "<node %v>", n.Op)
}
} }
func (n *Node) nodefmt(s fmt.State, flag FmtFlag) { func (n *Node) nodefmt(s fmt.State, flag FmtFlag) {