File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
ruby/ql/src/queries/variables Expand file tree Collapse file tree 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) {
5151 result .( NotExpr ) .getOperand ( ) = read
5252}
5353
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+
5460class RelevantLocalVariableReadAccess extends LocalVariableReadAccess {
5561 RelevantLocalVariableReadAccess ( ) {
5662 not exists ( MethodCall c |
@@ -76,11 +82,7 @@ class RelevantLocalVariableReadAccess extends LocalVariableReadAccess {
7682 not exists ( ConditionalExpr c | factor ( c .getCondition ( ) , this .getVariable ( ) .getAnAccess ( ) ) |
7783 this = c .getBranch ( true ) .getAChild * ( )
7884 ) 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 ) )
8486 }
8587}
8688
You can’t perform that action at this time.
0 commit comments