@@ -3,33 +3,42 @@ import DataFlowConfig
33
44query predicate dataFlow ( DataFlow:: Node src , DataFlow:: Node snk ) { TestFlow:: flow ( src , snk ) }
55
6- class Parity extends DataFlow:: FlowLabel {
7- Parity ( ) { this = "even" or this = "odd" }
8-
9- Parity flip ( ) { result != this }
10- }
11-
126module FlowLabelConfig implements DataFlow:: StateConfigSig {
13- class FlowState = DataFlow:: FlowLabel ;
7+ private newtype TFlowState =
8+ TEven ( ) or
9+ TOdd ( )
10+
11+ class FlowState extends TFlowState {
12+ string toString ( ) {
13+ this = TEven ( ) and result = "even"
14+ or
15+ this = TOdd ( ) and result = "odd"
16+ }
17+
18+ FlowState flip ( ) {
19+ this = TEven ( ) and result = TOdd ( )
20+ or
21+ this = TOdd ( ) and result = TEven ( )
22+ }
23+ }
1424
15- predicate isSource ( DataFlow:: Node nd , DataFlow :: FlowLabel lbl ) {
25+ predicate isSource ( DataFlow:: Node nd , FlowState state ) {
1626 nd .( DataFlow:: CallNode ) .getCalleeName ( ) = "source" and
17- lbl = "even"
27+ state = TEven ( )
1828 }
1929
20- predicate isSink ( DataFlow:: Node nd , DataFlow :: FlowLabel lbl ) {
30+ predicate isSink ( DataFlow:: Node nd , FlowState state ) {
2131 nd = any ( DataFlow:: CallNode c | c .getCalleeName ( ) = "sink" ) .getAnArgument ( ) and
22- lbl = "even"
32+ state = TEven ( )
2333 }
2434
2535 predicate isAdditionalFlowStep (
26- DataFlow:: Node pred , DataFlow:: FlowLabel predLabel , DataFlow:: Node succ ,
27- DataFlow:: FlowLabel succLabel
36+ DataFlow:: Node node1 , FlowState state1 , DataFlow:: Node node2 , FlowState state2
2837 ) {
29- exists ( DataFlow:: CallNode c | c = succ |
38+ exists ( DataFlow:: CallNode c | c = node2 |
3039 c .getCalleeName ( ) = "inc" and
31- pred = c .getAnArgument ( ) and
32- succLabel = predLabel . ( Parity ) .flip ( )
40+ node1 = c .getAnArgument ( ) and
41+ state2 = state1 .flip ( )
3342 )
3443 }
3544}
0 commit comments