Skip to content

Commit dea8803

Browse files
geoffw0Copilot
andcommitted
C++: Test complex-block statement thresholds
Cover blocks with four sufficiently large nested loops and the three-loop boundary for cpp/complex-block. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 43c6106 commit dea8803

3 files changed

Lines changed: 111 additions & 0 deletions

File tree

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
void complex_block_one() {
2+
while (true) {
3+
int a = 1;
4+
int b = 2;
5+
int c = 3;
6+
int d = 4;
7+
int e = 5;
8+
int f = 6;
9+
int g = 7;
10+
}
11+
while (true) {
12+
int a = 1;
13+
int b = 2;
14+
int c = 3;
15+
int d = 4;
16+
int e = 5;
17+
int f = 6;
18+
int g = 7;
19+
}
20+
while (true) {
21+
int a = 1;
22+
int b = 2;
23+
int c = 3;
24+
int d = 4;
25+
int e = 5;
26+
int f = 6;
27+
int g = 7;
28+
}
29+
while (true) {
30+
int a = 1;
31+
int b = 2;
32+
int c = 3;
33+
int d = 4;
34+
int e = 5;
35+
int f = 6;
36+
int g = 7;
37+
}
38+
} // $ Alert
39+
40+
void complex_block_two() {
41+
for (;;) {
42+
int a = 1;
43+
int b = 2;
44+
int c = 3;
45+
int d = 4;
46+
int e = 5;
47+
int f = 6;
48+
int g = 7;
49+
}
50+
for (;;) {
51+
int a = 1;
52+
int b = 2;
53+
int c = 3;
54+
int d = 4;
55+
int e = 5;
56+
int f = 6;
57+
int g = 7;
58+
}
59+
for (;;) {
60+
int a = 1;
61+
int b = 2;
62+
int c = 3;
63+
int d = 4;
64+
int e = 5;
65+
int f = 6;
66+
int g = 7;
67+
}
68+
for (;;) {
69+
int a = 1;
70+
int b = 2;
71+
int c = 3;
72+
int d = 4;
73+
int e = 5;
74+
int f = 6;
75+
int g = 7;
76+
}
77+
} // $ Alert
78+
79+
void three_complex_statements_is_not_enough() {
80+
while (true) {
81+
int a = 1;
82+
int b = 2;
83+
int c = 3;
84+
int d = 4;
85+
int e = 5;
86+
int f = 6;
87+
int g = 7;
88+
}
89+
while (true) {
90+
int a = 1;
91+
int b = 2;
92+
int c = 3;
93+
int d = 4;
94+
int e = 5;
95+
int f = 6;
96+
int g = 7;
97+
}
98+
while (true) {
99+
int a = 1;
100+
int b = 2;
101+
int c = 3;
102+
int d = 4;
103+
int e = 5;
104+
int f = 6;
105+
int g = 7;
106+
}
107+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| BlockWithTooManyStatements.cpp:1:26:38:1 | { ... } | Block with too many statements (4 complex statements in the block). |
2+
| BlockWithTooManyStatements.cpp:40:26:77:1 | { ... } | Block with too many statements (4 complex statements in the block). |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
query: Best Practices/BlockWithTooManyStatements.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql

0 commit comments

Comments
 (0)