Add queries to inspect and measure dispatch differences.

This commit is contained in:
Max Schaefer
2020-03-20 09:34:30 +00:00
parent 084fa80a57
commit 752ee3909a
3 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1 @@
TBD

View File

@@ -0,0 +1,20 @@
/**
* @kind problem
* @problem.severity warning
* @precision very-high
* @id go/compare-dispatch
*/
import go
import DataFlowDispatch
FuncDef viableCallableOld(CallExpr c) {
exists(DataFlow::CallNode call | call.asExpr() = c | result = call.getACallee())
}
from CallExpr c, FuncDef fn, string msg
where
fn = viableCallableOld(c) and not fn = viableCallable(c) and msg = "Missing"
or
not fn = viableCallableOld(c) and fn = viableCallable(c) and msg = "New"
select c, msg + " $@.", fn, "callee"

View File

@@ -0,0 +1,18 @@
/**
* @kind table
* @id go/dispatch-stats
*/
import go
import DataFlowDispatch
FuncDef viableCallableOld(CallExpr c) {
exists(DataFlow::CallNode call | call.asExpr() = c | result = call.getACallee())
}
from CallExpr c, int old, int new
where
old = count(viableCallableOld(c)) and
new = count(viableCallable(c)) and
old != new
select c, old + " -> " + new