Skip to content

Commit 3a30e2a

Browse files
committed
Java: Reinstate useless null check results for fields that are no longer tracked as SSA variables.
1 parent 042f230 commit 3a30e2a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

java/ql/lib/semmle/code/java/dataflow/NullGuards.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ Expr clearlyNotNullExpr(Expr reason) {
105105
result = v.getARead() and
106106
not result = baseNotNullExpr()
107107
)
108+
or
109+
exists(Field f |
110+
result = f.getAnAccess() and
111+
f.isFinal() and
112+
f.getInitializer() = clearlyNotNullExpr(reason) and
113+
not result = baseNotNullExpr()
114+
)
108115
}
109116

110117
/** Holds if `v` is an SSA variable that is provably not `null`. */

0 commit comments

Comments
 (0)