mirror of
https://github.com/github/codeql.git
synced 2026-04-27 01:35:13 +02:00
massively improve performance for detecting one-shot closures
This commit is contained in:
@@ -72,6 +72,9 @@ predicate benignContext(Expr e) {
|
||||
e = any(ResolvedPromiseDefinition promise).getValue().asExpr()
|
||||
}
|
||||
|
||||
predicate oneshotClosure(InvokeExpr call) {
|
||||
call.getCallee().getUnderlyingValue() instanceof ImmediatelyInvokedFunctionExpr
|
||||
}
|
||||
|
||||
from DataFlow::CallNode call
|
||||
where
|
||||
@@ -81,7 +84,7 @@ where
|
||||
not benignContext(call.asExpr()) and
|
||||
|
||||
// anonymous one-shot closure. Those are used in weird ways and we ignore them.
|
||||
call.asExpr() != any(ImmediatelyInvokedFunctionExpr f).getInvocation()
|
||||
not oneshotClosure(call.asExpr())
|
||||
select
|
||||
call, "the function $@ does not return anything, yet the return value is used.", call.getACallee(), call.getCalleeName()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user