@@ -119,39 +119,18 @@ private ControlFlowNode varDereference(SsaVariable v, VarAccess va) {
119119}
120120
121121/**
122- * A `ControlFlowNode` that ensures that the SSA variable is not null in any
123- * subsequent use, either by dereferencing it or by an assertion.
124- */
125- private ControlFlowNode ensureNotNull ( SsaVariable v ) { result = varDereference ( v , _) }
126-
127- private predicate assertFail ( BasicBlock bb , ControlFlowNode n ) {
128- bb = n .getBasicBlock ( ) and
129- methodCallUnconditionallyThrows ( n .asExpr ( ) )
130- }
131-
132- /**
133- * A variable dereference that cannot be reached by a `null` value, because of an earlier
134- * dereference or assertion in the same `BasicBlock`.
135- */
136- private predicate unreachableVarDereference ( BasicBlock bb , SsaVariable v , ControlFlowNode varDeref ) {
137- exists ( ControlFlowNode n , int i , int j |
138- ( n = ensureNotNull ( v ) or assertFail ( bb , n ) ) and
139- varDeref = varDereference ( v , _) and
140- bb .getNode ( i ) = n and
141- bb .getNode ( j ) = varDeref and
142- i < j
143- )
144- }
145-
146- /**
147- * The first dereference of a variable in a given `BasicBlock` excluding those dereferences
148- * that are preceded by a not-null assertion or a trivially failing assertion.
122+ * The first dereference of a variable in a given `BasicBlock`.
149123 */
150124private predicate firstVarDereferenceInBlock ( BasicBlock bb , SsaVariable v , VarAccess va ) {
151125 exists ( ControlFlowNode n |
152126 varDereference ( v , va ) = n and
153127 n .getBasicBlock ( ) = bb and
154- not unreachableVarDereference ( bb , v , n )
128+ n =
129+ min ( ControlFlowNode n0 , int i |
130+ varDereference ( v , _) = n0 and bb .getNode ( i ) = n0
131+ |
132+ n0 order by i
133+ )
155134 )
156135}
157136
0 commit comments