Skip to content

Commit c3cf48b

Browse files
committed
C++: Add a 'fieldFlowBranchLimit' override to the product flow library.
1 parent 9c5d735 commit c3cf48b

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

cpp/ql/lib/semmle/code/cpp/ir/dataflow/internal/ProductFlow.qll

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,30 @@ module ProductFlow {
8787
* dataflow graph.
8888
*/
8989
default predicate isBarrierIn2(DataFlow::Node node) { none() }
90+
91+
/**
92+
* Gets the virtual dispatch branching limit when calculating field flow in the first
93+
* projection of the product dataflow graph.
94+
*
95+
* This can be overridden to a smaller value to improve performance (a
96+
* value of 0 disables field flow), or a larger value to get more results.
97+
*/
98+
default int fieldFlowBranchLimit1() {
99+
// NOTE: This should be synchronized with the default value in the shared dataflow library
100+
result = 2
101+
}
102+
103+
/**
104+
* Gets the virtual dispatch branching limit when calculating field flow in the second
105+
* projection of the product dataflow graph.
106+
*
107+
* This can be overridden to a smaller value to improve performance (a
108+
* value of 0 disables field flow), or a larger value to get more results.
109+
*/
110+
default int fieldFlowBranchLimit2() {
111+
// NOTE: This should be synchronized with the default value in the shared dataflow library
112+
result = 2
113+
}
90114
}
91115

92116
/**
@@ -272,6 +296,30 @@ module ProductFlow {
272296
* dataflow graph.
273297
*/
274298
default predicate isBarrierIn2(DataFlow::Node node) { none() }
299+
300+
/**
301+
* Gets the virtual dispatch branching limit when calculating field flow in the first
302+
* projection of the product dataflow graph.
303+
*
304+
* This can be overridden to a smaller value to improve performance (a
305+
* value of 0 disables field flow), or a larger value to get more results.
306+
*/
307+
default int fieldFlowBranchLimit1() {
308+
// NOTE: This should be synchronized with the default value in the shared dataflow library
309+
result = 2
310+
}
311+
312+
/**
313+
* Gets the virtual dispatch branching limit when calculating field flow in the second
314+
* projection of the product dataflow graph.
315+
*
316+
* This can be overridden to a smaller value to improve performance (a
317+
* value of 0 disables field flow), or a larger value to get more results.
318+
*/
319+
default int fieldFlowBranchLimit2() {
320+
// NOTE: This should be synchronized with the default value in the shared dataflow library
321+
result = 2
322+
}
275323
}
276324

277325
/**
@@ -335,6 +383,8 @@ module ProductFlow {
335383
}
336384

337385
predicate isBarrierIn(DataFlow::Node node) { Config::isBarrierIn1(node) }
386+
387+
int fieldFlowBranchLimit() { result = Config::fieldFlowBranchLimit1() }
338388
}
339389

340390
private module Flow1 = DataFlow::GlobalWithState<Config1>;
@@ -367,6 +417,8 @@ module ProductFlow {
367417
}
368418

369419
predicate isBarrierIn(DataFlow::Node node) { Config::isBarrierIn2(node) }
420+
421+
int fieldFlowBranchLimit() { result = Config::fieldFlowBranchLimit2() }
370422
}
371423

372424
private module Flow2 = DataFlow::GlobalWithState<Config2>;

0 commit comments

Comments
 (0)