@@ -46,6 +46,46 @@ module Conf4 implements ConfigSig {
4646 predicate isBarrierOut ( Node n ) { sink0 ( n ) }
4747}
4848
49+ module StateConf1 implements StateConfigSig {
50+ class FlowState = Unit ;
51+
52+ predicate isSource ( Node n , FlowState state ) { src0 ( n ) and exists ( state ) }
53+
54+ predicate isSink ( Node n , FlowState state ) { sink0 ( n ) and exists ( state ) }
55+ }
56+
57+ module StateConf2 implements StateConfigSig {
58+ class FlowState = Unit ;
59+
60+ predicate isSource ( Node n , FlowState state ) { src0 ( n ) and exists ( state ) }
61+
62+ predicate isSink ( Node n , FlowState state ) { sink0 ( n ) and exists ( state ) }
63+
64+ predicate isBarrierIn ( Node n , FlowState state ) { isSource ( n , state ) }
65+ }
66+
67+ module StateConf3 implements StateConfigSig {
68+ class FlowState = Unit ;
69+
70+ predicate isSource ( Node n , FlowState state ) { src0 ( n ) and exists ( state ) }
71+
72+ predicate isSink ( Node n , FlowState state ) { sink0 ( n ) and exists ( state ) }
73+
74+ predicate isBarrierOut ( Node n , FlowState state ) { isSink ( n , state ) }
75+ }
76+
77+ module StateConf4 implements StateConfigSig {
78+ class FlowState = Unit ;
79+
80+ predicate isSource ( Node n , FlowState state ) { src0 ( n ) and exists ( state ) }
81+
82+ predicate isSink ( Node n , FlowState state ) { sink0 ( n ) and exists ( state ) }
83+
84+ predicate isBarrierIn ( Node n , FlowState state ) { isSource ( n , state ) }
85+
86+ predicate isBarrierOut ( Node n , FlowState state ) { isSink ( n , state ) }
87+ }
88+
4989predicate flow ( Node src , Node sink , string s ) {
5090 Global< Conf1 > :: flow ( src , sink ) and s = "nobarrier"
5191 or
@@ -56,6 +96,26 @@ predicate flow(Node src, Node sink, string s) {
5696 Global< Conf4 > :: flow ( src , sink ) and s = "both"
5797}
5898
99+ predicate stateFlow ( Node src , Node sink , string s ) {
100+ GlobalWithState< StateConf1 > :: flow ( src , sink ) and s = "nobarrier"
101+ or
102+ GlobalWithState< StateConf2 > :: flow ( src , sink ) and s = "srcbarrier"
103+ or
104+ GlobalWithState< StateConf3 > :: flow ( src , sink ) and s = "sinkbarrier"
105+ or
106+ GlobalWithState< StateConf4 > :: flow ( src , sink ) and s = "both"
107+ }
108+
109+ query predicate inconsistentFlow ( Node src , Node sink , string message ) {
110+ exists ( string kind |
111+ ( flow ( src , sink , kind ) and not stateFlow ( src , sink , kind ) ) and
112+ message = "missing state-flow in configuration " + kind
113+ or
114+ ( not flow ( src , sink , kind ) and stateFlow ( src , sink , kind ) ) and
115+ message = "spurious state-flow in configuration " + kind
116+ )
117+ }
118+
59119from Node src , Node sink , string s
60120where flow ( src , sink , _) and s = concat ( any ( string s0 | flow ( src , sink , s0 ) ) , ", " )
61121select src , sink , s
0 commit comments