go.tools/godoc/analysis: be defensive about files without position info (such as cgo generated files)

Also: improve log message for frontend errors without position info.

LGTM=gri
R=gri
CC=golang-codereviews
https://golang.org/cl/109100043
This commit is contained in:
Alan Donovan 2014-06-18 18:02:15 -04:00
parent 02dba5d1e6
commit e436e8e4aa

View File

@ -381,6 +381,9 @@ func Run(pta bool, result *Result) {
for _, info := range iprog.AllPackages {
nextfile:
for _, f := range info.Files {
if f.Pos() == 0 {
continue // e.g. files generated by cgo
}
abs := iprog.Fset.File(f.Pos()).Name()
// Find the root to which this file belongs.
for _, root := range roots {
@ -412,7 +415,8 @@ func Run(pta bool, result *Result) {
errors[e.Pos] = append(errors[e.Pos], e.Msg)
}
default:
log.Printf("Error (%T) without position: %v\n", err, err)
log.Printf("Package %q has error (%T) without position: %v\n",
info.Pkg.Path(), err, err)
}
}
}