mirror of
https://github.com/golang/go
synced 2024-11-18 16:54:43 -07:00
go.tools/go/ssa: record ast.CallExpr.Rparen as Alloc.Pos() for varargs arrays.
+ pointer analysis test-case. LGTM=gri R=gri CC=golang-codereviews https://golang.org/cl/108980043
This commit is contained in:
parent
ce1e99a260
commit
38cb4c0966
5
go/pointer/testdata/func.go
vendored
5
go/pointer/testdata/func.go
vendored
@ -152,6 +152,10 @@ func func7() {
|
||||
// @calls main.func7 -> (main.D).f$thunk
|
||||
}
|
||||
|
||||
func func8(x ...int) {
|
||||
print(&x[0]) // @pointsto varargs[*]@varargs:15
|
||||
}
|
||||
|
||||
func main() {
|
||||
func1()
|
||||
func2()
|
||||
@ -160,6 +164,7 @@ func main() {
|
||||
func5()
|
||||
func6()
|
||||
func7()
|
||||
func8(1, 2, 3) // @line varargs
|
||||
}
|
||||
|
||||
// @calls <root> -> main.main
|
||||
|
@ -854,8 +854,8 @@ func (b *builder) emitCallArgs(fn *Function, sig *types.Signature, e *ast.CallEx
|
||||
} else {
|
||||
// Replace a suffix of args with a slice containing it.
|
||||
at := types.NewArray(vt, int64(len(varargs)))
|
||||
// Don't set pos for implicit Allocs.
|
||||
a := emitNew(fn, at, token.NoPos)
|
||||
a.setPos(e.Rparen)
|
||||
a.Comment = "varargs"
|
||||
for i, arg := range varargs {
|
||||
iaddr := &IndexAddr{
|
||||
|
@ -474,7 +474,7 @@ type Builtin struct {
|
||||
// instantiate these types.
|
||||
//
|
||||
// Pos() returns the ast.CompositeLit.Lbrace for a composite literal,
|
||||
// or the ast.CallExpr.Lparen for a call to new() or for a call that
|
||||
// or the ast.CallExpr.Rparen for a call to new() or for a call that
|
||||
// allocates a varargs slice.
|
||||
//
|
||||
// Example printed form:
|
||||
|
Loading…
Reference in New Issue
Block a user