Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(251)

Delta Between Two Patch Sets: test/escape2.go

Issue 4634073: code review 4634073: gc: Escape analysis. (Closed)
Left Patch Set: diff -r 86d88823d334 https://go.googlecode.com/hg/ Created 13 years, 7 months ago
Right Patch Set: diff -r adfa9f5cca40 https://go.googlecode.com/hg/ Created 13 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/cmd/gc/typecheck.c ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // errchk -0 $G -sm $D/$F.go 1 // errchk -0 $G -sm $D/$F.go
2 2
3 // Copyright 2010 The Go Authors. All rights reserved. 3 // Copyright 2010 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style 4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file. 5 // license that can be found in the LICENSE file.
6 6
7 package foo 7 package foo
8 8
9 import "unsafe" 9 import "unsafe"
10 10
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 **xxx = y 102 **xxx = y
103 } 103 }
104 104
105 type Bar struct { 105 type Bar struct {
106 i int 106 i int
107 ii *int 107 ii *int
108 } 108 }
109 109
110 func NewBar() *Bar { 110 func NewBar() *Bar {
111 return &Bar{ 42, nil } 111 return &Bar{ 42, nil }
112 }
113
114 func NewBarp(x *int) *Bar { // ERROR "leaking param: NAME-x"
115 return &Bar{ 42, x }
116 }
117
118 func NewBarp2(x *int) *Bar {
119 return &Bar{ *x, nil }
112 } 120 }
113 121
114 func (b *Bar) NoLeak() int { 122 func (b *Bar) NoLeak() int {
115 return *(b.ii) 123 return *(b.ii)
116 } 124 }
117 125
118 func (b *Bar) AlsoNoLeak() *int { 126 func (b *Bar) AlsoNoLeak() *int {
119 return b.ii 127 return b.ii
120 } 128 }
121 129
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 } 554 }
547 555
548 func foo77a(z []interface{}) { // ERROR "leaking param: NAME-z" 556 func foo77a(z []interface{}) { // ERROR "leaking param: NAME-z"
549 myprint1(nil, z...) 557 myprint1(nil, z...)
550 } 558 }
551 559
552 func foo78(z int) *int { // ERROR "moved to heap: NAME-z" 560 func foo78(z int) *int { // ERROR "moved to heap: NAME-z"
553 return &z // "&z escapes" 561 return &z // "&z escapes"
554 } 562 }
555 563
556 // move of y is spurious. see esc.c line 842
557 func foo78a(z int) *int { // ERROR "moved to heap: NAME-z" 564 func foo78a(z int) *int { // ERROR "moved to heap: NAME-z"
558 » y := &z // ERROR "moved to heap: NAME-y" 565 » y := &z
559 x := &y 566 x := &y
560 return *x // really return y 567 return *x // really return y
561 } 568 }
562 569
563 func foo79() *int { 570 func foo79() *int {
564 return new(int) // "moved to heap: new[(]int[)]" 571 return new(int) // "moved to heap: new[(]int[)]"
565 } 572 }
566 573
567 func foo80() *int { 574 func foo80() *int {
568 var z *int 575 var z *int
(...skipping 16 matching lines...) Expand all
585 Foo() 592 Foo()
586 } 593 }
587 594
588 type LimitedFooer struct { 595 type LimitedFooer struct {
589 Fooer 596 Fooer
590 N int64 597 N int64
591 } 598 }
592 599
593 func LimitFooer(r Fooer, n int64) Fooer { // ERROR "leaking param: NAME-r" 600 func LimitFooer(r Fooer, n int64) Fooer { // ERROR "leaking param: NAME-r"
594 return &LimitedFooer{r, n} 601 return &LimitedFooer{r, n}
595 } 602 }
603
604 func foo90(x *int) map[*int]*int { // ERROR "leaking param: NAME-x"
605 » return map[*int]*int{ nil: x }
606 }
607
608 func foo91(x *int) map[*int]*int { // ERROR "leaking param: NAME-x"
609 » return map[*int]*int{ x:nil }
610 }
611
612 func foo92(x *int) [2]*int { // ERROR "leaking param: NAME-x"
613 » return [2]*int{ x, nil }
614 }
615
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b