mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: track line directives w/ column information
Extend cmd/internal/src.PosBase to track column information, and adjust the meaning of the PosBase position to mean the position at which the PosBase's relative (line, col) position starts (rather than indicating the position of the //line directive). Because this semantic change is made in the compiler's noder, it doesn't affect the logic of src.PosBase, only its test setup (where PosBases are constructed with corrected incomming positions). In short, src.PosBase now matches syntax.PosBase with respect to the semantics of src.PosBase.pos. For #22662. Change-Id: I5b1451cb88fff3f149920c2eec08b6167955ce27 Reviewed-on: https://go-review.googlesource.com/96535 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
6fa6bde924
commit
515fa58ac9
7 changed files with 117 additions and 46 deletions
|
|
@ -454,8 +454,8 @@ func (in *Input) line() {
|
|||
if tok != '\n' {
|
||||
in.Error("unexpected token at end of #line: ", tok)
|
||||
}
|
||||
pos := src.MakePos(in.Base(), uint(in.Line()), uint(in.Col()))
|
||||
in.Stack.SetBase(src.NewLinePragmaBase(pos, file, objabi.AbsFile(objabi.WorkingDir(), file, *flags.TrimPath), uint(line)))
|
||||
pos := src.MakePos(in.Base(), uint(in.Line())+1, 1) // +1 because #line nnn means line nnn starts on next line
|
||||
in.Stack.SetBase(src.NewLinePragmaBase(pos, file, objabi.AbsFile(objabi.WorkingDir(), file, *flags.TrimPath), uint(line), 1))
|
||||
}
|
||||
|
||||
// #undef processing
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue