Skip to content

Commit ae0c547

Browse files
committed
Rust: fix CFG for MacroPat
1 parent 943dd8e commit ae0c547

File tree

4 files changed

+4
-32
lines changed

4 files changed

+4
-32
lines changed

rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ class LetStmtTree extends PreOrderTree, LetStmt {
143143
}
144144

145145
class MacroCallTree extends StandardPostOrderTree, MacroCall {
146+
MacroCallTree() { not this.getParentNode() instanceof MacroPat }
147+
146148
override AstNode getChildNode(int i) { i = 0 and result = this.getMacroCallExpansion() }
147149
}
148150

rust/ql/test/library-tests/controlflow/BasicBlocks.expected

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -675,20 +675,11 @@ dominates
675675
| test.rs:453:5:458:5 | enter fn or_pattern_3 | test.rs:455:13:455:25 | 2 |
676676
| test.rs:453:5:458:5 | enter fn or_pattern_3 | test.rs:455:13:455:25 | [match(false)] 1 \| 2 |
677677
| test.rs:453:5:458:5 | enter fn or_pattern_3 | test.rs:455:13:455:25 | [match(true)] 1 \| 2 |
678-
| test.rs:453:5:458:5 | enter fn or_pattern_3 | test.rs:455:13:455:25 | one_or_two!... |
679-
| test.rs:453:5:458:5 | enter fn or_pattern_3 | test.rs:455:30:455:30 | 3 |
680-
| test.rs:453:5:458:5 | enter fn or_pattern_3 | test.rs:456:13:456:13 | _ |
681678
| test.rs:454:9:457:9 | match a { ... } | test.rs:454:9:457:9 | match a { ... } |
682679
| test.rs:455:13:455:25 | 2 | test.rs:455:13:455:25 | 2 |
683680
| test.rs:455:13:455:25 | 2 | test.rs:455:13:455:25 | [match(false)] 1 \| 2 |
684-
| test.rs:455:13:455:25 | 2 | test.rs:456:13:456:13 | _ |
685681
| test.rs:455:13:455:25 | [match(false)] 1 \| 2 | test.rs:455:13:455:25 | [match(false)] 1 \| 2 |
686-
| test.rs:455:13:455:25 | [match(false)] 1 \| 2 | test.rs:456:13:456:13 | _ |
687682
| test.rs:455:13:455:25 | [match(true)] 1 \| 2 | test.rs:455:13:455:25 | [match(true)] 1 \| 2 |
688-
| test.rs:455:13:455:25 | [match(true)] 1 \| 2 | test.rs:455:30:455:30 | 3 |
689-
| test.rs:455:13:455:25 | one_or_two!... | test.rs:455:13:455:25 | one_or_two!... |
690-
| test.rs:455:30:455:30 | 3 | test.rs:455:30:455:30 | 3 |
691-
| test.rs:456:13:456:13 | _ | test.rs:456:13:456:13 | _ |
692683
| test.rs:460:5:465:5 | enter fn irrefutable_pattern_and_dead_code | test.rs:460:5:465:5 | enter fn irrefutable_pattern_and_dead_code |
693684
| test.rs:460:5:465:5 | enter fn irrefutable_pattern_and_dead_code | test.rs:461:9:464:9 | match pair { ... } |
694685
| test.rs:460:5:465:5 | enter fn irrefutable_pattern_and_dead_code | test.rs:462:32:462:32 | _ |
@@ -1356,16 +1347,9 @@ postDominance
13561347
| test.rs:454:9:457:9 | match a { ... } | test.rs:455:13:455:25 | 2 |
13571348
| test.rs:454:9:457:9 | match a { ... } | test.rs:455:13:455:25 | [match(false)] 1 \| 2 |
13581349
| test.rs:454:9:457:9 | match a { ... } | test.rs:455:13:455:25 | [match(true)] 1 \| 2 |
1359-
| test.rs:454:9:457:9 | match a { ... } | test.rs:455:30:455:30 | 3 |
1360-
| test.rs:454:9:457:9 | match a { ... } | test.rs:456:13:456:13 | _ |
13611350
| test.rs:455:13:455:25 | 2 | test.rs:455:13:455:25 | 2 |
13621351
| test.rs:455:13:455:25 | [match(false)] 1 \| 2 | test.rs:455:13:455:25 | [match(false)] 1 \| 2 |
13631352
| test.rs:455:13:455:25 | [match(true)] 1 \| 2 | test.rs:455:13:455:25 | [match(true)] 1 \| 2 |
1364-
| test.rs:455:13:455:25 | one_or_two!... | test.rs:455:13:455:25 | one_or_two!... |
1365-
| test.rs:455:30:455:30 | 3 | test.rs:455:13:455:25 | [match(true)] 1 \| 2 |
1366-
| test.rs:455:30:455:30 | 3 | test.rs:455:30:455:30 | 3 |
1367-
| test.rs:456:13:456:13 | _ | test.rs:455:13:455:25 | [match(false)] 1 \| 2 |
1368-
| test.rs:456:13:456:13 | _ | test.rs:456:13:456:13 | _ |
13691353
| test.rs:460:5:465:5 | enter fn irrefutable_pattern_and_dead_code | test.rs:460:5:465:5 | enter fn irrefutable_pattern_and_dead_code |
13701354
| test.rs:461:9:464:9 | match pair { ... } | test.rs:460:5:465:5 | enter fn irrefutable_pattern_and_dead_code |
13711355
| test.rs:461:9:464:9 | match pair { ... } | test.rs:461:9:464:9 | match pair { ... } |
@@ -1673,9 +1657,6 @@ immediateDominator
16731657
| test.rs:455:13:455:25 | 2 | test.rs:453:5:458:5 | enter fn or_pattern_3 |
16741658
| test.rs:455:13:455:25 | [match(false)] 1 \| 2 | test.rs:455:13:455:25 | 2 |
16751659
| test.rs:455:13:455:25 | [match(true)] 1 \| 2 | test.rs:453:5:458:5 | enter fn or_pattern_3 |
1676-
| test.rs:455:13:455:25 | one_or_two!... | test.rs:453:5:458:5 | enter fn or_pattern_3 |
1677-
| test.rs:455:30:455:30 | 3 | test.rs:455:13:455:25 | [match(true)] 1 \| 2 |
1678-
| test.rs:456:13:456:13 | _ | test.rs:455:13:455:25 | [match(false)] 1 \| 2 |
16791660
| test.rs:461:9:464:9 | match pair { ... } | test.rs:460:5:465:5 | enter fn irrefutable_pattern_and_dead_code |
16801661
| test.rs:462:32:462:32 | _ | test.rs:460:5:465:5 | enter fn irrefutable_pattern_and_dead_code |
16811662
| test.rs:463:13:463:13 | _ | test.rs:460:5:465:5 | enter fn irrefutable_pattern_and_dead_code |
@@ -2204,12 +2185,10 @@ joinBlockPredecessor
22042185
| test.rs:443:13:443:36 | ... \| ... | test.rs:443:26:443:36 | Some(...) | 1 |
22052186
| test.rs:443:26:443:36 | Some(...) | test.rs:443:13:443:22 | Some(...) | 1 |
22062187
| test.rs:443:26:443:36 | Some(...) | test.rs:443:18:443:21 | true | 0 |
2207-
| test.rs:454:9:457:9 | match a { ... } | test.rs:455:30:455:30 | 3 | 0 |
2208-
| test.rs:454:9:457:9 | match a { ... } | test.rs:456:13:456:13 | _ | 1 |
2188+
| test.rs:454:9:457:9 | match a { ... } | test.rs:455:13:455:25 | [match(false)] 1 \| 2 | 0 |
2189+
| test.rs:454:9:457:9 | match a { ... } | test.rs:455:13:455:25 | [match(true)] 1 \| 2 | 1 |
22092190
| test.rs:455:13:455:25 | [match(true)] 1 \| 2 | test.rs:453:5:458:5 | enter fn or_pattern_3 | 1 |
22102191
| test.rs:455:13:455:25 | [match(true)] 1 \| 2 | test.rs:455:13:455:25 | 2 | 0 |
2211-
| test.rs:455:13:455:25 | one_or_two!... | test.rs:455:13:455:25 | [match(false)] 1 \| 2 | 0 |
2212-
| test.rs:455:13:455:25 | one_or_two!... | test.rs:455:13:455:25 | [match(true)] 1 \| 2 | 1 |
22132192
| test.rs:461:9:464:9 | match pair { ... } | test.rs:462:32:462:32 | _ | 0 |
22142193
| test.rs:461:9:464:9 | match pair { ... } | test.rs:463:13:463:13 | _ | 1 |
22152194
| test.rs:476:9:480:9 | match e { ... } | test.rs:477:32:477:32 | _ | 0 |

rust/ql/test/library-tests/controlflow/CONSISTENCY/CfgConsistency.expected

Lines changed: 0 additions & 7 deletions
This file was deleted.

rust/ql/test/library-tests/controlflow/Cfg.expected

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,9 +1129,7 @@ edges
11291129
| test.rs:455:13:455:25 | 2 | test.rs:455:13:455:25 | [match(false)] 1 \| 2 | no-match |
11301130
| test.rs:455:13:455:25 | 2 | test.rs:455:13:455:25 | [match(true)] 1 \| 2 | match |
11311131
| test.rs:455:13:455:25 | MacroPat | test.rs:455:13:455:25 | 1 | match |
1132-
| test.rs:455:13:455:25 | [match(false)] 1 \| 2 | test.rs:455:13:455:25 | one_or_two!... | no-match |
11331132
| test.rs:455:13:455:25 | [match(false)] 1 \| 2 | test.rs:456:13:456:13 | _ | no-match |
1134-
| test.rs:455:13:455:25 | [match(true)] 1 \| 2 | test.rs:455:13:455:25 | one_or_two!... | match |
11351133
| test.rs:455:13:455:25 | [match(true)] 1 \| 2 | test.rs:455:30:455:30 | 3 | match |
11361134
| test.rs:455:30:455:30 | 3 | test.rs:454:9:457:9 | match a { ... } | |
11371135
| test.rs:456:13:456:13 | _ | test.rs:456:18:456:18 | 4 | match |

0 commit comments

Comments
 (0)