Skip to content

Commit ab5a471

Browse files
committed
Update DoNotUseRelationalOperatorsWithDifferingArrays to the new dataflow library
1 parent 3b05adc commit ab5a471

File tree

3 files changed

+49
-31
lines changed

3 files changed

+49
-31
lines changed

c/common/test/rules/donotuserelationaloperatorswithdifferingarrays/DoNotUseRelationalOperatorsWithDifferingArrays.expected

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,35 @@ problems
1010
| test.c:25:7:25:14 | ... >= ... | test.c:7:14:7:15 | l1 | test.c:25:7:25:8 | p1 | Compare operation >= comparing left operand pointing to array $@ and other operand pointing to array $@. | test.c:2:7:2:8 | l1 | l1 | test.c:4:7:4:8 | l3 | l3 |
1111
| test.c:25:7:25:14 | ... >= ... | test.c:25:13:25:14 | l3 | test.c:25:13:25:14 | l3 | Compare operation >= comparing right operand pointing to array $@ and other operand pointing to array $@. | test.c:4:7:4:8 | l3 | l3 | test.c:2:7:2:8 | l1 | l1 |
1212
edges
13+
| test.c:6:13:6:14 | l1 | test.c:6:13:6:14 | l1 | provenance | |
1314
| test.c:6:13:6:14 | l1 | test.c:13:12:13:13 | p0 | provenance | |
14-
| test.c:7:14:7:15 | l1 | test.c:7:14:7:18 | access to array | provenance | Config |
15-
| test.c:7:14:7:18 | access to array | test.c:11:7:11:8 | p1 | provenance | |
16-
| test.c:7:14:7:18 | access to array | test.c:13:7:13:8 | p1 | provenance | |
17-
| test.c:7:14:7:18 | access to array | test.c:15:13:15:14 | p1 | provenance | |
18-
| test.c:7:14:7:18 | access to array | test.c:17:7:17:8 | p1 | provenance | |
19-
| test.c:7:14:7:18 | access to array | test.c:23:13:23:14 | p1 | provenance | |
20-
| test.c:7:14:7:18 | access to array | test.c:25:7:25:8 | p1 | provenance | |
21-
| test.c:8:14:8:15 | l1 | test.c:8:14:8:18 | access to array | provenance | Config |
22-
| test.c:8:14:8:18 | access to array | test.c:11:12:11:13 | p2 | provenance | |
23-
| test.c:8:14:8:18 | access to array | test.c:21:7:21:8 | p2 | provenance | |
24-
| test.c:9:14:9:15 | l2 | test.c:9:14:9:18 | access to array | provenance | Config |
25-
| test.c:9:14:9:18 | access to array | test.c:21:12:21:13 | p3 | provenance | |
15+
| test.c:7:13:7:18 | & ... | test.c:7:13:7:18 | & ... | provenance | |
16+
| test.c:7:13:7:18 | & ... | test.c:11:7:11:8 | p1 | provenance | |
17+
| test.c:7:13:7:18 | & ... | test.c:13:7:13:8 | p1 | provenance | |
18+
| test.c:7:13:7:18 | & ... | test.c:15:13:15:14 | p1 | provenance | |
19+
| test.c:7:13:7:18 | & ... | test.c:17:7:17:8 | p1 | provenance | |
20+
| test.c:7:13:7:18 | & ... | test.c:23:13:23:14 | p1 | provenance | |
21+
| test.c:7:13:7:18 | & ... | test.c:25:7:25:8 | p1 | provenance | |
22+
| test.c:7:14:7:15 | l1 | test.c:7:13:7:18 | & ... | provenance | Config |
23+
| test.c:8:13:8:18 | & ... | test.c:8:13:8:18 | & ... | provenance | |
24+
| test.c:8:13:8:18 | & ... | test.c:11:12:11:13 | p2 | provenance | |
25+
| test.c:8:13:8:18 | & ... | test.c:21:7:21:8 | p2 | provenance | |
26+
| test.c:8:14:8:15 | l1 | test.c:8:13:8:18 | & ... | provenance | Config |
27+
| test.c:9:13:9:18 | & ... | test.c:9:13:9:18 | & ... | provenance | |
28+
| test.c:9:13:9:18 | & ... | test.c:21:12:21:13 | p3 | provenance | |
29+
| test.c:9:14:9:15 | l2 | test.c:9:13:9:18 | & ... | provenance | Config |
2630
nodes
2731
| test.c:6:13:6:14 | l1 | semmle.label | l1 |
32+
| test.c:6:13:6:14 | l1 | semmle.label | l1 |
33+
| test.c:7:13:7:18 | & ... | semmle.label | & ... |
34+
| test.c:7:13:7:18 | & ... | semmle.label | & ... |
2835
| test.c:7:14:7:15 | l1 | semmle.label | l1 |
29-
| test.c:7:14:7:18 | access to array | semmle.label | access to array |
36+
| test.c:8:13:8:18 | & ... | semmle.label | & ... |
37+
| test.c:8:13:8:18 | & ... | semmle.label | & ... |
3038
| test.c:8:14:8:15 | l1 | semmle.label | l1 |
31-
| test.c:8:14:8:18 | access to array | semmle.label | access to array |
39+
| test.c:9:13:9:18 | & ... | semmle.label | & ... |
40+
| test.c:9:13:9:18 | & ... | semmle.label | & ... |
3241
| test.c:9:14:9:15 | l2 | semmle.label | l2 |
33-
| test.c:9:14:9:18 | access to array | semmle.label | access to array |
3442
| test.c:11:7:11:8 | p1 | semmle.label | p1 |
3543
| test.c:11:12:11:13 | p2 | semmle.label | p2 |
3644
| test.c:13:7:13:8 | p1 | semmle.label | p1 |

