// (suspected) format errors, and whenever a change is made to the format.
const debugFormat = false // default: false
+// If posInfoFormat is set, position information (file, lineno) is written
+// for each exported object, including methods and struct fields. Currently
+// disabled because it may lead to different object files depending on which
+// directory they are built under, which causes tests checking for hermetic
+// builds to fail (e.g. TestCgoConsistentResults for cmd/go).
+// TODO(gri) determine what to do here.
+const posInfoFormat = false
+
// TODO(gri) remove eventually
const forceNewExport = false // force new export format - DO NOT SUBMIT with this flag set
}
p.rawByte(format)
+ // posInfo exported or not?
+ p.bool(posInfoFormat)
+
// --- generic export data ---
if p.trace {
}
func (p *exporter) pos(n *Node) {
+ if !posInfoFormat {
+ return
+ }
+
var file string
var line int
if n != nil {
funcList []*Node // nil entry means already declared
// position encoding
- prevFile string
- prevLine int
+ posInfoFormat bool
+ prevFile string
+ prevLine int
// debugging support
debugFormat bool
Fatalf("importer: invalid encoding format in export data: got %q; want 'c' or 'd'", format)
}
+ p.posInfoFormat = p.bool()
+
// --- generic export data ---
if v := p.string(); v != exportVersion {
}
func (p *importer) pos() {
+ if !p.posInfoFormat {
+ return
+ }
+
file := p.prevFile
line := p.prevLine
typList []types.Type // in order of appearance
// position encoding
- prevFile string
- prevLine int
+ posInfoFormat bool
+ prevFile string
+ prevLine int
// debugging support
debugFormat bool
return p.read, nil, fmt.Errorf("invalid encoding format in export data: got %q; want 'c' or 'd'", format)
}
+ p.posInfoFormat = p.int() != 0
+
// --- generic export data ---
if v := p.string(); v != "v0" {
}
func (p *importer) pos() {
+ if !p.posInfoFormat {
+ return
+ }
+
file := p.prevFile
line := p.prevLine