@@ -142,28 +142,15 @@ private class LogicalNotValueNumber extends ValueNumber {
142
142
/**
143
143
* A Boolean condition in the AST that guards one or more basic blocks. This includes
144
144
* operands of logical operators but not switch statements.
145
- *
146
- * For performance reasons conditions inside static local initializers or
147
- * global initializers are not considered `GuardCondition`s.
148
145
*/
149
- cached
150
- class GuardCondition extends Expr {
151
- cached
152
- GuardCondition ( ) {
153
- exists ( IRGuardCondition ir | this = ir .getUnconvertedResultExpression ( ) )
154
- or
155
- // no binary operators in the IR
156
- this .( BinaryLogicalOperation ) .getAnOperand ( ) instanceof GuardCondition
157
- }
158
-
146
+ abstract private class GuardConditionImpl extends Expr {
159
147
/**
160
148
* Holds if this condition controls `controlled`, meaning that `controlled` is only
161
149
* entered if the value of this condition is `v`.
162
150
*
163
151
* For details on what "controls" mean, see the QLDoc for `controls`.
164
152
*/
165
- cached
166
- predicate valueControls ( BasicBlock controlled , AbstractValue v ) { none ( ) }
153
+ abstract predicate valueControls ( BasicBlock controlled , AbstractValue v ) ;
167
154
168
155
/**
169
156
* Holds if this condition controls `controlled`, meaning that `controlled` is only
@@ -197,61 +184,58 @@ class GuardCondition extends Expr {
197
184
}
198
185
199
186
/** Holds if (determined by this guard) `left < right + k` evaluates to `isLessThan` if this expression evaluates to `testIsTrue`. */
200
- cached
201
- predicate comparesLt ( Expr left , Expr right , int k , boolean isLessThan , boolean testIsTrue ) {
202
- none ( )
203
- }
187
+ abstract predicate comparesLt ( Expr left , Expr right , int k , boolean isLessThan , boolean testIsTrue ) ;
204
188
205
189
/**
206
190
* Holds if (determined by this guard) `left < right + k` must be `isLessThan` in `block`.
207
191
* If `isLessThan = false` then this implies `left >= right + k`.
208
192
*/
209
193
cached
210
- predicate ensuresLt ( Expr left , Expr right , int k , BasicBlock block , boolean isLessThan ) { none ( ) }
194
+ abstract predicate ensuresLt ( Expr left , Expr right , int k , BasicBlock block , boolean isLessThan ) ;
211
195
212
196
/**
213
197
* Holds if (determined by this guard) `e < k` evaluates to `isLessThan` if
214
198
* this expression evaluates to `value`.
215
199
*/
216
200
cached
217
- predicate comparesLt ( Expr e , int k , boolean isLessThan , AbstractValue value ) { none ( ) }
201
+ abstract predicate comparesLt ( Expr e , int k , boolean isLessThan , AbstractValue value ) ;
218
202
219
203
/**
220
204
* Holds if (determined by this guard) `e < k` must be `isLessThan` in `block`.
221
205
* If `isLessThan = false` then this implies `e >= k`.
222
206
*/
223
207
cached
224
- predicate ensuresLt ( Expr e , int k , BasicBlock block , boolean isLessThan ) { none ( ) }
208
+ abstract predicate ensuresLt ( Expr e , int k , BasicBlock block , boolean isLessThan ) ;
225
209
226
210
/** Holds if (determined by this guard) `left == right + k` evaluates to `areEqual` if this expression evaluates to `testIsTrue`. */
227
211
cached
228
- predicate comparesEq ( Expr left , Expr right , int k , boolean areEqual , boolean testIsTrue ) {
229
- none ( )
230
- }
212
+ abstract predicate comparesEq ( Expr left , Expr right , int k , boolean areEqual , boolean testIsTrue ) ;
231
213
232
214
/**
233
215
* Holds if (determined by this guard) `left == right + k` must be `areEqual` in `block`.
234
216
* If `areEqual = false` then this implies `left != right + k`.
235
217
*/
236
218
cached
237
- predicate ensuresEq ( Expr left , Expr right , int k , BasicBlock block , boolean areEqual ) { none ( ) }
219
+ abstract predicate ensuresEq ( Expr left , Expr right , int k , BasicBlock block , boolean areEqual ) ;
238
220
239
221
/** Holds if (determined by this guard) `e == k` evaluates to `areEqual` if this expression evaluates to `value`. */
240
222
cached
241
- predicate comparesEq ( Expr e , int k , boolean areEqual , AbstractValue value ) { none ( ) }
223
+ abstract predicate comparesEq ( Expr e , int k , boolean areEqual , AbstractValue value ) ;
242
224
243
225
/**
244
226
* Holds if (determined by this guard) `e == k` must be `areEqual` in `block`.
245
227
* If `areEqual = false` then this implies `e != k`.
246
228
*/
247
229
cached
248
- predicate ensuresEq ( Expr e , int k , BasicBlock block , boolean areEqual ) { none ( ) }
230
+ abstract predicate ensuresEq ( Expr e , int k , BasicBlock block , boolean areEqual ) ;
249
231
}
250
232
233
+ final class GuardCondition = GuardConditionImpl ;
234
+
251
235
/**
252
236
* A binary logical operator in the AST that guards one or more basic blocks.
253
237
*/
254
- private class GuardConditionFromBinaryLogicalOperator extends GuardCondition {
238
+ private class GuardConditionFromBinaryLogicalOperator extends GuardConditionImpl {
255
239
GuardConditionFromBinaryLogicalOperator ( ) {
256
240
this .( BinaryLogicalOperation ) .getAnOperand ( ) instanceof GuardCondition
257
241
}
@@ -329,7 +313,7 @@ private class GuardConditionFromBinaryLogicalOperator extends GuardCondition {
329
313
* A Boolean condition in the AST that guards one or more basic blocks and has a corresponding IR
330
314
* instruction.
331
315
*/
332
- private class GuardConditionFromIR extends GuardCondition {
316
+ private class GuardConditionFromIR extends GuardConditionImpl {
333
317
IRGuardCondition ir ;
334
318
335
319
GuardConditionFromIR ( ) { this = ir .getUnconvertedResultExpression ( ) }
0 commit comments