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

cmd/cgo: fix line info in _cgo_gotypes.go

Don't write line info for types, we don't have it.
Otherwise types look like:

type _Ctype_struct_cb struct {
//line :1
      on_test *[0]byte
//line :1
}

Which is not useful. Moreover we never override source info,
so subsequent source code uses the same source info.
Moreover, empty file name makes compile emit no source debug info at all.

Update #17190

Change-Id: I7ae6fa4964520d7665743d340419b787df0b51e8
Reviewed-on: https://go-review.googlesource.com/29713
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
Dmitry Vyukov 2016-09-24 17:03:30 +02:00
parent c14050646f
commit 9f1c78781b

View File

@ -19,7 +19,10 @@ import (
"strings"
)
var conf = printer.Config{Mode: printer.SourcePos, Tabwidth: 8}
var (
conf = printer.Config{Mode: printer.SourcePos, Tabwidth: 8}
noSourceConf = printer.Config{Tabwidth: 8}
)
// writeDefs creates output files to be compiled by gc and gcc.
func (p *Package) writeDefs() {
@ -95,7 +98,19 @@ func (p *Package) writeDefs() {
for _, name := range typedefNames {
def := typedef[name]
fmt.Fprintf(fgo2, "type %s ", name)
conf.Fprint(fgo2, fset, def.Go)
// We don't have source info for these types, so write them out without source info.
// Otherwise types would look like:
//
// type _Ctype_struct_cb struct {
// //line :1
// on_test *[0]byte
// //line :1
// }
//
// Which is not useful. Moreover we never override source info,
// so subsequent source code uses the same source info.
// Moreover, empty file name makes compile emit no source debug info at all.
noSourceConf.Fprint(fgo2, fset, def.Go)
fmt.Fprintf(fgo2, "\n\n")
}
if *gccgo {