Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bd59029

Browse files
committed
C++: Add pointer-to-member test to syntax-zoo
This test was inspired by problems observed in a MySQL snapshot. The results show there are problems with both the QL CFG and the IR.
1 parent df1bf4a commit bd59029

6 files changed

Lines changed: 92 additions & 53 deletions

File tree

cpp/ql/test/library-tests/syntax-zoo/aliased_ssa_sanity.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ instructionWithoutSuccessor
2020
| ms_try_mix.cpp:11:12:11:15 | Chi: call to C |
2121
| ms_try_mix.cpp:28:12:28:15 | Chi: call to C |
2222
| ms_try_mix.cpp:48:10:48:13 | Chi: call to C |
23+
| pointer_to_member.cpp:35:11:35:21 | FieldAddress: {...} |
2324
| stmt_expr.cpp:27:5:27:15 | Store: ... = ... |
2425
| vla.c:5:9:5:14 | Uninitialized: definition of matrix |
2526
| vla.c:11:6:11:16 | UnmodeledDefinition: vla_typedef |
Lines changed: 76 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,76 @@
1-
| staticlocals__staticlocals_f2_extractor | false | 31268 | 31268 | f2 |
2-
| staticlocals__staticlocals_f2_extractor | false | 31274 | 31274 | declaration |
3-
| staticlocals__staticlocals_f2_extractor | false | 31277 | 31277 | declaration |
4-
| staticlocals__staticlocals_f2_extractor | false | 31280 | 31280 | declaration |
5-
| staticlocals__staticlocals_f2_extractor | false | 31283 | 31283 | declaration |
6-
| staticlocals__staticlocals_f2_extractor | false | 31286 | 31286 | return ... |
7-
| staticlocals__staticlocals_f2_extractor | false | 31289 | 31289 | { ... } |
8-
| staticlocals__staticlocals_f2_extractor | false | 31292 | 31292 | call to C |
9-
| staticlocals__staticlocals_f2_extractor | false | 31295 | 31295 | initializer for c |
10-
| staticlocals__staticlocals_f2_extractor | false | 31298 | 31298 | call to addOne |
11-
| staticlocals__staticlocals_f2_extractor | false | 31304 | 31304 | 2 |
12-
| staticlocals__staticlocals_f2_extractor | false | 31309 | 31309 | initializer for j |
13-
| staticlocals__staticlocals_f2_extractor | false | 31311 | 31311 | call to addOne |
14-
| staticlocals__staticlocals_f2_extractor | false | 31319 | 31319 | 2 |
15-
| staticlocals__staticlocals_f2_extractor | false | 31321 | 31321 | initializer for two |
16-
| staticlocals__staticlocals_f2_extractor | false | 31325 | 31325 | two |
17-
| staticlocals__staticlocals_f2_extractor | false | 31333 | 31333 | initializer for i |
18-
| staticlocals__staticlocals_f2_extractor | true | 31274 | 31321 | |
19-
| staticlocals__staticlocals_f2_extractor | true | 31277 | 31280 | |
20-
| staticlocals__staticlocals_f2_extractor | true | 31280 | 31283 | |
21-
| staticlocals__staticlocals_f2_extractor | true | 31283 | 31286 | |
22-
| staticlocals__staticlocals_f2_extractor | true | 31286 | 31268 | |
23-
| staticlocals__staticlocals_f2_extractor | true | 31289 | 31274 | |
24-
| staticlocals__staticlocals_f2_extractor | true | 31319 | 31277 | |
25-
| staticlocals__staticlocals_f2_extractor | true | 31321 | 31319 | |
26-
| staticlocals__staticlocals_f2_ql | false | 31268 | 31268 | f2 |
27-
| staticlocals__staticlocals_f2_ql | false | 31274 | 31274 | declaration |
28-
| staticlocals__staticlocals_f2_ql | false | 31277 | 31277 | declaration |
29-
| staticlocals__staticlocals_f2_ql | false | 31280 | 31280 | declaration |
30-
| staticlocals__staticlocals_f2_ql | false | 31283 | 31283 | declaration |
31-
| staticlocals__staticlocals_f2_ql | false | 31286 | 31286 | return ... |
32-
| staticlocals__staticlocals_f2_ql | false | 31289 | 31289 | { ... } |
33-
| staticlocals__staticlocals_f2_ql | false | 31292 | 31292 | call to C |
34-
| staticlocals__staticlocals_f2_ql | false | 31295 | 31295 | initializer for c |
35-
| staticlocals__staticlocals_f2_ql | false | 31298 | 31298 | call to addOne |
36-
| staticlocals__staticlocals_f2_ql | false | 31304 | 31304 | 2 |
37-
| staticlocals__staticlocals_f2_ql | false | 31309 | 31309 | initializer for j |
38-
| staticlocals__staticlocals_f2_ql | false | 31311 | 31311 | call to addOne |
39-
| staticlocals__staticlocals_f2_ql | false | 31319 | 31319 | 2 |
40-
| staticlocals__staticlocals_f2_ql | false | 31321 | 31321 | initializer for two |
41-
| staticlocals__staticlocals_f2_ql | false | 31325 | 31325 | two |
42-
| staticlocals__staticlocals_f2_ql | false | 31333 | 31333 | initializer for i |
43-
| staticlocals__staticlocals_f2_ql | true | 31274 | 31321 | |
44-
| staticlocals__staticlocals_f2_ql | true | 31277 | 31280 | |
45-
| staticlocals__staticlocals_f2_ql | true | 31280 | 31283 | |
46-
| staticlocals__staticlocals_f2_ql | true | 31283 | 31286 | |
47-
| staticlocals__staticlocals_f2_ql | true | 31283 | 31295 | |
48-
| staticlocals__staticlocals_f2_ql | true | 31286 | 31268 | |
49-
| staticlocals__staticlocals_f2_ql | true | 31289 | 31274 | |
50-
| staticlocals__staticlocals_f2_ql | true | 31292 | 31286 | |
51-
| staticlocals__staticlocals_f2_ql | true | 31295 | 31292 | |
52-
| staticlocals__staticlocals_f2_ql | true | 31319 | 31277 | |
53-
| staticlocals__staticlocals_f2_ql | true | 31321 | 31319 | |
1+
| pointer_to_member__pmIsConst_extractor | false | 15698 | 15698 | pmIsConst |
2+
| pointer_to_member__pmIsConst_extractor | false | 15724 | 15724 | declaration |
3+
| pointer_to_member__pmIsConst_extractor | false | 15726 | 15726 | return ... |
4+
| pointer_to_member__pmIsConst_extractor | false | 15728 | 15728 | { ... } |
5+
| pointer_to_member__pmIsConst_extractor | false | 15731 | 15731 | {...} |
6+
| pointer_to_member__pmIsConst_extractor | false | 15734 | 15734 | x1 |
7+
| pointer_to_member__pmIsConst_extractor | false | 15735 | 15735 | initializer for pms |
8+
| pointer_to_member__pmIsConst_extractor | true | 15724 | 15726 | |
9+
| pointer_to_member__pmIsConst_extractor | true | 15726 | 15698 | |
10+
| pointer_to_member__pmIsConst_extractor | true | 15728 | 15724 | |
11+
| pointer_to_member__pmIsConst_ql | false | 15698 | 15698 | pmIsConst |
12+
| pointer_to_member__pmIsConst_ql | false | 15724 | 15724 | declaration |
13+
| pointer_to_member__pmIsConst_ql | false | 15726 | 15726 | return ... |
14+
| pointer_to_member__pmIsConst_ql | false | 15728 | 15728 | { ... } |
15+
| pointer_to_member__pmIsConst_ql | false | 15731 | 15731 | {...} |
16+
| pointer_to_member__pmIsConst_ql | false | 15734 | 15734 | x1 |
17+
| pointer_to_member__pmIsConst_ql | false | 15735 | 15735 | initializer for pms |
18+
| pointer_to_member__pmIsConst_ql | true | 15724 | 15735 | |
19+
| pointer_to_member__pmIsConst_ql | true | 15726 | 15698 | |
20+
| pointer_to_member__pmIsConst_ql | true | 15728 | 15724 | |
21+
| pointer_to_member__pmIsConst_ql | true | 15731 | 15726 | |
22+
| pointer_to_member__pmIsConst_ql | true | 15734 | 15731 | |
23+
| pointer_to_member__pmIsConst_ql | true | 15735 | 15734 | |
24+
| staticlocals__staticlocals_f2_extractor | false | 22465 | 22465 | f2 |
25+
| staticlocals__staticlocals_f2_extractor | false | 22470 | 22470 | declaration |
26+
| staticlocals__staticlocals_f2_extractor | false | 22472 | 22472 | declaration |
27+
| staticlocals__staticlocals_f2_extractor | false | 22474 | 22474 | declaration |
28+
| staticlocals__staticlocals_f2_extractor | false | 22476 | 22476 | declaration |
29+
| staticlocals__staticlocals_f2_extractor | false | 22478 | 22478 | return ... |
30+
| staticlocals__staticlocals_f2_extractor | false | 22480 | 22480 | { ... } |
31+
| staticlocals__staticlocals_f2_extractor | false | 22482 | 22482 | call to C |
32+
| staticlocals__staticlocals_f2_extractor | false | 22484 | 22484 | initializer for c |
33+
| staticlocals__staticlocals_f2_extractor | false | 22486 | 22486 | call to addOne |
34+
| staticlocals__staticlocals_f2_extractor | false | 22490 | 22490 | 2 |
35+
| staticlocals__staticlocals_f2_extractor | false | 22493 | 22493 | initializer for j |
36+
| staticlocals__staticlocals_f2_extractor | false | 22494 | 22494 | call to addOne |
37+
| staticlocals__staticlocals_f2_extractor | false | 22499 | 22499 | 2 |
38+
| staticlocals__staticlocals_f2_extractor | false | 22500 | 22500 | initializer for two |
39+
| staticlocals__staticlocals_f2_extractor | false | 22503 | 22503 | two |
40+
| staticlocals__staticlocals_f2_extractor | false | 22508 | 22508 | initializer for i |
41+
| staticlocals__staticlocals_f2_extractor | true | 22470 | 22500 | |
42+
| staticlocals__staticlocals_f2_extractor | true | 22472 | 22474 | |
43+
| staticlocals__staticlocals_f2_extractor | true | 22474 | 22476 | |
44+
| staticlocals__staticlocals_f2_extractor | true | 22476 | 22478 | |
45+
| staticlocals__staticlocals_f2_extractor | true | 22478 | 22465 | |
46+
| staticlocals__staticlocals_f2_extractor | true | 22480 | 22470 | |
47+
| staticlocals__staticlocals_f2_extractor | true | 22499 | 22472 | |
48+
| staticlocals__staticlocals_f2_extractor | true | 22500 | 22499 | |
49+
| staticlocals__staticlocals_f2_ql | false | 22465 | 22465 | f2 |
50+
| staticlocals__staticlocals_f2_ql | false | 22470 | 22470 | declaration |
51+
| staticlocals__staticlocals_f2_ql | false | 22472 | 22472 | declaration |
52+
| staticlocals__staticlocals_f2_ql | false | 22474 | 22474 | declaration |
53+
| staticlocals__staticlocals_f2_ql | false | 22476 | 22476 | declaration |
54+
| staticlocals__staticlocals_f2_ql | false | 22478 | 22478 | return ... |
55+
| staticlocals__staticlocals_f2_ql | false | 22480 | 22480 | { ... } |
56+
| staticlocals__staticlocals_f2_ql | false | 22482 | 22482 | call to C |
57+
| staticlocals__staticlocals_f2_ql | false | 22484 | 22484 | initializer for c |
58+
| staticlocals__staticlocals_f2_ql | false | 22486 | 22486 | call to addOne |
59+
| staticlocals__staticlocals_f2_ql | false | 22490 | 22490 | 2 |
60+
| staticlocals__staticlocals_f2_ql | false | 22493 | 22493 | initializer for j |
61+
| staticlocals__staticlocals_f2_ql | false | 22494 | 22494 | call to addOne |
62+
| staticlocals__staticlocals_f2_ql | false | 22499 | 22499 | 2 |
63+
| staticlocals__staticlocals_f2_ql | false | 22500 | 22500 | initializer for two |
64+
| staticlocals__staticlocals_f2_ql | false | 22503 | 22503 | two |
65+
| staticlocals__staticlocals_f2_ql | false | 22508 | 22508 | initializer for i |
66+
| staticlocals__staticlocals_f2_ql | true | 22470 | 22500 | |
67+
| staticlocals__staticlocals_f2_ql | true | 22472 | 22474 | |
68+
| staticlocals__staticlocals_f2_ql | true | 22474 | 22476 | |
69+
| staticlocals__staticlocals_f2_ql | true | 22476 | 22478 | |
70+
| staticlocals__staticlocals_f2_ql | true | 22476 | 22484 | |
71+
| staticlocals__staticlocals_f2_ql | true | 22478 | 22465 | |
72+
| staticlocals__staticlocals_f2_ql | true | 22480 | 22470 | |
73+
| staticlocals__staticlocals_f2_ql | true | 22482 | 22478 | |
74+
| staticlocals__staticlocals_f2_ql | true | 22484 | 22482 | |
75+
| staticlocals__staticlocals_f2_ql | true | 22499 | 22472 | |
76+
| staticlocals__staticlocals_f2_ql | true | 22500 | 22499 | |

