Skip to content

Commit 7bc53c7

Browse files
hvitvedCopilot
andcommitted
Fix async block CFG value propagation
Avoid propagating a tail expression directly to an async block expression across callable boundaries. The shared block handling already propagates block-tail values within the correct callable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ed9bb74 commit 7bc53c7

3 files changed

Lines changed: 2 additions & 28 deletions

File tree

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,8 +614,6 @@ private module Input implements InputSig1, InputSig2 {
614614
class CallableContext = Void;
615615

616616
predicate propagatesValue(Ast::AstNode child, Ast::AstNode parent) {
617-
child = parent.(Rust::BlockExpr).getStmtList().getTailExpr()
618-
or
619617
child = parent.(Rust::MatchExpr).getAnArm().getExpr()
620618
}
621619

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

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -719,18 +719,11 @@ dominates
719719
| test.rs:502:31:504:9 | Entry | test.rs:502:31:504:9 | Entry |
720720
| test.rs:505:20:505:27 | Entry | test.rs:505:20:505:27 | Entry |
721721
| test.rs:511:22:516:9 | Entry | test.rs:511:22:516:9 | Entry |
722-
| test.rs:511:22:516:9 | Entry | test.rs:511:28:516:9 | { ... } |
723722
| test.rs:511:28:516:9 | Entry | test.rs:511:28:516:9 | Entry |
724723
| test.rs:511:28:516:9 | Entry | test.rs:511:28:516:9 | Normal Exit |
725-
| test.rs:511:28:516:9 | Entry | test.rs:511:28:516:9 | { ... } |
726-
| test.rs:511:28:516:9 | Entry | test.rs:511:34:516:9 | After StmtList |
727724
| test.rs:511:28:516:9 | Entry | test.rs:512:16:512:16 | After b [false] |
728725
| test.rs:511:28:516:9 | Entry | test.rs:512:16:512:16 | After b [true] |
729726
| test.rs:511:28:516:9 | Normal Exit | test.rs:511:28:516:9 | Normal Exit |
730-
| test.rs:511:28:516:9 | { ... } | test.rs:511:28:516:9 | { ... } |
731-
| test.rs:511:34:516:9 | After StmtList | test.rs:511:34:516:9 | After StmtList |
732-
| test.rs:512:16:512:16 | After b [false] | test.rs:511:28:516:9 | { ... } |
733-
| test.rs:512:16:512:16 | After b [false] | test.rs:511:34:516:9 | After StmtList |
734727
| test.rs:512:16:512:16 | After b [false] | test.rs:512:16:512:16 | After b [false] |
735728
| test.rs:512:16:512:16 | After b [true] | test.rs:512:16:512:16 | After b [true] |
736729
| test.rs:523:5:525:5 | Entry | test.rs:523:5:525:5 | Entry |
@@ -1411,17 +1404,8 @@ postDominance
14111404
| test.rs:511:28:516:9 | Entry | test.rs:511:28:516:9 | Entry |
14121405
| test.rs:511:28:516:9 | Normal Exit | test.rs:511:28:516:9 | Entry |
14131406
| test.rs:511:28:516:9 | Normal Exit | test.rs:511:28:516:9 | Normal Exit |
1414-
| test.rs:511:28:516:9 | Normal Exit | test.rs:511:34:516:9 | After StmtList |
14151407
| test.rs:511:28:516:9 | Normal Exit | test.rs:512:16:512:16 | After b [false] |
14161408
| test.rs:511:28:516:9 | Normal Exit | test.rs:512:16:512:16 | After b [true] |
1417-
| test.rs:511:28:516:9 | { ... } | test.rs:511:22:516:9 | Entry |
1418-
| test.rs:511:28:516:9 | { ... } | test.rs:511:28:516:9 | Entry |
1419-
| test.rs:511:28:516:9 | { ... } | test.rs:511:28:516:9 | { ... } |
1420-
| test.rs:511:28:516:9 | { ... } | test.rs:512:16:512:16 | After b [false] |
1421-
| test.rs:511:34:516:9 | After StmtList | test.rs:511:28:516:9 | Entry |
1422-
| test.rs:511:34:516:9 | After StmtList | test.rs:511:34:516:9 | After StmtList |
1423-
| test.rs:511:34:516:9 | After StmtList | test.rs:512:16:512:16 | After b [false] |
1424-
| test.rs:512:16:512:16 | After b [false] | test.rs:511:28:516:9 | Entry |
14251409
| test.rs:512:16:512:16 | After b [false] | test.rs:512:16:512:16 | After b [false] |
14261410
| test.rs:512:16:512:16 | After b [true] | test.rs:512:16:512:16 | After b [true] |
14271411
| test.rs:523:5:525:5 | Entry | test.rs:523:5:525:5 | Entry |
@@ -1715,9 +1699,6 @@ immediateDominator
17151699
| test.rs:478:13:478:27 | [pattern-start] TupleVariant(...) | test.rs:477:13:477:34 | After StructVariant {...} [no-match] |
17161700
| test.rs:486:14:488:9 | { ... } | test.rs:485:5:490:5 | Entry |
17171701
| test.rs:511:28:516:9 | Normal Exit | test.rs:511:28:516:9 | Entry |
1718-
| test.rs:511:28:516:9 | { ... } | test.rs:511:22:516:9 | Entry |
1719-
| test.rs:511:28:516:9 | { ... } | test.rs:512:16:512:16 | After b [false] |
1720-
| test.rs:511:34:516:9 | After StmtList | test.rs:512:16:512:16 | After b [false] |
17211702
| test.rs:512:16:512:16 | After b [false] | test.rs:511:28:516:9 | Entry |
17221703
| test.rs:512:16:512:16 | After b [true] | test.rs:511:28:516:9 | Entry |
17231704
| test.rs:533:21:533:48 | After ... > ... [false] | test.rs:529:5:537:5 | Entry |
@@ -1989,8 +1970,6 @@ controls
19891970
| test.rs:475:5:481:5 | Entry | test.rs:478:13:478:27 | [pattern-start] TupleVariant(...) | no-match |
19901971
| test.rs:477:13:477:34 | After StructVariant {...} [no-match] | test.rs:478:13:478:27 | After TupleVariant(...) [no-match] | no-match |
19911972
| test.rs:477:13:477:34 | After StructVariant {...} [no-match] | test.rs:478:13:478:27 | [pattern-start] TupleVariant(...) | match |
1992-
| test.rs:511:28:516:9 | Entry | test.rs:511:28:516:9 | { ... } | false |
1993-
| test.rs:511:28:516:9 | Entry | test.rs:511:34:516:9 | After StmtList | false |
19941973
| test.rs:511:28:516:9 | Entry | test.rs:512:16:512:16 | After b [false] | false |
19951974
| test.rs:511:28:516:9 | Entry | test.rs:512:16:512:16 | After b [true] | true |
19961975
| test.rs:529:5:537:5 | Entry | test.rs:533:21:533:48 | After ... > ... [false] | false |
@@ -2399,10 +2378,8 @@ joinBlockPredecessor
23992378
| test.rs:476:9:480:9 | After match e { ... } | test.rs:478:13:478:27 | [pattern-start] TupleVariant(...) | 1 |
24002379
| test.rs:486:14:488:9 | { ... } | test.rs:485:5:490:5 | Entry | 1 |
24012380
| test.rs:486:14:488:9 | { ... } | test.rs:486:14:488:9 | { ... } | 0 |
2402-
| test.rs:511:28:516:9 | Normal Exit | test.rs:511:34:516:9 | After StmtList | 1 |
2403-
| test.rs:511:28:516:9 | Normal Exit | test.rs:512:16:512:16 | After b [true] | 0 |
2404-
| test.rs:511:28:516:9 | { ... } | test.rs:511:22:516:9 | Entry | 1 |
2405-
| test.rs:511:28:516:9 | { ... } | test.rs:512:16:512:16 | After b [false] | 0 |
2381+
| test.rs:511:28:516:9 | Normal Exit | test.rs:512:16:512:16 | After b [false] | 0 |
2382+
| test.rs:511:28:516:9 | Normal Exit | test.rs:512:16:512:16 | After b [true] | 1 |
24062383
| test.rs:533:21:533:48 | After if ... {...} | test.rs:533:21:533:48 | After ... > ... [false] | 0 |
24072384
| test.rs:533:21:533:48 | After if ... {...} | test.rs:533:21:533:48 | After ... > ... [true] | 1 |
24082385
| test.rs:569:18:580:5 | After 'block: { ... } | test.rs:571:12:571:30 | After condition_not_met(...) [true] | 0 |

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2267,7 +2267,6 @@ edges
22672267
| test.rs:513:24:513:40 | Before async_block(...) | test.rs:513:24:513:34 | async_block | |
22682268
| test.rs:513:24:513:40 | async_block(...) | test.rs:513:24:513:40 | After async_block(...) | |
22692269
| test.rs:513:36:513:39 | true | test.rs:513:24:513:40 | async_block(...) | |
2270-
| test.rs:515:13:515:15 | foo | test.rs:511:28:516:9 | { ... } | |
22712270
| test.rs:515:13:515:15 | foo | test.rs:511:34:516:9 | After StmtList | |
22722271
| test.rs:523:5:525:5 | Entry | test.rs:523:22:523:22 | Before n | |
22732272
| test.rs:523:5:525:5 | Normal Exit | test.rs:523:5:525:5 | Exit | |

0 commit comments

Comments
 (0)