@@ -183,19 +183,18 @@ module ValidState {
183183 // `AddInstruction` to the flow-state of any predecessor node.
184184 // For case 2 we simply propagate the valid flow-states from the predecessor node to
185185 // the next one.
186- exists ( PathNode n0 , DataFlow:: Node node , int value0 |
186+ exists ( PathNode n0 , DataFlow:: Node node0 , DataFlow :: Node node , int value0 |
187187 n0 .getASuccessor ( ) = n and
188188 validStateImpl ( n0 , value0 ) and
189- node = n .getNode ( )
189+ node = n .getNode ( ) and
190+ node0 = n0 .getNode ( )
190191 |
191- exists ( AddInstruction add , Operand op1 , Operand op2 , int delta |
192- add = node .asInstruction ( ) and
193- add .hasOperands ( op1 , op2 ) and
194- value0 = value + delta and
195- semBounded ( getSemanticExpr ( [ op1 , op2 ] .getDef ( ) ) , any ( SemZeroBound zero ) , delta , true , _)
192+ exists ( int delta |
193+ isAdditionalFlowStep2 ( node0 , node , delta ) and
194+ value0 = value + delta
196195 )
197196 or
198- not node . asInstruction ( ) instanceof AddInstruction and
197+ not isAdditionalFlowStep2 ( node0 , node , _ ) and
199198 value = value0
200199 )
201200 )
@@ -208,6 +207,20 @@ module ValidState {
208207
209208import ValidState
210209
210+ /**
211+ * Holds if `node2` is a dataflow node that represents an addition of two operands `op1`
212+ * and `op2` such that:
213+ * 1. `node1` is the dataflow node that represents `op1`, and
214+ * 2. the value of `op2` can be upper bounded by `delta.`
215+ */
216+ predicate isAdditionalFlowStep2 ( DataFlow:: Node node1 , DataFlow:: Node node2 , int delta ) {
217+ exists ( AddInstruction add , Operand op |
218+ add .hasOperands ( node1 .asOperand ( ) , op ) and
219+ semBounded ( getSemanticExpr ( op .getDef ( ) ) , any ( SemZeroBound zero ) , delta , true , _) and
220+ node2 .asInstruction ( ) = add
221+ )
222+ }
223+
211224module StringSizeConfig implements ProductFlow:: StateConfigSig {
212225 class FlowState1 = Unit ;
213226
@@ -251,13 +264,9 @@ module StringSizeConfig implements ProductFlow::StateConfigSig {
251264 DataFlow:: Node node1 , FlowState2 state1 , DataFlow:: Node node2 , FlowState2 state2
252265 ) {
253266 validState ( node2 , state2 ) and
254- exists ( AddInstruction add , Operand op , int delta , int s1 , int s2 |
255- state1 = s1 and
256- state2 = s2 and
257- add .hasOperands ( node1 .asOperand ( ) , op ) and
258- semBounded ( getSemanticExpr ( op .getDef ( ) ) , any ( SemZeroBound zero ) , delta , true , _) and
259- node2 .asInstruction ( ) = add and
260- s1 = s2 + delta
267+ exists ( int delta |
268+ isAdditionalFlowStep2 ( node1 , node2 , delta ) and
269+ state1 = state2 + delta
261270 )
262271 }
263272}
0 commit comments