transform: modify output format from the -print-allocs flag to be the same as expected by the go coverage tool

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram
2026-02-24 14:34:13 +01:00
parent 180220a2e3
commit 9bdbe943ce
4 changed files with 62 additions and 19 deletions
+10 -10
View File
@@ -10,7 +10,7 @@ func main() {
derefInt(&n1)
// This should eventually be modified to not escape.
n2 := 6 // OUT: object allocated on the heap: escapes at line 14
n2 := 6 // OUT: allocs2.go:52.1,52.42 1 0
returnIntPtr(&n2)
s1 := make([]int, 3)
@@ -20,22 +20,22 @@ func main() {
readIntSlice(s2[:])
// This should also be modified to not escape.
s3 := make([]int, 3) // OUT: object allocated on the heap: escapes at line 24
s3 := make([]int, 3) // OUT: allocs2.go:51.1,51.42 1 0
returnIntSlice(s3)
useSlice(make([]int, getUnknownNumber())) // OUT: object allocated on the heap: size is not constant
useSlice(make([]int, getUnknownNumber())) // OUT: allocs2.go:48.1,48.55 1 0
s4 := make([]byte, 300) // OUT: object allocated on the heap: object size 300 exceeds maximum stack allocation size 256
s4 := make([]byte, 300) // OUT: allocs2.go:46.1,46.56 1 0
readByteSlice(s4)
s5 := make([]int, 4) // OUT: object allocated on the heap: escapes at line 32
s5 := make([]int, 4) // OUT: allocs2.go:38.1,38.56 1 0
_ = append(s5, 5)
s6 := make([]int, 3)
s7 := []int{1, 2, 3}
copySlice(s6, s7)
c1 := getComplex128() // OUT: object allocated on the heap: escapes at line 39
c1 := getComplex128() // OUT: allocs2.go:31.1,31.55 1 0
useInterface(c1)
n3 := 5
@@ -43,13 +43,13 @@ func main() {
return n3
}()
callVariadic(3, 5, 8) // OUT: object allocated on the heap: escapes at line 46
callVariadic(3, 5, 8) // OUT: allocs2.go:28.1,28.58 1 0
s8 := []int{3, 5, 8} // OUT: object allocated on the heap: escapes at line 49
s8 := []int{3, 5, 8} // OUT: allocs2.go:26.1,26.76 1 0
callVariadic(s8...)
n4 := 3 // OUT: object allocated on the heap: escapes at line 53
n5 := 7 // OUT: object allocated on the heap: escapes at line 53
n4 := 3 // OUT: allocs2.go:23.1,23.55 1 0
n5 := 7 // OUT: allocs2.go:13.1,13.42 1 0
func() {
n4 = n5
}()