cpp/ql/test/library-tests/syntax-zoo/pointer_to_member.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,9 @@ int usePM(int PM::* pm) {
2828

2929
return acc;
3030
}
31+
32+
void pmIsConst() {
33+
static const struct {
34+
int PM::* pm1;
35+
} pms = { &PM::x1 };
36+
}

cpp/ql/test/library-tests/syntax-zoo/raw_sanity.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ missingOperand
77
| misc.c:220:3:223:3 | Store: ... = ... | Instruction 'Store' is missing an expected operand with tag 'StoreValue' in function '$@'. | misc.c:219:5:219:26 | IR: assign_designated_init | int assign_designated_init(someStruct*) |
88
| misc.c:220:9:223:3 | FieldAddress: {...} | Instruction 'FieldAddress' is missing an expected operand with tag 'Unary' in function '$@'. | misc.c:219:5:219:26 | IR: assign_designated_init | int assign_designated_init(someStruct*) |
99
| misc.c:220:9:223:3 | FieldAddress: {...} | Instruction 'FieldAddress' is missing an expected operand with tag 'Unary' in function '$@'. | misc.c:219:5:219:26 | IR: assign_designated_init | int assign_designated_init(someStruct*) |
10+
| pointer_to_member.cpp:35:13:35:19 | FieldAddress: x1 | Instruction 'FieldAddress' is missing an expected operand with tag 'Unary' in function '$@'. | pointer_to_member.cpp:32:6:32:14 | IR: pmIsConst | void pmIsConst() |
1011
| range_analysis.c:368:10:368:21 | Store: ... ? ... : ... | Instruction 'Store' is missing an expected operand with tag 'StoreValue' in function '$@'. | range_analysis.c:355:14:355:27 | IR: test_ternary01 | unsigned int test_ternary01(unsigned int) |
1112
| range_analysis.c:369:10:369:36 | Store: ... ? ... : ... | Instruction 'Store' is missing an expected operand with tag 'StoreValue' in function '$@'. | range_analysis.c:355:14:355:27 | IR: test_ternary01 | unsigned int test_ternary01(unsigned int) |
1213
| range_analysis.c:370:10:370:38 | Store: ... ? ... : ... | Instruction 'Store' is missing an expected operand with tag 'StoreValue' in function '$@'. | range_analysis.c:355:14:355:27 | IR: test_ternary01 | unsigned int test_ternary01(unsigned int) |
@@ -65,6 +66,7 @@ instructionWithoutSuccessor
6566
| ms_try_mix.cpp:48:10:48:13 | CallSideEffect: call to C |
6667
| ms_try_mix.cpp:51:5:51:11 | ThrowValue: throw ... |
6768
| ms_try_mix.cpp:53:13:54:3 | NoOp: { ... } |
69+
| pointer_to_member.cpp:35:11:35:21 | FieldAddress: {...} |
6870
| static_init_templates.cpp:80:27:80:36 | Convert: (void *)... |
6971
| static_init_templates.cpp:80:27:80:36 | Convert: (void *)... |
7072
| static_init_templates.cpp:89:27:89:36 | Convert: (void *)... |
@@ -671,6 +673,7 @@ useNotDominatedByDefinition
671673
| ms_try_mix.cpp:38:16:38:19 | Operand | Operand 'Operand' is not dominated by its definition in function '$@'. | ms_try_mix.cpp:27:6:27:19 | IR: ms_finally_mix | void ms_finally_mix(int) |
672674
| ms_try_mix.cpp:41:12:41:15 | Operand | Operand 'Operand' is not dominated by its definition in function '$@'. | ms_try_mix.cpp:27:6:27:19 | IR: ms_finally_mix | void ms_finally_mix(int) |
673675
| ms_try_mix.cpp:51:5:51:11 | Load | Operand 'Load' is not dominated by its definition in function '$@'. | ms_try_mix.cpp:47:6:47:28 | IR: ms_empty_finally_at_end | void ms_empty_finally_at_end() |
676+
| pointer_to_member.cpp:35:13:35:19 | Address | Operand 'Address' is not dominated by its definition in function '$@'. | pointer_to_member.cpp:32:6:32:14 | IR: pmIsConst | void pmIsConst() |
674677
| stmt_expr.cpp:30:20:30:21 | Operand | Operand 'Operand' is not dominated by its definition in function '$@'. | stmt_expr.cpp:21:6:21:6 | IR: g | void stmtexpr::g(int) |
675678
| stmt_expr.cpp:31:16:31:18 | Load | Operand 'Load' is not dominated by its definition in function '$@'. | stmt_expr.cpp:21:6:21:6 | IR: g | void stmtexpr::g(int) |
676679
| try_catch.cpp:21:13:21:24 | Address | Operand 'Address' is not dominated by its definition in function '$@'. | try_catch.cpp:19:6:19:23 | IR: throw_from_nonstmt | void throw_from_nonstmt(int) |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
| pointer_to_member__pmIsConst | pointer_to_member.cpp:33:3:35:22 | declaration | pointer_to_member.cpp:35:11:35:21 | initializer for pms | Standard edge, only from QL |
2+
| pointer_to_member__pmIsConst | pointer_to_member.cpp:33:3:35:22 | declaration | pointer_to_member.cpp:36:1:36:1 | return ... | Standard edge, only from extractor |
3+
| pointer_to_member__pmIsConst | pointer_to_member.cpp:35:11:35:21 | initializer for pms | pointer_to_member.cpp:35:13:35:19 | x1 | Standard edge, only from QL |
4+
| pointer_to_member__pmIsConst | pointer_to_member.cpp:35:11:35:21 | {...} | pointer_to_member.cpp:36:1:36:1 | return ... | Standard edge, only from QL |
5+
| pointer_to_member__pmIsConst | pointer_to_member.cpp:35:13:35:19 | x1 | pointer_to_member.cpp:35:11:35:21 | {...} | Standard edge, only from QL |
16
| staticlocals__staticlocals_f2 | file://:0:0:0:0 | call to C | staticlocals.cpp:30:1:30:1 | return ... | Standard edge, only from QL |
27
| staticlocals__staticlocals_f2 | file://:0:0:0:0 | initializer for c | file://:0:0:0:0 | call to C | Standard edge, only from QL |
38
| staticlocals__staticlocals_f2 | staticlocals.cpp:29:5:29:17 | declaration | file://:0:0:0:0 | initializer for c | Standard edge, only from QL |

cpp/ql/test/library-tests/syntax-zoo/unaliased_ssa_sanity.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ instructionWithoutSuccessor
2929
| ms_try_mix.cpp:11:12:11:15 | CallSideEffect: call to C |
3030
| ms_try_mix.cpp:28:12:28:15 | CallSideEffect: call to C |
3131
| ms_try_mix.cpp:48:10:48:13 | CallSideEffect: call to C |
32+
| pointer_to_member.cpp:35:11:35:21 | FieldAddress: {...} |
3233
| stmt_expr.cpp:27:5:27:15 | Store: ... = ... |
3334
| vla.c:5:9:5:14 | Uninitialized: definition of matrix |
3435
| vla.c:11:6:11:16 | UnmodeledDefinition: vla_typedef |

0 commit comments

Comments
 (0)