From 543085f0ecbe65f1dd183883c76b604564d740ab Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Mon, 13 Jul 2015 12:37:01 -0400 Subject: [PATCH] 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 --- go/callgraph/callgraph.go | 10 ++++++++-- oracle/testdata/src/calls/main.go | 4 ++-- oracle/testdata/src/calls/main.golden | 6 +++--- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/go/callgraph/callgraph.go b/go/callgraph/callgraph.go index dad8c22c..707a3193 100644 --- a/go/callgraph/callgraph.go +++ b/go/callgraph/callgraph.go @@ -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 { diff --git a/oracle/testdata/src/calls/main.go b/oracle/testdata/src/calls/main.go index 6fdff95d..54bb8959 100644 --- a/oracle/testdata/src/calls/main.go +++ b/oracle/testdata/src/calls/main.go @@ -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" diff --git a/oracle/testdata/src/calls/main.golden b/oracle/testdata/src/calls/main.golden index f6bfb0ea..b5e65477 100644 --- a/oracle/testdata/src/calls/main.golden +++ b/oracle/testdata/src/calls/main.golden @@ -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: