mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/cgo: add line info for return statements
When calling a C function, line information will be
incorrect if the function call's closing parenthesis
is not on the same line as the last argument. We add
a comment with the line info for the return statement
to guide debuggers to the correct line.
Fixes #49839.
Change-Id: I8bc2ce35fec9cbcafbbe8536d5a79dc487eb24bb
GitHub-Last-Rev: 8b28646d2e
GitHub-Pull-Request: golang/go#49840
Reviewed-on: https://go-review.googlesource.com/c/go/+/367454
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
This commit is contained in:
parent
831f116828
commit
0ad74fd1dc
1 changed files with 2 additions and 1 deletions
|
|
@ -811,6 +811,7 @@ func (p *Package) rewriteCall(f *File, call *Call) (string, bool) {
|
||||||
|
|
||||||
params := name.FuncType.Params
|
params := name.FuncType.Params
|
||||||
args := call.Call.Args
|
args := call.Call.Args
|
||||||
|
end := call.Call.End()
|
||||||
|
|
||||||
// Avoid a crash if the number of arguments doesn't match
|
// Avoid a crash if the number of arguments doesn't match
|
||||||
// the number of parameters.
|
// the number of parameters.
|
||||||
|
|
@ -958,7 +959,7 @@ func (p *Package) rewriteCall(f *File, call *Call) (string, bool) {
|
||||||
if nu {
|
if nu {
|
||||||
needsUnsafe = true
|
needsUnsafe = true
|
||||||
}
|
}
|
||||||
sb.WriteString(gofmtLine(m))
|
sb.WriteString(gofmtPos(m, end))
|
||||||
|
|
||||||
sb.WriteString("(")
|
sb.WriteString("(")
|
||||||
for i := range params {
|
for i := range params {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue