@@ -4,6 +4,7 @@ module Private {
4
4
private import semmle.code.java.dataflow.RangeUtils as RU
5
5
private import semmle.code.java.controlflow.Guards as G
6
6
private import semmle.code.java.controlflow.BasicBlocks as BB
7
+ private import semmle.code.java.controlflow.internal.GuardsLogic as GL
7
8
private import SsaReadPositionCommon
8
9
9
10
class BasicBlock = BB:: BasicBlock ;
@@ -100,9 +101,31 @@ module Private {
100
101
}
101
102
}
102
103
103
- predicate guardDirectlyControlsSsaRead = RU:: guardDirectlyControlsSsaRead / 3 ;
104
+ /**
105
+ * Holds if `guard` directly controls the position `controlled` with the
106
+ * value `testIsTrue`.
107
+ */
108
+ pragma [ nomagic]
109
+ predicate guardDirectlyControlsSsaRead ( Guard guard , SsaReadPosition controlled , boolean testIsTrue ) {
110
+ guard .directlyControls ( controlled .( SsaReadPositionBlock ) .getBlock ( ) , testIsTrue )
111
+ or
112
+ exists ( SsaReadPositionPhiInputEdge controlledEdge | controlledEdge = controlled |
113
+ guard .directlyControls ( controlledEdge .getOrigBlock ( ) , testIsTrue ) or
114
+ guard .hasBranchEdge ( controlledEdge .getOrigBlock ( ) , controlledEdge .getPhiBlock ( ) , testIsTrue )
115
+ )
116
+ }
104
117
105
- predicate guardControlsSsaRead = RU:: guardControlsSsaRead / 3 ;
118
+ /**
119
+ * Holds if `guard` controls the position `controlled` with the value `testIsTrue`.
120
+ */
121
+ predicate guardControlsSsaRead ( Guard guard , SsaReadPosition controlled , boolean testIsTrue ) {
122
+ guardDirectlyControlsSsaRead ( guard , controlled , testIsTrue )
123
+ or
124
+ exists ( Guard guard0 , boolean testIsTrue0 |
125
+ GL:: implies_v2 ( guard0 , testIsTrue0 , guard , testIsTrue ) and
126
+ guardControlsSsaRead ( guard0 , controlled , testIsTrue0 )
127
+ )
128
+ }
106
129
107
130
predicate valueFlowStep = RU:: valueFlowStep / 3 ;
108
131
0 commit comments