Skip to content

Commit 6f24074

Browse files
committed
C++: Update some dataflow tests to use DataFlow::ConfigSig
1 parent 8253f2d commit 6f24074

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
import cpp
22
import semmle.code.cpp.ir.dataflow.DataFlow
33

4-
class TestConfig extends DataFlow::Configuration {
5-
TestConfig() { this = "TestConfig" }
6-
7-
override predicate isSource(DataFlow::Node source) {
4+
module TestConfig implements DataFlow::ConfigSig {
5+
predicate isSource(DataFlow::Node source) {
86
source.asExpr().(FunctionCall).getTarget().getName() = "source"
97
}
108

11-
override predicate isSink(DataFlow::Node sink) {
9+
predicate isSink(DataFlow::Node sink) {
1210
exists(FunctionCall call |
1311
call.getTarget().getName() = "sink" and
1412
sink.asExpr() = call.getAnArgument()
1513
)
1614
}
1715
}
1816

19-
from DataFlow::Node sink, DataFlow::Node source, TestConfig cfg
20-
where cfg.hasFlow(source, sink)
17+
module TestFlow = DataFlow::Make<TestConfig>;
18+
19+
from DataFlow::Node sink, DataFlow::Node source
20+
where TestFlow::hasFlow(source, sink)
2121
select sink, source
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
import cpp
22
import semmle.code.cpp.ir.dataflow.DataFlow
33

4-
class TestConfig extends DataFlow::Configuration {
5-
TestConfig() { this = "TestConfig" }
6-
7-
override predicate isSource(DataFlow::Node source) {
4+
module TestConfig implements DataFlow::ConfigSig {
5+
predicate isSource(DataFlow::Node source) {
86
source.asExpr().(FunctionCall).getTarget().getName() = "source"
97
}
108

11-
override predicate isSink(DataFlow::Node sink) {
9+
predicate isSink(DataFlow::Node sink) {
1210
exists(FunctionCall call |
1311
call.getTarget().getName() = "sink" and
1412
sink.asExpr() = call.getAnArgument()
1513
)
1614
}
1715

18-
override predicate isAdditionalFlowStep(DataFlow::Node n1, DataFlow::Node n2) {
16+
predicate isAdditionalFlowStep(DataFlow::Node n1, DataFlow::Node n2) {
1917
// Send all arguments of function-pointer-calls to a function with a
2018
// special name
2119
exists(Call call, Function target, int i |
@@ -27,6 +25,8 @@ class TestConfig extends DataFlow::Configuration {
2725
}
2826
}
2927

30-
from DataFlow::Node sink, DataFlow::Node source, TestConfig cfg
31-
where cfg.hasFlow(source, sink)
28+
module TestFlow = DataFlow::Make<TestConfig>;
29+
30+
from DataFlow::Node sink, DataFlow::Node source
31+
where TestFlow::hasFlow(source, sink)
3232
select sink, source
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import cpp
22
import semmle.code.cpp.ir.dataflow.DataFlow
33

4-
class Cfg extends DataFlow::Configuration {
5-
Cfg() { this = "from0::Cfg" }
4+
module Cfg implements DataFlow::ConfigSig {
5+
predicate isSource(DataFlow::Node source) { source.asExpr().getValue() = "0" }
66

7-
override predicate isSource(DataFlow::Node source) { source.asExpr().getValue() = "0" }
8-
9-
override predicate isSink(DataFlow::Node sink) { sink.asExpr() instanceof VariableAccess }
7+
predicate isSink(DataFlow::Node sink) { sink.asExpr() instanceof VariableAccess }
108
}
119

12-
from Cfg cfg, Expr sink
13-
where cfg.hasFlowToExpr(sink)
10+
module Flow = DataFlow::Make<Cfg>;
11+
12+
from Expr sink
13+
where Flow::hasFlowToExpr(sink)
1414
select sink

0 commit comments

Comments
 (0)