cpp/common/src/codingstandards/cpp/rules/donotuserelationaloperatorswithdifferingarrays/DoNotUseRelationalOperatorsWithDifferingArrays.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import cpp
88
import codingstandards.cpp.Customizations
99
import codingstandards.cpp.Exclusions
10-
import semmle.code.cpp.dataflow.DataFlow
10+
import semmle.code.cpp.dataflow.new.DataFlow
1111
import ArrayToRelationalOperationOperandFlow::PathGraph
1212

1313
abstract class DoNotUseRelationalOperatorsWithDifferingArraysSharedQuery extends Query { }
@@ -43,6 +43,8 @@ module ArrayToRelationalOperationOperandConfig implements DataFlow::ConfigSig {
4343
// Add a flow step from the base to the array expression to track pointers to elements of the array.
4444
exists(ArrayExpr e | e.getArrayBase() = pred.asExpr() and e = succ.asExpr())
4545
}
46+
47+
predicate isBarrierIn(DataFlow::Node node) { isSource(node) }
4648
}
4749

4850
module ArrayToRelationalOperationOperandFlow =

cpp/common/test/rules/donotuserelationaloperatorswithdifferingarrays/DoNotUseRelationalOperatorsWithDifferingArrays.expected

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,35 @@ problems
1010
| test.cpp:25:7:25:14 | ... >= ... | test.cpp:7:14:7:15 | l1 | test.cpp:25:7:25:8 | p1 | Compare operation >= comparing left operand pointing to array $@ and other operand pointing to array $@. | test.cpp:2:7:2:8 | l1 | l1 | test.cpp:4:7:4:8 | l3 | l3 |
1111
| test.cpp:25:7:25:14 | ... >= ... | test.cpp:25:13:25:14 | l3 | test.cpp:25:13:25:14 | l3 | Compare operation >= comparing right operand pointing to array $@ and other operand pointing to array $@. | test.cpp:4:7:4:8 | l3 | l3 | test.cpp:2:7:2:8 | l1 | l1 |
1212
edges
13+
| test.cpp:6:13:6:14 | l1 | test.cpp:6:13:6:14 | l1 | provenance | |
1314
| test.cpp:6:13:6:14 | l1 | test.cpp:13:12:13:13 | p0 | provenance | |
14-
| test.cpp:7:14:7:15 | l1 | test.cpp:7:14:7:18 | access to array | provenance | Config |
15-
| test.cpp:7:14:7:18 | access to array | test.cpp:11:7:11:8 | p1 | provenance | |
16-
| test.cpp:7:14:7:18 | access to array | test.cpp:13:7:13:8 | p1 | provenance | |
17-
| test.cpp:7:14:7:18 | access to array | test.cpp:15:13:15:14 | p1 | provenance | |
18-
| test.cpp:7:14:7:18 | access to array | test.cpp:17:7:17:8 | p1 | provenance | |
19-
| test.cpp:7:14:7:18 | access to array | test.cpp:23:13:23:14 | p1 | provenance | |
20-
| test.cpp:7:14:7:18 | access to array | test.cpp:25:7:25:8 | p1 | provenance | |
21-
| test.cpp:8:14:8:15 | l1 | test.cpp:8:14:8:18 | access to array | provenance | Config |
22-
| test.cpp:8:14:8:18 | access to array | test.cpp:11:12:11:13 | p2 | provenance | |
23-
| test.cpp:8:14:8:18 | access to array | test.cpp:21:7:21:8 | p2 | provenance | |
24-
| test.cpp:9:14:9:15 | l2 | test.cpp:9:14:9:18 | access to array | provenance | Config |
25-
| test.cpp:9:14:9:18 | access to array | test.cpp:21:12:21:13 | p3 | provenance | |
15+
| test.cpp:7:13:7:18 | & ... | test.cpp:7:13:7:18 | & ... | provenance | |
16+
| test.cpp:7:13:7:18 | & ... | test.cpp:11:7:11:8 | p1 | provenance | |
17+
| test.cpp:7:13:7:18 | & ... | test.cpp:13:7:13:8 | p1 | provenance | |
18+
| test.cpp:7:13:7:18 | & ... | test.cpp:15:13:15:14 | p1 | provenance | |
19+
| test.cpp:7:13:7:18 | & ... | test.cpp:17:7:17:8 | p1 | provenance | |
20+
| test.cpp:7:13:7:18 | & ... | test.cpp:23:13:23:14 | p1 | provenance | |
21+
| test.cpp:7:13:7:18 | & ... | test.cpp:25:7:25:8 | p1 | provenance | |
22+
| test.cpp:7:14:7:15 | l1 | test.cpp:7:13:7:18 | & ... | provenance | Config |
23+
| test.cpp:8:13:8:18 | & ... | test.cpp:8:13:8:18 | & ... | provenance | |
24+
| test.cpp:8:13:8:18 | & ... | test.cpp:11:12:11:13 | p2 | provenance | |
25+
| test.cpp:8:13:8:18 | & ... | test.cpp:21:7:21:8 | p2 | provenance | |
26+
| test.cpp:8:14:8:15 | l1 | test.cpp:8:13:8:18 | & ... | provenance | Config |
27+
| test.cpp:9:13:9:18 | & ... | test.cpp:9:13:9:18 | & ... | provenance | |
28+
| test.cpp:9:13:9:18 | & ... | test.cpp:21:12:21:13 | p3 | provenance | |
29+
| test.cpp:9:14:9:15 | l2 | test.cpp:9:13:9:18 | & ... | provenance | Config |
2630
nodes
2731
| test.cpp:6:13:6:14 | l1 | semmle.label | l1 |
32+
| test.cpp:6:13:6:14 | l1 | semmle.label | l1 |
33+
| test.cpp:7:13:7:18 | & ... | semmle.label | & ... |
34+
| test.cpp:7:13:7:18 | & ... | semmle.label | & ... |
2835
| test.cpp:7:14:7:15 | l1 | semmle.label | l1 |
29-
| test.cpp:7:14:7:18 | access to array | semmle.label | access to array |
36+
| test.cpp:8:13:8:18 | & ... | semmle.label | & ... |
37+
| test.cpp:8:13:8:18 | & ... | semmle.label | & ... |
3038
| test.cpp:8:14:8:15 | l1 | semmle.label | l1 |
31-
| test.cpp:8:14:8:18 | access to array | semmle.label | access to array |
39+
| test.cpp:9:13:9:18 | & ... | semmle.label | & ... |
40+
| test.cpp:9:13:9:18 | & ... | semmle.label | & ... |
3241
| test.cpp:9:14:9:15 | l2 | semmle.label | l2 |
33-
| test.cpp:9:14:9:18 | access to array | semmle.label | access to array |
3442
| test.cpp:11:7:11:8 | p1 | semmle.label | p1 |
3543
| test.cpp:11:12:11:13 | p2 | semmle.label | p2 |
3644
| test.cpp:13:7:13:8 | p1 | semmle.label | p1 |

0 commit comments

Comments
 (0)