Skip to content

Commit a38c317

Browse files
committed
C++: Use Unit instead of string in product flow
1 parent 9b89a30 commit a38c317

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

cpp/ql/lib/experimental/semmle/code/cpp/dataflow/ProductFlow.qll

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import semmle.code.cpp.ir.dataflow.DataFlow
2+
private import codeql.util.Unit
23

34
module ProductFlow {
45
signature module ConfigSig {
@@ -68,33 +69,33 @@ module ProductFlow {
6869

6970
module Make<ConfigSig Config> {
7071
private module StateConfig implements StateConfigSig {
71-
class FlowState1 = DataFlow::FlowState;
72+
class FlowState1 = Unit;
7273

73-
class FlowState2 = DataFlow::FlowState;
74+
class FlowState2 = Unit;
7475

7576
predicate isSourcePair(
7677
DataFlow::Node source1, FlowState1 state1, DataFlow::Node source2, FlowState2 state2
7778
) {
78-
state1 instanceof DataFlow::FlowStateEmpty and
79-
state2 instanceof DataFlow::FlowStateEmpty and
79+
exists(state1) and
80+
exists(state2) and
8081
Config::isSourcePair(source1, source2)
8182
}
8283

8384
predicate isSinkPair(
8485
DataFlow::Node sink1, FlowState1 state1, DataFlow::Node sink2, FlowState2 state2
8586
) {
86-
state1 instanceof DataFlow::FlowStateEmpty and
87-
state2 instanceof DataFlow::FlowStateEmpty and
87+
exists(state1) and
88+
exists(state2) and
8889
Config::isSinkPair(sink1, sink2)
8990
}
9091

9192
predicate isBarrier1(DataFlow::Node node, FlowState1 state) {
92-
state instanceof DataFlow::FlowStateEmpty and
93+
exists(state) and
9394
Config::isBarrier1(node)
9495
}
9596

9697
predicate isBarrier2(DataFlow::Node node, FlowState2 state) {
97-
state instanceof DataFlow::FlowStateEmpty and
98+
exists(state) and
9899
Config::isBarrier2(node)
99100
}
100101

@@ -111,8 +112,8 @@ module ProductFlow {
111112
predicate isAdditionalFlowStep1(
112113
DataFlow::Node node1, FlowState1 state1, DataFlow::Node node2, FlowState1 state2
113114
) {
114-
state1 instanceof DataFlow::FlowStateEmpty and
115-
state2 instanceof DataFlow::FlowStateEmpty and
115+
exists(state1) and
116+
exists(state2) and
116117
Config::isAdditionalFlowStep1(node1, node2)
117118
}
118119

@@ -121,8 +122,8 @@ module ProductFlow {
121122
predicate isAdditionalFlowStep2(
122123
DataFlow::Node node1, FlowState2 state1, DataFlow::Node node2, FlowState2 state2
123124
) {
124-
state1 instanceof DataFlow::FlowStateEmpty and
125-
state2 instanceof DataFlow::FlowStateEmpty and
125+
exists(state1) and
126+
exists(state2) and
126127
Config::isAdditionalFlowStep2(node1, node2)
127128
}
128129

0 commit comments

Comments
 (0)