Skip to content

Commit b04b690

Browse files
committed
libclang: do not make error locations relative
This is done at a later time anyway, so doesn't need to be done in the cgo package. In fact, _not_ doing it there makes it easier to print correct relative packages.
1 parent 8a357af commit b04b690

File tree

2 files changed

+2
-12
lines changed

2 files changed

+2
-12
lines changed

cgo/libclang.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -646,13 +646,6 @@ func (p *cgoPackage) addErrorAfter(pos token.Pos, after, msg string) {
646646

647647
// addErrorAt is a utility function to add an error to the list of errors.
648648
func (p *cgoPackage) addErrorAt(position token.Position, msg string) {
649-
if filepath.IsAbs(position.Filename) {
650-
// Relative paths for readability, like other Go parser errors.
651-
relpath, err := filepath.Rel(p.currentDir, position.Filename)
652-
if err == nil {
653-
position.Filename = relpath
654-
}
655-
}
656649
p.errors = append(p.errors, scanner.Error{
657650
Pos: position,
658651
Msg: msg,

testdata/errors/cgo.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import "C"
77
func main() {
88
}
99

10-
// TODO: this error should be relative to the current directory (so cgo.go
11-
// instead of testdata/errors/cgo.go).
12-
1310
// ERROR: # command-line-arguments
14-
// ERROR: testdata/errors/cgo.go:3:5: error: hello
15-
// ERROR: testdata/errors/cgo.go:4:4: error: expected identifier or '('
11+
// ERROR: cgo.go:3:5: error: hello
12+
// ERROR: cgo.go:4:4: error: expected identifier or '('

0 commit comments

Comments
 (0)