mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
test: add tests for escape analysis of interface conversions
The false positives (var incorrectly escapes) are marked with BAD. Change-Id: If64fabb6ea96de44a1177d9ab12e2ccc579fe0c4 Reviewed-on: https://go-review.googlesource.com/5294 Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
8a2545744b
commit
edcc062bdc
10 changed files with 343 additions and 106 deletions
|
|
@ -653,9 +653,15 @@ func esc(e *EscState, n *Node, up *Node) {
|
|||
}
|
||||
}
|
||||
|
||||
case OCONV,
|
||||
OCONVNOP,
|
||||
OCONVIFACE:
|
||||
case OCONV, OCONVNOP:
|
||||
escassign(e, n, n.Left)
|
||||
|
||||
case OCONVIFACE:
|
||||
// We don't allocate storage for OCONVIFACE on stack yet,
|
||||
// but mark it as EscNone merely to get debug output for tests.
|
||||
n.Esc = EscNone // until proven otherwise
|
||||
e.noesc = list(e.noesc, n)
|
||||
n.Escloopdepth = e.loopdepth
|
||||
escassign(e, n, n.Left)
|
||||
|
||||
case OARRAYLIT:
|
||||
|
|
@ -878,7 +884,8 @@ func escassign(e *EscState, dst *Node, src *Node) {
|
|||
ONEW,
|
||||
OCLOSURE,
|
||||
OCALLPART,
|
||||
ORUNESTR:
|
||||
ORUNESTR,
|
||||
OCONVIFACE:
|
||||
escflows(e, dst, src)
|
||||
|
||||
// Flowing multiple returns to a single dst happens when
|
||||
|
|
@ -900,7 +907,6 @@ func escassign(e *EscState, dst *Node, src *Node) {
|
|||
// Conversions, field access, slice all preserve the input value.
|
||||
// fallthrough
|
||||
case OCONV,
|
||||
OCONVIFACE,
|
||||
OCONVNOP,
|
||||
ODOTMETH,
|
||||
// treat recv.meth as a value with recv in it, only happens in ODEFER and OPROC
|
||||
|
|
@ -1342,7 +1348,8 @@ func escwalk(e *EscState, level int, dst *Node, src *Node) {
|
|||
ONEW,
|
||||
OCLOSURE,
|
||||
OCALLPART,
|
||||
ORUNESTR:
|
||||
ORUNESTR,
|
||||
OCONVIFACE:
|
||||
if leaks {
|
||||
src.Esc = EscHeap
|
||||
if Debug['m'] != 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue