Skip to content

Commit b0625f8

Browse files
committed
Rust: Add CFG test of range patterns
1 parent 272d12f commit b0625f8

File tree

2 files changed

+120
-86
lines changed

2 files changed

+120
-86
lines changed

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

Lines changed: 111 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -710,89 +710,114 @@ edges
710710
| test.rs:329:15:329:16 | st | test.rs:330:13:330:23 | RecordPat | |
711711
| test.rs:330:13:330:23 | RecordPat | test.rs:330:28:330:28 | 1 | match |
712712
| test.rs:330:28:330:28 | 1 | test.rs:329:9:331:9 | MatchExpr | |
713-
| test.rs:336:5:341:5 | enter test_infinite_loop | test.rs:337:9:339:9 | ExprStmt | |
714-
| test.rs:337:9:339:9 | ExprStmt | test.rs:338:13:338:13 | 1 | |
715-
| test.rs:337:14:339:9 | BlockExpr | test.rs:338:13:338:13 | 1 | |
716-
| test.rs:338:13:338:13 | 1 | test.rs:337:14:339:9 | BlockExpr | |
717-
| test.rs:344:1:349:1 | enter dead_code | test.rs:345:5:347:5 | ExprStmt | |
718-
| test.rs:344:1:349:1 | exit dead_code (normal) | test.rs:344:1:349:1 | exit dead_code | |
719-
| test.rs:345:5:347:5 | ExprStmt | test.rs:345:9:345:12 | true | |
720-
| test.rs:345:9:345:12 | true | test.rs:346:9:346:17 | ExprStmt | true |
721-
| test.rs:346:9:346:16 | ReturnExpr | test.rs:344:1:349:1 | exit dead_code (normal) | return |
722-
| test.rs:346:9:346:17 | ExprStmt | test.rs:346:16:346:16 | 0 | |
723-
| test.rs:346:16:346:16 | 0 | test.rs:346:9:346:16 | ReturnExpr | |
724-
| test.rs:351:1:364:1 | enter labelled_block1 | test.rs:352:5:363:6 | LetStmt | |
725-
| test.rs:351:1:364:1 | exit labelled_block1 (normal) | test.rs:351:1:364:1 | exit labelled_block1 | |
726-
| test.rs:351:29:364:1 | BlockExpr | test.rs:351:1:364:1 | exit labelled_block1 (normal) | |
727-
| test.rs:352:5:363:6 | LetStmt | test.rs:353:9:353:19 | ExprStmt | |
728-
| test.rs:352:9:352:14 | result | test.rs:351:29:364:1 | BlockExpr | match |
729-
| test.rs:352:18:363:5 | BlockExpr | test.rs:352:9:352:14 | result | |
730-
| test.rs:353:9:353:16 | PathExpr | test.rs:353:9:353:18 | CallExpr | |
731-
| test.rs:353:9:353:18 | CallExpr | test.rs:354:9:356:9 | ExprStmt | |
732-
| test.rs:353:9:353:19 | ExprStmt | test.rs:353:9:353:16 | PathExpr | |
733-
| test.rs:354:9:356:9 | ExprStmt | test.rs:354:12:354:28 | PathExpr | |
734-
| test.rs:354:9:356:9 | IfExpr | test.rs:357:9:357:24 | ExprStmt | |
735-
| test.rs:354:12:354:28 | PathExpr | test.rs:354:12:354:30 | CallExpr | |
736-
| test.rs:354:12:354:30 | CallExpr | test.rs:354:9:356:9 | IfExpr | false |
737-
| test.rs:354:12:354:30 | CallExpr | test.rs:355:13:355:27 | ExprStmt | true |
738-
| test.rs:355:13:355:26 | BreakExpr | test.rs:352:18:363:5 | BlockExpr | break |
739-
| test.rs:355:13:355:27 | ExprStmt | test.rs:355:26:355:26 | 1 | |
740-
| test.rs:355:26:355:26 | 1 | test.rs:355:13:355:26 | BreakExpr | |
741-
| test.rs:357:9:357:21 | PathExpr | test.rs:357:9:357:23 | CallExpr | |
742-
| test.rs:357:9:357:23 | CallExpr | test.rs:358:9:360:9 | ExprStmt | |
743-
| test.rs:357:9:357:24 | ExprStmt | test.rs:357:9:357:21 | PathExpr | |
744-
| test.rs:358:9:360:9 | ExprStmt | test.rs:358:12:358:28 | PathExpr | |
745-
| test.rs:358:9:360:9 | IfExpr | test.rs:361:9:361:24 | ExprStmt | |
746-
| test.rs:358:12:358:28 | PathExpr | test.rs:358:12:358:30 | CallExpr | |
747-
| test.rs:358:12:358:30 | CallExpr | test.rs:358:9:360:9 | IfExpr | false |
748-
| test.rs:358:12:358:30 | CallExpr | test.rs:359:13:359:27 | ExprStmt | true |
749-
| test.rs:359:13:359:26 | BreakExpr | test.rs:352:18:363:5 | BlockExpr | break |
750-
| test.rs:359:13:359:27 | ExprStmt | test.rs:359:26:359:26 | 2 | |
751-
| test.rs:359:26:359:26 | 2 | test.rs:359:13:359:26 | BreakExpr | |
752-
| test.rs:361:9:361:21 | PathExpr | test.rs:361:9:361:23 | CallExpr | |
753-
| test.rs:361:9:361:23 | CallExpr | test.rs:362:9:362:9 | 3 | |
754-
| test.rs:361:9:361:24 | ExprStmt | test.rs:361:9:361:21 | PathExpr | |
755-
| test.rs:362:9:362:9 | 3 | test.rs:352:18:363:5 | BlockExpr | |
756-
| test.rs:366:1:374:1 | enter labelled_block2 | test.rs:367:5:373:6 | LetStmt | |
757-
| test.rs:366:1:374:1 | exit labelled_block2 (normal) | test.rs:366:1:374:1 | exit labelled_block2 | |
758-
| test.rs:366:29:374:1 | BlockExpr | test.rs:366:1:374:1 | exit labelled_block2 (normal) | |
759-
| test.rs:367:5:373:6 | LetStmt | test.rs:368:9:368:34 | LetStmt | |
760-
| test.rs:367:9:367:14 | result | test.rs:366:29:374:1 | BlockExpr | match |
761-
| test.rs:367:18:373:5 | BlockExpr | test.rs:367:9:367:14 | result | |
762-
| test.rs:368:9:368:34 | LetStmt | test.rs:368:30:368:33 | PathExpr | |
763-
| test.rs:368:13:368:13 | x | test.rs:369:9:371:10 | LetStmt | match |
764-
| test.rs:368:30:368:33 | PathExpr | test.rs:368:13:368:13 | x | |
765-
| test.rs:369:9:371:10 | LetStmt | test.rs:369:23:369:23 | x | |
766-
| test.rs:369:13:369:19 | TupleStructPat | test.rs:369:18:369:18 | y | match |
767-
| test.rs:369:13:369:19 | TupleStructPat | test.rs:370:13:370:27 | ExprStmt | no-match |
768-
| test.rs:369:18:369:18 | y | test.rs:372:9:372:9 | x | match |
769-
| test.rs:369:23:369:23 | x | test.rs:369:13:369:19 | TupleStructPat | |
770-
| test.rs:370:13:370:26 | BreakExpr | test.rs:367:18:373:5 | BlockExpr | break |
771-
| test.rs:370:13:370:27 | ExprStmt | test.rs:370:26:370:26 | 1 | |
772-
| test.rs:370:26:370:26 | 1 | test.rs:370:13:370:26 | BreakExpr | |
773-
| test.rs:372:9:372:9 | x | test.rs:367:18:373:5 | BlockExpr | |
774-
| test.rs:376:1:382:1 | enter test_nested_function | test.rs:377:5:377:18 | LetStmt | |
775-
| test.rs:376:1:382:1 | exit test_nested_function (normal) | test.rs:376:1:382:1 | exit test_nested_function | |
776-
| test.rs:376:27:382:1 | BlockExpr | test.rs:376:1:382:1 | exit test_nested_function (normal) | |
777-
| test.rs:377:5:377:18 | LetStmt | test.rs:377:17:377:17 | 0 | |
778-
| test.rs:377:9:377:13 | x | test.rs:378:5:380:5 | nested | match |
779-
| test.rs:377:17:377:17 | 0 | test.rs:377:9:377:13 | x | |
780-
| test.rs:378:5:380:5 | enter nested | test.rs:378:15:378:15 | x | |
781-
| test.rs:378:5:380:5 | exit nested (normal) | test.rs:378:5:380:5 | exit nested | |
782-
| test.rs:378:5:380:5 | nested | test.rs:381:5:381:19 | ExprStmt | |
783-
| test.rs:378:15:378:15 | x | test.rs:378:15:378:25 | Param | match |
784-
| test.rs:378:15:378:25 | Param | test.rs:379:9:379:16 | ExprStmt | |
785-
| test.rs:378:28:380:5 | BlockExpr | test.rs:378:5:380:5 | exit nested (normal) | |
786-
| test.rs:379:9:379:10 | * ... | test.rs:379:15:379:15 | 1 | |
787-
| test.rs:379:9:379:15 | ... += ... | test.rs:378:28:380:5 | BlockExpr | |
788-
| test.rs:379:9:379:16 | ExprStmt | test.rs:379:10:379:10 | x | |
789-
| test.rs:379:10:379:10 | x | test.rs:379:9:379:10 | * ... | |
790-
| test.rs:379:15:379:15 | 1 | test.rs:379:9:379:15 | ... += ... | |
791-
| test.rs:381:5:381:10 | PathExpr | test.rs:381:17:381:17 | x | |
792-
| test.rs:381:5:381:18 | CallExpr | test.rs:376:27:382:1 | BlockExpr | |
793-
| test.rs:381:5:381:19 | ExprStmt | test.rs:381:5:381:10 | PathExpr | |
794-
| test.rs:381:12:381:17 | RefExpr | test.rs:381:5:381:18 | CallExpr | |
795-
| test.rs:381:17:381:17 | x | test.rs:381:12:381:17 | RefExpr | |
713+
| test.rs:334:5:341:5 | enter range_pattern | test.rs:335:15:335:16 | 42 | |
714+
| test.rs:334:5:341:5 | exit range_pattern (normal) | test.rs:334:5:341:5 | exit range_pattern | |
715+
| test.rs:334:31:341:5 | BlockExpr | test.rs:334:5:341:5 | exit range_pattern (normal) | |
716+
| test.rs:335:9:340:9 | MatchExpr | test.rs:334:31:341:5 | BlockExpr | |
717+
| test.rs:335:15:335:16 | 42 | test.rs:336:13:336:15 | RangePat | |
718+
| test.rs:336:13:336:15 | RangePat | test.rs:336:15:336:15 | LiteralPat | match |
719+
| test.rs:336:13:336:15 | RangePat | test.rs:336:20:336:20 | 1 | match |
720+
| test.rs:336:13:336:15 | RangePat | test.rs:337:13:337:16 | RangePat | no-match |
721+
| test.rs:336:15:336:15 | LiteralPat | test.rs:336:20:336:20 | 1 | match |
722+
| test.rs:336:15:336:15 | LiteralPat | test.rs:337:13:337:16 | RangePat | no-match |
723+
| test.rs:336:20:336:20 | 1 | test.rs:335:9:340:9 | MatchExpr | |
724+
| test.rs:337:13:337:13 | LiteralPat | test.rs:337:16:337:16 | LiteralPat | match |
725+
| test.rs:337:13:337:13 | LiteralPat | test.rs:338:13:338:15 | RangePat | no-match |
726+
| test.rs:337:13:337:16 | RangePat | test.rs:337:13:337:13 | LiteralPat | match |
727+
| test.rs:337:13:337:16 | RangePat | test.rs:338:13:338:15 | RangePat | no-match |
728+
| test.rs:337:16:337:16 | LiteralPat | test.rs:337:21:337:21 | 2 | match |
729+
| test.rs:337:16:337:16 | LiteralPat | test.rs:338:13:338:15 | RangePat | no-match |
730+
| test.rs:337:21:337:21 | 2 | test.rs:335:9:340:9 | MatchExpr | |
731+
| test.rs:338:13:338:13 | LiteralPat | test.rs:338:20:338:20 | 3 | match |
732+
| test.rs:338:13:338:13 | LiteralPat | test.rs:339:13:339:14 | RestPat | no-match |
733+
| test.rs:338:13:338:15 | RangePat | test.rs:338:13:338:13 | LiteralPat | match |
734+
| test.rs:338:13:338:15 | RangePat | test.rs:339:13:339:14 | RestPat | no-match |
735+
| test.rs:338:20:338:20 | 3 | test.rs:335:9:340:9 | MatchExpr | |
736+
| test.rs:339:13:339:14 | RestPat | test.rs:339:19:339:19 | 4 | match |
737+
| test.rs:339:19:339:19 | 4 | test.rs:335:9:340:9 | MatchExpr | |
738+
| test.rs:345:5:350:5 | enter test_infinite_loop | test.rs:346:9:348:9 | ExprStmt | |
739+
| test.rs:346:9:348:9 | ExprStmt | test.rs:347:13:347:13 | 1 | |
740+
| test.rs:346:14:348:9 | BlockExpr | test.rs:347:13:347:13 | 1 | |
741+
| test.rs:347:13:347:13 | 1 | test.rs:346:14:348:9 | BlockExpr | |
742+
| test.rs:353:1:358:1 | enter dead_code | test.rs:354:5:356:5 | ExprStmt | |
743+
| test.rs:353:1:358:1 | exit dead_code (normal) | test.rs:353:1:358:1 | exit dead_code | |
744+
| test.rs:354:5:356:5 | ExprStmt | test.rs:354:9:354:12 | true | |
745+
| test.rs:354:9:354:12 | true | test.rs:355:9:355:17 | ExprStmt | true |
746+
| test.rs:355:9:355:16 | ReturnExpr | test.rs:353:1:358:1 | exit dead_code (normal) | return |
747+
| test.rs:355:9:355:17 | ExprStmt | test.rs:355:16:355:16 | 0 | |
748+
| test.rs:355:16:355:16 | 0 | test.rs:355:9:355:16 | ReturnExpr | |
749+
| test.rs:360:1:373:1 | enter labelled_block1 | test.rs:361:5:372:6 | LetStmt | |
750+
| test.rs:360:1:373:1 | exit labelled_block1 (normal) | test.rs:360:1:373:1 | exit labelled_block1 | |
751+
| test.rs:360:29:373:1 | BlockExpr | test.rs:360:1:373:1 | exit labelled_block1 (normal) | |
752+
| test.rs:361:5:372:6 | LetStmt | test.rs:362:9:362:19 | ExprStmt | |
753+
| test.rs:361:9:361:14 | result | test.rs:360:29:373:1 | BlockExpr | match |
754+
| test.rs:361:18:372:5 | BlockExpr | test.rs:361:9:361:14 | result | |
755+
| test.rs:362:9:362:16 | PathExpr | test.rs:362:9:362:18 | CallExpr | |
756+
| test.rs:362:9:362:18 | CallExpr | test.rs:363:9:365:9 | ExprStmt | |
757+
| test.rs:362:9:362:19 | ExprStmt | test.rs:362:9:362:16 | PathExpr | |
758+
| test.rs:363:9:365:9 | ExprStmt | test.rs:363:12:363:28 | PathExpr | |
759+
| test.rs:363:9:365:9 | IfExpr | test.rs:366:9:366:24 | ExprStmt | |
760+
| test.rs:363:12:363:28 | PathExpr | test.rs:363:12:363:30 | CallExpr | |
761+
| test.rs:363:12:363:30 | CallExpr | test.rs:363:9:365:9 | IfExpr | false |
762+
| test.rs:363:12:363:30 | CallExpr | test.rs:364:13:364:27 | ExprStmt | true |
763+
| test.rs:364:13:364:26 | BreakExpr | test.rs:361:18:372:5 | BlockExpr | break |
764+
| test.rs:364:13:364:27 | ExprStmt | test.rs:364:26:364:26 | 1 | |
765+
| test.rs:364:26:364:26 | 1 | test.rs:364:13:364:26 | BreakExpr | |
766+
| test.rs:366:9:366:21 | PathExpr | test.rs:366:9:366:23 | CallExpr | |
767+
| test.rs:366:9:366:23 | CallExpr | test.rs:367:9:369:9 | ExprStmt | |
768+
| test.rs:366:9:366:24 | ExprStmt | test.rs:366:9:366:21 | PathExpr | |
769+
| test.rs:367:9:369:9 | ExprStmt | test.rs:367:12:367:28 | PathExpr | |
770+
| test.rs:367:9:369:9 | IfExpr | test.rs:370:9:370:24 | ExprStmt | |
771+
| test.rs:367:12:367:28 | PathExpr | test.rs:367:12:367:30 | CallExpr | |
772+
| test.rs:367:12:367:30 | CallExpr | test.rs:367:9:369:9 | IfExpr | false |
773+
| test.rs:367:12:367:30 | CallExpr | test.rs:368:13:368:27 | ExprStmt | true |
774+
| test.rs:368:13:368:26 | BreakExpr | test.rs:361:18:372:5 | BlockExpr | break |
775+
| test.rs:368:13:368:27 | ExprStmt | test.rs:368:26:368:26 | 2 | |
776+
| test.rs:368:26:368:26 | 2 | test.rs:368:13:368:26 | BreakExpr | |
777+
| test.rs:370:9:370:21 | PathExpr | test.rs:370:9:370:23 | CallExpr | |
778+
| test.rs:370:9:370:23 | CallExpr | test.rs:371:9:371:9 | 3 | |
779+
| test.rs:370:9:370:24 | ExprStmt | test.rs:370:9:370:21 | PathExpr | |
780+
| test.rs:371:9:371:9 | 3 | test.rs:361:18:372:5 | BlockExpr | |
781+
| test.rs:375:1:383:1 | enter labelled_block2 | test.rs:376:5:382:6 | LetStmt | |
782+
| test.rs:375:1:383:1 | exit labelled_block2 (normal) | test.rs:375:1:383:1 | exit labelled_block2 | |
783+
| test.rs:375:29:383:1 | BlockExpr | test.rs:375:1:383:1 | exit labelled_block2 (normal) | |
784+
| test.rs:376:5:382:6 | LetStmt | test.rs:377:9:377:34 | LetStmt | |
785+
| test.rs:376:9:376:14 | result | test.rs:375:29:383:1 | BlockExpr | match |
786+
| test.rs:376:18:382:5 | BlockExpr | test.rs:376:9:376:14 | result | |
787+
| test.rs:377:9:377:34 | LetStmt | test.rs:377:30:377:33 | PathExpr | |
788+
| test.rs:377:13:377:13 | x | test.rs:378:9:380:10 | LetStmt | match |
789+
| test.rs:377:30:377:33 | PathExpr | test.rs:377:13:377:13 | x | |
790+
| test.rs:378:9:380:10 | LetStmt | test.rs:378:23:378:23 | x | |
791+
| test.rs:378:13:378:19 | TupleStructPat | test.rs:378:18:378:18 | y | match |
792+
| test.rs:378:13:378:19 | TupleStructPat | test.rs:379:13:379:27 | ExprStmt | no-match |
793+
| test.rs:378:18:378:18 | y | test.rs:381:9:381:9 | x | match |
794+
| test.rs:378:23:378:23 | x | test.rs:378:13:378:19 | TupleStructPat | |
795+
| test.rs:379:13:379:26 | BreakExpr | test.rs:376:18:382:5 | BlockExpr | break |
796+
| test.rs:379:13:379:27 | ExprStmt | test.rs:379:26:379:26 | 1 | |
797+
| test.rs:379:26:379:26 | 1 | test.rs:379:13:379:26 | BreakExpr | |
798+
| test.rs:381:9:381:9 | x | test.rs:376:18:382:5 | BlockExpr | |
799+
| test.rs:385:1:391:1 | enter test_nested_function | test.rs:386:5:386:18 | LetStmt | |
800+
| test.rs:385:1:391:1 | exit test_nested_function (normal) | test.rs:385:1:391:1 | exit test_nested_function | |
801+
| test.rs:385:27:391:1 | BlockExpr | test.rs:385:1:391:1 | exit test_nested_function (normal) | |
802+
| test.rs:386:5:386:18 | LetStmt | test.rs:386:17:386:17 | 0 | |
803+
| test.rs:386:9:386:13 | x | test.rs:387:5:389:5 | nested | match |
804+
| test.rs:386:17:386:17 | 0 | test.rs:386:9:386:13 | x | |
805+
| test.rs:387:5:389:5 | enter nested | test.rs:387:15:387:15 | x | |
806+
| test.rs:387:5:389:5 | exit nested (normal) | test.rs:387:5:389:5 | exit nested | |
807+
| test.rs:387:5:389:5 | nested | test.rs:390:5:390:19 | ExprStmt | |
808+
| test.rs:387:15:387:15 | x | test.rs:387:15:387:25 | Param | match |
809+
| test.rs:387:15:387:25 | Param | test.rs:388:9:388:16 | ExprStmt | |
810+
| test.rs:387:28:389:5 | BlockExpr | test.rs:387:5:389:5 | exit nested (normal) | |
811+
| test.rs:388:9:388:10 | * ... | test.rs:388:15:388:15 | 1 | |
812+
| test.rs:388:9:388:15 | ... += ... | test.rs:387:28:389:5 | BlockExpr | |
813+
| test.rs:388:9:388:16 | ExprStmt | test.rs:388:10:388:10 | x | |
814+
| test.rs:388:10:388:10 | x | test.rs:388:9:388:10 | * ... | |
815+
| test.rs:388:15:388:15 | 1 | test.rs:388:9:388:15 | ... += ... | |
816+
| test.rs:390:5:390:10 | PathExpr | test.rs:390:17:390:17 | x | |
817+
| test.rs:390:5:390:18 | CallExpr | test.rs:385:27:391:1 | BlockExpr | |
818+
| test.rs:390:5:390:19 | ExprStmt | test.rs:390:5:390:10 | PathExpr | |
819+
| test.rs:390:12:390:17 | RefExpr | test.rs:390:5:390:18 | CallExpr | |
820+
| test.rs:390:17:390:17 | x | test.rs:390:12:390:17 | RefExpr | |
796821
breakTarget
797822
| test.rs:25:17:25:21 | BreakExpr | test.rs:19:9:31:9 | LoopExpr |
798823
| test.rs:39:21:39:25 | BreakExpr | test.rs:37:13:44:13 | LoopExpr |
@@ -804,9 +829,9 @@ breakTarget
804829
| test.rs:179:17:179:28 | BreakExpr | test.rs:177:13:182:9 | LoopExpr |
805830
| test.rs:192:17:192:35 | BreakExpr | test.rs:190:13:195:9 | LoopExpr |
806831
| test.rs:204:13:204:30 | BreakExpr | test.rs:203:13:205:9 | BlockExpr |
807-
| test.rs:355:13:355:26 | BreakExpr | test.rs:352:18:363:5 | BlockExpr |
808-
| test.rs:359:13:359:26 | BreakExpr | test.rs:352:18:363:5 | BlockExpr |
809-
| test.rs:370:13:370:26 | BreakExpr | test.rs:367:18:373:5 | BlockExpr |
832+
| test.rs:364:13:364:26 | BreakExpr | test.rs:361:18:372:5 | BlockExpr |
833+
| test.rs:368:13:368:26 | BreakExpr | test.rs:361:18:372:5 | BlockExpr |
834+
| test.rs:379:13:379:26 | BreakExpr | test.rs:376:18:382:5 | BlockExpr |
810835
continueTarget
811836
| test.rs:28:17:28:24 | ContinueExpr | test.rs:19:9:31:9 | LoopExpr |
812837
| test.rs:54:21:54:28 | ContinueExpr | test.rs:52:13:59:13 | LoopExpr |

rust/ql/test/library-tests/controlflow/test.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,15 @@ mod patterns {
330330
MyStruct {} => 1,
331331
}
332332
}
333+
334+
fn range_pattern() -> i64 {
335+
match 42 {
336+
..0 => 1,
337+
1..2 => 2,
338+
5.. => 3,
339+
.. => 4,
340+
}
341+
}
333342
}
334343

335344
mod divergence {

0 commit comments

Comments
 (0)