-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/cgo: modify source as text, not as AST
Cgo has always operated by rewriting the AST and invoking go/printer. This CL converts it to use the AST to make decisions but then apply its edits directly to the underlying source text. This approach worked better in rsc.io/grind (used during the C to Go conversion) and also more recently in cmd/cover. It guarantees that all comments and line numbers are preserved exactly. This eliminates a lot of special concern about comments and problems with cgo not preserving meaningful comments. Combined with the CL changing cmd/cover to use the same approach, it means that the combination of applying cgo and applying cover still guarantees all comments and line numbers are preserved exactly. This sets us up to fix some cgo vs cover bugs by swapping the order in which they run during the go command. This also sets up #16623 a bit: the edit list being accumulated here is nearly exactly what you'd want to pass to the compiler for that issue. Change-Id: I7611815be22e7c5c0d4fc3fa11832c42b32c4eb3 Reviewed-on: https://go-review.googlesource.com/77153 Reviewed-by: Ian Lance Taylor <iant@golang.org>
- Loading branch information
Showing
5 changed files
with
86 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters