mirror of
https://github.com/github/codeql.git
synced 2026-04-26 09:15:12 +02:00
Java: Replace some references to basicNullGuard.
This commit is contained in:
@@ -306,10 +306,21 @@ private Method customNullGuard(int index, boolean retval, boolean isnull) {
|
||||
}
|
||||
|
||||
/**
|
||||
* `guard` is a guard expression that suggests that `v` might be null.
|
||||
*
|
||||
* This is equivalent to `guard = basicNullGuard(sameValue(v, _), _, true)`.
|
||||
* Holds if `guard` is a guard expression that suggests that `e` might be null.
|
||||
*/
|
||||
predicate guardSuggestsExprMaybeNull(Expr guard, Expr e) {
|
||||
guard.(EqualityTest).hasOperands(e, any(NullLiteral n))
|
||||
or
|
||||
exists(MethodCall call |
|
||||
call = guard and
|
||||
call.getAnArgument() = e and
|
||||
nullCheckMethod(call.getMethod(), _, true)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `guard` is a guard expression that suggests that `v` might be null.
|
||||
*/
|
||||
predicate guardSuggestsVarMaybeNull(Expr guard, SsaVariable v) {
|
||||
guard = basicNullGuard(sameValue(v, _), _, true)
|
||||
guardSuggestsExprMaybeNull(guard, sameValue(v, _))
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import semmle.code.java.controlflow.Guards
|
||||
|
||||
from Expr guard, Expr e, Expr reason, string msg
|
||||
where
|
||||
guard = basicNullGuard(e, _, true) and
|
||||
guardSuggestsExprMaybeNull(guard, e) and
|
||||
e = clearlyNotNullExpr(reason) and
|
||||
(
|
||||
if reason instanceof Guard
|
||||
|
||||
Reference in New Issue
Block a user