1
0
mirror of https://github.com/golang/go synced 2024-10-01 03:28:32 -06:00

go/callgraph: add "concurrent" or "deferred" prefix to (*Edge).Description

Fixes golang/go#11518

Change-Id: If6c86c1995c0b6a1226deedaa1713947baa6593a
Reviewed-on: https://go-review.googlesource.com/12085
Reviewed-by: Daniel Morsing <daniel.morsing@gmail.com>
This commit is contained in:
Alan Donovan 2015-07-13 12:37:01 -04:00
parent 4cd43f3077
commit 543085f0ec
3 changed files with 13 additions and 7 deletions

View File

@ -101,10 +101,16 @@ func (e Edge) String() string {
}
func (e Edge) Description() string {
if e.Site == nil {
var prefix string
switch e.Site.(type) {
case nil:
return "synthetic call"
case *ssa.Go:
prefix = "concurrent "
case *ssa.Defer:
prefix = "deferred "
}
return e.Site.Common().Description()
return prefix + e.Site.Common().Description()
}
func (e Edge) Pos() token.Pos {

View File

@ -45,8 +45,8 @@ func call(f func() *int) {
func main() {
var a, b int
apply(A, &a) // @callees callees-main-apply1 "app"
apply(B, &b)
go apply(A, &a) // @callees callees-main-apply1 "app"
defer apply(B, &b)
var c, d int
var pc, pd *int // @pointsto pointsto-pc "pc"

View File

@ -7,7 +7,7 @@ this *int may point to these objects:
Found a call path from root to main.A
main.A
dynamic function call from main.apply
static function call from main.main
concurrent static function call from main.main
-------- @pointsto pointsto-B-x --------
this *int may point to these objects:
@ -25,8 +25,8 @@ this dynamic function call dispatches to:
-------- @callers callers-apply --------
main.apply is called from these 2 sites:
static function call from main.main
static function call from main.main
concurrent static function call from main.main
deferred static function call from main.main
-------- @callers callers-store --------
main.store is called from these 2 sites: