Skip to content

Commit dfff976

Browse files
authored
Merge pull request #936 from MathiasVP/better-global-variable-flow-follow-up
C++: Fix queries after #20126
2 parents a7924d5 + 086a4ed commit dfff976

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

c/cert/src/rules/CON30-C/CleanUpThreadSpecificStorage.ql

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,28 @@ import codingstandards.c.cert
2222
import codingstandards.cpp.ConcurrencyNew
2323
import semmle.code.cpp.dataflow.new.DataFlow
2424

25+
newtype Direction =
26+
Incoming() or
27+
Outgoing()
28+
29+
predicate isSource(DataFlow::Node node, Direction d) {
30+
exists(TSSCreateFunctionCall tsc, Expr e |
31+
// the only requirement of the source is that at some point
32+
// it refers to the key of a create statement
33+
e.getParent*() = tsc.getKey()
34+
|
35+
d = Outgoing() and
36+
e = [node.asExpr(), node.asDefiningArgument()]
37+
or
38+
d = Incoming() and
39+
e = [node.asExpr(), node.asIndirectArgument()]
40+
)
41+
}
42+
2543
module TssCreateToTssDeleteConfig implements DataFlow::ConfigSig {
26-
predicate isSource(DataFlow::Node node) {
27-
exists(TSSCreateFunctionCall tsc, Expr e |
28-
// the only requirement of the source is that at some point
29-
// it refers to the key of a create statement
30-
e.getParent*() = tsc.getKey() and
31-
(e = node.asDefiningArgument() or e = node.asExpr())
32-
)
33-
}
44+
predicate isSource(DataFlow::Node node) { isSource(node, Outgoing()) }
45+
46+
predicate isBarrierIn(DataFlow::Node node) { isSource(node, Incoming()) }
3447

3548
predicate isSink(DataFlow::Node node) {
3649
exists(TSSDeleteFunctionCall tsd, Expr e |

c/misra/test/rules/RULE-21-26/TimedlockOnInappropriateMutexType.expected

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
edges
2+
| test.c:3:7:3:8 | *g1 | test.c:3:7:3:8 | *g1 | provenance | |
3+
| test.c:3:7:3:8 | *g1 | test.c:14:17:14:19 | *& ... | provenance | |
4+
| test.c:3:7:3:8 | *g1 | test.c:15:14:15:16 | *& ... | provenance | |
5+
| test.c:4:7:4:8 | *g2 | test.c:4:7:4:8 | *g2 | provenance | |
6+
| test.c:4:7:4:8 | *g2 | test.c:18:17:18:19 | *& ... | provenance | |
7+
| test.c:4:7:4:8 | *g2 | test.c:19:14:19:16 | *& ... | provenance | |
8+
| test.c:10:24:10:24 | *m | test.c:10:24:10:24 | *m | provenance | |
29
| test.c:10:24:10:24 | *m | test.c:10:43:10:43 | *m | provenance | |
10+
| test.c:10:24:10:24 | *m | test.c:10:43:10:43 | *m | provenance | |
11+
| test.c:13:12:13:14 | mtx_init output argument | test.c:3:7:3:8 | *g1 | provenance | |
312
| test.c:13:12:13:14 | mtx_init output argument | test.c:14:17:14:19 | *& ... | provenance | |
413
| test.c:13:12:13:14 | mtx_init output argument | test.c:15:14:15:16 | *& ... | provenance | |
514
| test.c:15:14:15:16 | *& ... | test.c:10:24:10:24 | *m | provenance | |
15+
| test.c:15:14:15:16 | *& ... | test.c:15:14:15:16 | doTimeLock output argument | provenance | |
16+
| test.c:15:14:15:16 | doTimeLock output argument | test.c:3:7:3:8 | *g1 | provenance | |
17+
| test.c:17:12:17:14 | mtx_init output argument | test.c:4:7:4:8 | *g2 | provenance | |
618
| test.c:17:12:17:14 | mtx_init output argument | test.c:18:17:18:19 | *& ... | provenance | |
719
| test.c:17:12:17:14 | mtx_init output argument | test.c:19:14:19:16 | *& ... | provenance | |
820
| test.c:19:14:19:16 | *& ... | test.c:10:24:10:24 | *m | provenance | |
21+
| test.c:19:14:19:16 | *& ... | test.c:19:14:19:16 | doTimeLock output argument | provenance | |
22+
| test.c:19:14:19:16 | doTimeLock output argument | test.c:4:7:4:8 | *g2 | provenance | |
923
| test.c:30:12:30:14 | mtx_init output argument | test.c:31:17:31:19 | *& ... | provenance | |
1024
| test.c:30:12:30:14 | mtx_init output argument | test.c:32:14:32:16 | *& ... | provenance | |
1125
| test.c:32:14:32:16 | *& ... | test.c:10:24:10:24 | *m | provenance | |
@@ -16,14 +30,20 @@ edges
1630
| test.c:44:14:44:18 | *& ... | test.c:10:24:10:24 | *m | provenance | |
1731
| test.c:44:15:44:16 | *l3 [m] | test.c:44:14:44:18 | *& ... | provenance | |
1832
nodes
33+
| test.c:3:7:3:8 | *g1 | semmle.label | *g1 |
34+
| test.c:4:7:4:8 | *g2 | semmle.label | *g2 |
35+
| test.c:10:24:10:24 | *m | semmle.label | *m |
36+
| test.c:10:24:10:24 | *m | semmle.label | *m |
1937
| test.c:10:24:10:24 | *m | semmle.label | *m |
2038
| test.c:10:43:10:43 | *m | semmle.label | *m |
2139
| test.c:13:12:13:14 | mtx_init output argument | semmle.label | mtx_init output argument |
2240
| test.c:14:17:14:19 | *& ... | semmle.label | *& ... |
2341
| test.c:15:14:15:16 | *& ... | semmle.label | *& ... |
42+
| test.c:15:14:15:16 | doTimeLock output argument | semmle.label | doTimeLock output argument |
2443
| test.c:17:12:17:14 | mtx_init output argument | semmle.label | mtx_init output argument |
2544
| test.c:18:17:18:19 | *& ... | semmle.label | *& ... |
2645
| test.c:19:14:19:16 | *& ... | semmle.label | *& ... |
46+
| test.c:19:14:19:16 | doTimeLock output argument | semmle.label | doTimeLock output argument |
2747
| test.c:30:12:30:14 | mtx_init output argument | semmle.label | mtx_init output argument |
2848
| test.c:31:17:31:19 | *& ... | semmle.label | *& ... |
2949
| test.c:32:14:32:16 | *& ... | semmle.label | *& ... |
@@ -34,6 +54,8 @@ nodes
3454
| test.c:44:14:44:18 | *& ... | semmle.label | *& ... |
3555
| test.c:44:15:44:16 | *l3 [m] | semmle.label | *l3 [m] |
3656
subpaths
57+
| test.c:15:14:15:16 | *& ... | test.c:10:24:10:24 | *m | test.c:10:24:10:24 | *m | test.c:15:14:15:16 | doTimeLock output argument |
58+
| test.c:19:14:19:16 | *& ... | test.c:10:24:10:24 | *m | test.c:10:24:10:24 | *m | test.c:19:14:19:16 | doTimeLock output argument |
3759
#select
3860
| test.c:10:43:10:43 | *m | test.c:13:12:13:14 | mtx_init output argument | test.c:10:43:10:43 | *m | Call to mtx_timedlock with mutex which is $@ without flag 'mtx_timed'. | test.c:13:12:13:14 | mtx_init output argument | initialized |
3961
| test.c:10:43:10:43 | *m | test.c:17:12:17:14 | mtx_init output argument | test.c:10:43:10:43 | *m | Call to mtx_timedlock with mutex which is $@ without flag 'mtx_timed'. | test.c:17:12:17:14 | mtx_init output argument | initialized |

0 commit comments

Comments
 (0)