File tree 1 file changed +7
-5
lines changed
ruby/ql/src/queries/variables
1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,12 @@ Expr evaluatingMention(LocalVariableReadAccess read) {
51
51
result .( NotExpr ) .getOperand ( ) = read
52
52
}
53
53
54
+ predicate loopProtects ( ConditionalLoop l , LocalVariableReadAccess read ) {
55
+ l .getCondition ( ) = read .getVariable ( ) .getAnAccess ( ) and
56
+ l .entersLoopWhenConditionIs ( false ) and
57
+ l .getAControlFlowNode ( ) .getBasicBlock ( ) .dominates ( read .getAControlFlowNode ( ) .getBasicBlock ( ) )
58
+ }
59
+
54
60
class RelevantLocalVariableReadAccess extends LocalVariableReadAccess {
55
61
RelevantLocalVariableReadAccess ( ) {
56
62
not exists ( MethodCall c |
@@ -76,11 +82,7 @@ class RelevantLocalVariableReadAccess extends LocalVariableReadAccess {
76
82
not exists ( ConditionalExpr c | factor ( c .getCondition ( ) , this .getVariable ( ) .getAnAccess ( ) ) |
77
83
this = c .getBranch ( true ) .getAChild * ( )
78
84
) and
79
- not exists ( ConditionalLoop l |
80
- l .getCondition ( ) = this .getVariable ( ) .getAnAccess ( ) and
81
- l .entersLoopWhenConditionIs ( false ) and
82
- l .getAControlFlowNode ( ) .getBasicBlock ( ) .dominates ( this .getAControlFlowNode ( ) .getBasicBlock ( ) )
83
- )
85
+ not exists ( ConditionalLoop l | loopProtects ( l , this ) )
84
86
}
85
87
}
86
88
You can’t perform that action at this time.
0 commit comments