github-vet / github-vet/bots

callgraph improvements using pointer argument pattern

Open
#101 1 comment 0 reactions 0 assignees View on GitHub
discussion enhancement vet-bot
Dominant language
Go
Stars
1
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Once #28 lands, there will be one more thing we can use in the call-graph to disambiguate nodes _without_ using any type information.

Whether we want to do this depends entirely on how many false-positives we see. (EDIT: maybe not; I kind of just want to do it...)

We can use name, arity, _and the pattern of pointer arguments_ to uniquely identify a function in the callgraph.

For instance, a function
```
func foo(x int, y *int, z int) {
// ...
}
```
would have signature `{foo, 3, [false, true, false]}`.

We can easily construct this graph for function signatures. However, using the graph at the call-site without type information is a little bit trickier. We can use the position where the pointer argument(s) are being passed to lookup the set of all the nodes in the call-graph whose signatures match and run our BFS starting from those nodes.

That lookup is only a tiny bit tricky. I think it's easiest trading off space for time by using an index.

Functions which do not take any pointer arguments are also totally useless for our purposes. I think we can just ignore them in every case (see #102). Any edges which we may miss couldn't have a pointer crossing them in any case.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.