awslabs / ar-go-tools

ar-go-tools (Argot) is a collection of analysis tools for Go
Apache License 2.0
9 stars 1 forks source link

Closures context sensitive for bound variables #27

Closed victornicolet closed 1 year ago

victornicolet commented 1 year ago

This PR introduces a new algorithm for tracing dataflow from bound variables to closure bodies that improves precision. When a bound variable is tainted (either a directly bound variable with BoundVarNode or alias with BoundLabelNode) the dataflow visitor goes to the makeclosure node and changes is "tracing" mode to closure tracing. The visitor maintains the identity of the closure being traced, and when the closure is called, it has the correct call stack, which allows it to be more context aware.

The case of multiple closures is handled by maintaining a stack of closure identities (the current closure identity in ClosureTracingInfo maintains a pointer to the previous closure identity, or nil).

Other changes include: