From 08f19bbde1b01227fdc2fa2d326e4029bb74dd96 Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Thu, 19 Oct 2017 17:31:31 -0700 Subject: go/printer: forbid empty line before first comment in block To improve readability when exported fields are removed, forbid the printer from emitting an empty line before the first comment in a const, var, or type block. Also, when printing the "Has filtered or unexported fields." message, add an empty line before it to separate the message from the struct or interfact contents. Before the change: <<< type NamedArg struct { // Name is the name of the parameter placeholder. // // If empty, the ordinal position in the argument list will be // used. // // Name must omit any symbol prefix. Name string // Value is the value of the parameter. // It may be assigned the same value types as the query // arguments. Value interface{} // contains filtered or unexported fields } >>> After the change: <<< type NamedArg struct { // Name is the name of the parameter placeholder. // // If empty, the ordinal position in the argument list will be // used. // // Name must omit any symbol prefix. Name string // Value is the value of the parameter. // It may be assigned the same value types as the query // arguments. Value interface{} // contains filtered or unexported fields } >>> Fixes #18264 Change-Id: I9fe17ca39cf92fcdfea55064bd2eaa784ce48c88 Reviewed-on: https://go-review.googlesource.com/71990 Run-TryBot: Joe Tsai TryBot-Result: Gobot Gobot Reviewed-by: Robert Griesemer --- src/cmd/compile/internal/ssa/gen/rulegen.go | 1 - src/cmd/internal/obj/ppc64/asm9.go | 1 - src/cmd/internal/obj/x86/asm6.go | 1 - src/cmd/link/internal/ld/data.go | 1 - src/cmd/link/internal/ppc64/asm.go | 2 -- 5 files changed, 6 deletions(-) (limited to 'src/cmd') diff --git a/src/cmd/compile/internal/ssa/gen/rulegen.go b/src/cmd/compile/internal/ssa/gen/rulegen.go index c23a54d9b5..5946b01f8e 100644 --- a/src/cmd/compile/internal/ssa/gen/rulegen.go +++ b/src/cmd/compile/internal/ssa/gen/rulegen.go @@ -659,7 +659,6 @@ func extract(val string) (op string, typ string, auxint string, aux string, args // It returns the op and unparsed strings for typ, auxint, and aux restrictions and for all args. // oparch is the architecture that op is located in, or "" for generic. func parseValue(val string, arch arch, loc string) (op opData, oparch string, typ string, auxint string, aux string, args []string) { - // Resolve the op. var s string s, typ, auxint, aux, args = extract(val) diff --git a/src/cmd/internal/obj/ppc64/asm9.go b/src/cmd/internal/obj/ppc64/asm9.go index 644cc65880..2b8efe846d 100644 --- a/src/cmd/internal/obj/ppc64/asm9.go +++ b/src/cmd/internal/obj/ppc64/asm9.go @@ -2468,7 +2468,6 @@ func (c *ctxt9) asmout(p *obj.Prog, o *Optab, out []uint32) { d := c.vregoff(p.GetFrom3()) var a int switch p.As { - // These opcodes expect a mask operand that has to be converted into the // appropriate operand. The way these were defined, not all valid masks are possible. // Left here for compatibility in case they were used or generated. diff --git a/src/cmd/internal/obj/x86/asm6.go b/src/cmd/internal/obj/x86/asm6.go index dbdaebba8d..4e4cae6b44 100644 --- a/src/cmd/internal/obj/x86/asm6.go +++ b/src/cmd/internal/obj/x86/asm6.go @@ -1996,7 +1996,6 @@ func span6(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) { c = 0 for p := s.Func.Text; p != nil; p = p.Link { if ctxt.Headtype == objabi.Hnacl && p.Isize > 0 { - // pad everything to avoid crossing 32-byte boundary if c>>5 != (c+int32(p.Isize)-1)>>5 { c = naclpad(ctxt, s, c, -c&31) diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go index 79b9ae1013..a6e03baafa 100644 --- a/src/cmd/link/internal/ld/data.go +++ b/src/cmd/link/internal/ld/data.go @@ -1857,7 +1857,6 @@ func assignAddress(ctxt *Link, sect *sym.Section, n int, s *sym.Symbol, va uint6 // Only break at outermost syms. if ctxt.Arch.InFamily(sys.PPC64) && s.Outer == nil && ctxt.IsELF && ctxt.LinkMode == LinkExternal && va-sect.Vaddr+funcsize+maxSizeTrampolinesPPC64(s, isTramp) > 0x1c00000 { - // Set the length for the previous text section sect.Length = va - sect.Vaddr diff --git a/src/cmd/link/internal/ppc64/asm.go b/src/cmd/link/internal/ppc64/asm.go index 4e277f9aa9..9b30e5f27c 100644 --- a/src/cmd/link/internal/ppc64/asm.go +++ b/src/cmd/link/internal/ppc64/asm.go @@ -523,7 +523,6 @@ func archrelocaddr(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol, val *int64) bool // resolve direct jump relocation r in s, and add trampoline if necessary func trampoline(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol) { - // Trampolines are created if the branch offset is too large and the linker cannot insert a call stub to handle it. // For internal linking, trampolines are always created for long calls. // For external linking, the linker can insert a call stub to handle a long call, but depends on having the TOC address in @@ -542,7 +541,6 @@ func trampoline(ctxt *ld.Link, r *sym.Reloc, s *sym.Symbol) { if (ctxt.LinkMode == ld.LinkExternal && s.Sect != r.Sym.Sect) || (ctxt.LinkMode == ld.LinkInternal && int64(int32(t<<6)>>6) != t) || (*ld.FlagDebugTramp > 1 && s.File != r.Sym.File) { var tramp *sym.Symbol for i := 0; ; i++ { - // Using r.Add as part of the name is significant in functions like duffzero where the call // target is at some offset within the function. Calls to duff+8 and duff+256 must appear as // distinct trampolines. -- cgit v1.3