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
|
|
@ -152,6 +152,10 @@ func func7() {
|
||||||
// @calls main.func7 -> (main.D).f$thunk
|
// @calls main.func7 -> (main.D).f$thunk
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func func8(x ...int) {
|
||||||
|
print(&x[0]) // @pointsto varargs[*]@varargs:15
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
func1()
|
func1()
|
||||||
func2()
|
func2()
|
||||||
|
|
@ -160,6 +164,7 @@ func main() {
|
||||||
func5()
|
func5()
|
||||||
func6()
|
func6()
|
||||||
func7()
|
func7()
|
||||||
|
func8(1, 2, 3) // @line varargs
|
||||||
}
|
}
|
||||||
|
|
||||||
// @calls <root> -> main.main
|
// @calls <root> -> main.main
|
||||||
|
|
|
||||||
|
|
@ -854,8 +854,8 @@ func (b *builder) emitCallArgs(fn *Function, sig *types.Signature, e *ast.CallEx
|
||||||
} else {
|
} else {
|
||||||
// Replace a suffix of args with a slice containing it.
|
// Replace a suffix of args with a slice containing it.
|
||||||
at := types.NewArray(vt, int64(len(varargs)))
|
at := types.NewArray(vt, int64(len(varargs)))
|
||||||
// Don't set pos for implicit Allocs.
|
|
||||||
a := emitNew(fn, at, token.NoPos)
|
a := emitNew(fn, at, token.NoPos)
|
||||||
|
a.setPos(e.Rparen)
|
||||||
a.Comment = "varargs"
|
a.Comment = "varargs"
|
||||||
for i, arg := range varargs {
|
for i, arg := range varargs {
|
||||||
iaddr := &IndexAddr{
|
iaddr := &IndexAddr{
|
||||||
|
|
|
||||||
|
|
@ -474,7 +474,7 @@ type Builtin struct {
|
||||||
// instantiate these types.
|
// instantiate these types.
|
||||||
//
|
//
|
||||||
// Pos() returns the ast.CompositeLit.Lbrace for a composite literal,
|
// 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.
|
// allocates a varargs slice.
|
||||||
//
|
//
|
||||||
// Example printed form:
|
// Example printed form:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue