@@ -4,6 +4,7 @@ module Private {
44 private import semmle.code.java.dataflow.RangeUtils as RU
55 private import semmle.code.java.controlflow.Guards as G
66 private import semmle.code.java.controlflow.BasicBlocks as BB
7+ private import semmle.code.java.controlflow.internal.GuardsLogic as GL
78 private import SsaReadPositionCommon
89
910 class BasicBlock = BB:: BasicBlock ;
@@ -100,9 +101,33 @@ module Private {
100101 }
101102 }
102103
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 (
110+ Guard guard , SsaReadPosition controlled , boolean testIsTrue
111+ ) {
112+ guard .directlyControls ( controlled .( SsaReadPositionBlock ) .getBlock ( ) , testIsTrue )
113+ or
114+ exists ( SsaReadPositionPhiInputEdge controlledEdge | controlledEdge = controlled |
115+ guard .directlyControls ( controlledEdge .getOrigBlock ( ) , testIsTrue ) or
116+ guard .hasBranchEdge ( controlledEdge .getOrigBlock ( ) , controlledEdge .getPhiBlock ( ) , testIsTrue )
117+ )
118+ }
104119
105- predicate guardControlsSsaRead = RU:: guardControlsSsaRead / 3 ;
120+ /**
121+ * Holds if `guard` controls the position `controlled` with the value `testIsTrue`.
122+ */
123+ predicate guardControlsSsaRead ( Guard guard , SsaReadPosition controlled , boolean testIsTrue ) {
124+ guardDirectlyControlsSsaRead ( guard , controlled , testIsTrue )
125+ or
126+ exists ( Guard guard0 , boolean testIsTrue0 |
127+ GL:: implies_v2 ( guard0 , testIsTrue0 , guard , testIsTrue ) and
128+ guardControlsSsaRead ( guard0 , controlled , testIsTrue0 )
129+ )
130+ }
106131
107132 predicate valueFlowStep = RU:: valueFlowStep / 3 ;
108133
0 commit comments