On ir.Node, ir.Nodes, and ir.Op, # is ignored, so %#v is %v.
On ir.Node, %S is the same as %v.
On types.Type, # is ignored, so %#L is %L, %#v is %v.
On types.Type, 0 is ignored, so %0S is %S.
Rewrite all these using go test cmd/compile -r, plus a
few multiline formats mentioning %0S on types updated by hand.
Now the formats used in the compiler match the documentation
for the format methods, a minor miracle.
Passes buildall w/ toolstash -cmp.
Change-Id: I3d4a3fae543145a68da13eede91166632c5b1ceb
Reviewed-on: https://go-review.googlesource.com/c/go/+/275782
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
"*cmd/compile/internal/ssa.Value %s": "",
"*cmd/compile/internal/types.Sym %+v": "",
"*cmd/compile/internal/types.Sym %S": "",
- "*cmd/compile/internal/types.Type %#L": "",
- "*cmd/compile/internal/types.Type %#v": "",
"*cmd/compile/internal/types.Type %+v": "",
"*cmd/compile/internal/types.Type %-S": "",
- "*cmd/compile/internal/types.Type %0S": "",
"*cmd/compile/internal/types.Type %L": "",
"*cmd/compile/internal/types.Type %S": "",
"*cmd/compile/internal/types.Type %s": "",
"cmd/compile/internal/arm.shift %d": "",
"cmd/compile/internal/gc.initKind %d": "",
"cmd/compile/internal/ir.Class %d": "",
- "cmd/compile/internal/ir.Node %#v": "",
"cmd/compile/internal/ir.Node %+v": "",
"cmd/compile/internal/ir.Node %L": "",
- "cmd/compile/internal/ir.Node %S": "",
- "cmd/compile/internal/ir.Nodes %#v": "",
"cmd/compile/internal/ir.Nodes %+v": "",
"cmd/compile/internal/ir.Nodes %.v": "",
- "cmd/compile/internal/ir.Op %#v": "",
"cmd/compile/internal/ir.Op %+v": "",
"cmd/compile/internal/ssa.BranchPrediction %d": "",
"cmd/compile/internal/ssa.ID %d": "",
if !n.Name().Captured() {
n.Name().SetCaptured(true)
if n.Name().Decldepth == 0 {
- base.Fatalf("typecheckclosure: var %S does not have decldepth assigned", n)
+ base.Fatalf("typecheckclosure: var %v does not have decldepth assigned", n)
}
// Ignore assignments to the variable in straightline code
// Filter out some no-op assignments for escape analysis.
ignore := dst != nil && src != nil && isSelfAssign(dst, src)
if ignore && base.Flag.LowerM != 0 {
- base.WarnfAt(where.Pos(), "%v ignoring self-assignment in %S", funcSym(e.curfn), where)
+ base.WarnfAt(where.Pos(), "%v ignoring self-assignment in %v", funcSym(e.curfn), where)
}
k := e.addr(dst)
if loc.escapes {
if n.Op() != ir.ONAME {
if base.Flag.LowerM != 0 {
- base.WarnfAt(n.Pos(), "%S escapes to heap", n)
+ base.WarnfAt(n.Pos(), "%v escapes to heap", n)
}
if logopt.Enabled() {
logopt.LogOpt(n.Pos(), "escape", "escape", ir.FuncName(e.curfn))
addrescapes(n)
} else {
if base.Flag.LowerM != 0 && n.Op() != ir.ONAME {
- base.WarnfAt(n.Pos(), "%S does not escape", n)
+ base.WarnfAt(n.Pos(), "%v does not escape", n)
}
n.SetEsc(EscNone)
if loc.transient {
if base.Flag.E > 0 && base.Flag.LowerM > 2 {
if base.Flag.LowerM > 3 {
- fmt.Printf("inl body for %v %#v: %+v\n", fn, fn.Type(), ir.AsNodes(fn.Inl.Body))
+ fmt.Printf("inl body for %v %v: %+v\n", fn, fn.Type(), ir.AsNodes(fn.Inl.Body))
} else {
- fmt.Printf("inl body for %v %#v: %v\n", fn, fn.Type(), ir.AsNodes(fn.Inl.Body))
+ fmt.Printf("inl body for %v %v: %v\n", fn, fn.Type(), ir.AsNodes(fn.Inl.Body))
}
}
}
}
if base.Flag.LowerM > 2 || base.Debug.Export != 0 {
- fmt.Printf("typecheck import [%v] %L { %#v }\n", fn.Sym(), fn, ir.AsNodes(fn.Inl.Body))
+ fmt.Printf("typecheck import [%v] %L { %v }\n", fn.Sym(), fn, ir.AsNodes(fn.Inl.Body))
}
savefn := Curfn
}
if base.Flag.LowerM > 1 {
- fmt.Printf("%v: can inline %#v with cost %d as: %#v { %#v }\n", ir.Line(fn), n, inlineMaxBudget-visitor.budget, fn.Type(), ir.AsNodes(n.Func().Inl.Body))
+ fmt.Printf("%v: can inline %v with cost %d as: %v { %v }\n", ir.Line(fn), n, inlineMaxBudget-visitor.budget, fn.Type(), ir.AsNodes(n.Func().Inl.Body))
} else if base.Flag.LowerM != 0 {
fmt.Printf("%v: can inline %v\n", ir.Line(fn), n)
}
// We have a function node, and it has an inlineable body.
if base.Flag.LowerM > 1 {
- fmt.Printf("%v: inlining call to %v %#v { %#v }\n", ir.Line(n), fn.Sym(), fn.Type(), ir.AsNodes(fn.Inl.Body))
+ fmt.Printf("%v: inlining call to %v %v { %v }\n", ir.Line(n), fn.Sym(), fn.Type(), ir.AsNodes(fn.Inl.Body))
} else if base.Flag.LowerM != 0 {
fmt.Printf("%v: inlining call to %v\n", ir.Line(n), fn)
}
for _, d := range testdata {
got := cmpstackvarlt(d.a, d.b)
if got != d.lt {
- t.Errorf("want %#v < %#v", d.a, d.b)
+ t.Errorf("want %v < %v", d.a, d.b)
}
// If we expect a < b to be true, check that b < a is false.
if d.lt && cmpstackvarlt(d.b, d.a) {
- t.Errorf("unexpected %#v < %#v", d.b, d.a)
+ t.Errorf("unexpected %v < %v", d.b, d.a)
}
}
}
why = fmt.Sprintf(":\n\t%v does not implement %v (%v method is marked 'nointerface')", src, dst, missing.Sym)
} else if have != nil && have.Sym == missing.Sym {
why = fmt.Sprintf(":\n\t%v does not implement %v (wrong type for %v method)\n"+
- "\t\thave %v%0S\n\t\twant %v%0S", src, dst, missing.Sym, have.Sym, have.Type, missing.Sym, missing.Type)
+ "\t\thave %v%S\n\t\twant %v%S", src, dst, missing.Sym, have.Sym, have.Type, missing.Sym, missing.Type)
} else if ptr != 0 {
why = fmt.Sprintf(":\n\t%v does not implement %v (%v method has pointer receiver)", src, dst, missing.Sym)
} else if have != nil {
why = fmt.Sprintf(":\n\t%v does not implement %v (missing %v method)\n"+
- "\t\thave %v%0S\n\t\twant %v%0S", src, dst, missing.Sym, have.Sym, have.Type, missing.Sym, missing.Type)
+ "\t\thave %v%S\n\t\twant %v%S", src, dst, missing.Sym, have.Sym, have.Type, missing.Sym, missing.Type)
} else {
why = fmt.Sprintf(":\n\t%v does not implement %v (missing %v method)", src, dst, missing.Sym)
}
skipDowidthForTracing = true
defer func() { skipDowidthForTracing = false }()
- fmt.Printf("%s: %s=> %p %s %v tc=%d type=%#L\n", pos, indent, n, op, n, tc, typ)
+ fmt.Printf("%s: %s=> %p %s %v tc=%d type=%L\n", pos, indent, n, op, n, tc, typ)
}
}
if !implements(n.Type(), t, &missing, &have, &ptr) {
if have != nil && have.Sym == missing.Sym {
base.Errorf("impossible type assertion:\n\t%v does not implement %v (wrong type for %v method)\n"+
- "\t\thave %v%0S\n\t\twant %v%0S", n.Type(), t, missing.Sym, have.Sym, have.Type, missing.Sym, missing.Type)
+ "\t\thave %v%S\n\t\twant %v%S", n.Type(), t, missing.Sym, have.Sym, have.Type, missing.Sym, missing.Type)
} else if ptr != 0 {
base.Errorf("impossible type assertion:\n\t%v does not implement %v (%v method has pointer receiver)", n.Type(), t, missing.Sym)
} else if have != nil {
base.Errorf("impossible type assertion:\n\t%v does not implement %v (missing %v method)\n"+
- "\t\thave %v%0S\n\t\twant %v%0S", n.Type(), t, missing.Sym, have.Sym, have.Type, missing.Sym, missing.Type)
+ "\t\thave %v%S\n\t\twant %v%S", n.Type(), t, missing.Sym, have.Sym, have.Type, missing.Sym, missing.Type)
} else {
base.Errorf("impossible type assertion:\n\t%v does not implement %v (missing %v method)", n.Type(), t, missing.Sym)
}
v += r.Offset()
default:
ir.Dump("unsafenmagic", n.Left())
- base.Fatalf("impossible %#v node after dot insertion", r.Op())
+ base.Fatalf("impossible %v node after dot insertion", r.Op())
}
}
return v
switch l.Op() {
default:
- base.Fatalf("reorder3 unexpected lvalue %#v", l.Op())
+ base.Fatalf("reorder3 unexpected lvalue %v", l.Op())
case ir.ONAME:
break
// %+v Debug syntax, as in Dump.
//
func FmtNode(n Node, s fmt.State, verb rune) {
- // TODO(rsc): Remove uses of %#v, which behaves just like %v.
- // TODO(rsc): Remove uses of %S, which behaves just like %v.
- if verb == 'S' {
- verb = 'v'
- }
-
// %+v prints Dump.
// Otherwise we print Go syntax.
if s.Flag('+') && verb == 'v' {
break
}
- fmt.Fprintf(s, "%v %#v= %v", n.Left(), n.SubOp(), n.Right())
+ fmt.Fprintf(s, "%v %v= %v", n.Left(), n.SubOp(), n.Right())
case OAS2, OAS2DOTTYPE, OAS2FUNC, OAS2MAPR, OAS2RECV:
if n.Colas() && !complexinit {
break
}
- fmt.Fprintf(s, "%#v", n.Op())
+ fmt.Fprintf(s, "%v", n.Op())
if simpleinit {
fmt.Fprintf(s, " %v;", n.Init().First())
}
case OBREAK, OCONTINUE, OGOTO, OFALL:
if n.Sym() != nil {
- fmt.Fprintf(s, "%#v %v", n.Op(), n.Sym())
+ fmt.Fprintf(s, "%v %v", n.Op(), n.Sym())
} else {
- fmt.Fprintf(s, "%#v", n.Op())
+ fmt.Fprintf(s, "%v", n.Op())
}
case OLABEL:
case OCOMPLEX, OCOPY:
if n.Left() != nil {
- fmt.Fprintf(s, "%#v(%v, %v)", n.Op(), n.Left(), n.Right())
+ fmt.Fprintf(s, "%v(%v, %v)", n.Op(), n.Left(), n.Right())
} else {
- fmt.Fprintf(s, "%#v(%.v)", n.Op(), n.List())
+ fmt.Fprintf(s, "%v(%.v)", n.Op(), n.List())
}
case OCONV,
OPRINT,
OPRINTN:
if n.Left() != nil {
- fmt.Fprintf(s, "%#v(%v)", n.Op(), n.Left())
+ fmt.Fprintf(s, "%v(%v)", n.Op(), n.Left())
return
}
if n.IsDDD() {
- fmt.Fprintf(s, "%#v(%.v...)", n.Op(), n.List())
+ fmt.Fprintf(s, "%v(%.v...)", n.Op(), n.List())
return
}
- fmt.Fprintf(s, "%#v(%.v)", n.Op(), n.List())
+ fmt.Fprintf(s, "%v(%.v)", n.Op(), n.List())
case OCALL, OCALLFUNC, OCALLINTER, OCALLMETH, OGETG:
exprFmt(n.Left(), s, nprec)
case OPLUS, ONEG, OADDR, OBITNOT, ODEREF, ONOT, ORECV:
// Unary
- fmt.Fprintf(s, "%#v", n.Op())
+ fmt.Fprintf(s, "%v", n.Op())
if n.Left() != nil && n.Left().Op() == n.Op() {
fmt.Fprint(s, " ")
}
OSUB,
OXOR:
exprFmt(n.Left(), s, nprec)
- fmt.Fprintf(s, " %#v ", n.Op())
+ fmt.Fprintf(s, " %v ", n.Op())
exprFmt(n.Right(), s, nprec+1)
case OADDSTR: