mirror of
https://github.com/github/codeql.git
synced 2026-01-29 22:32:58 +01:00
Add queries to inspect and measure dispatch differences.
This commit is contained in:
1
ql/src/semmle/go/dataflow/internal/CompareDispatch.qhelp
Normal file
1
ql/src/semmle/go/dataflow/internal/CompareDispatch.qhelp
Normal file
@@ -0,0 +1 @@
|
||||
TBD
|
||||
20
ql/src/semmle/go/dataflow/internal/CompareDispatch.ql
Normal file
20
ql/src/semmle/go/dataflow/internal/CompareDispatch.ql
Normal 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"
|
||||
18
ql/src/semmle/go/dataflow/internal/DispatchStats.ql
Normal file
18
ql/src/semmle/go/dataflow/internal/DispatchStats.ql
Normal 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
|
||||
Reference in New Issue
Block a user