1 // RUN: %check_clang_tidy %s bugprone-terminating-continue %t
2
f()3 void f() {
4 do {
5 continue;
6 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'continue' in loop with false condition is equivalent to 'break' [bugprone-terminating-continue]
7 // CHECK-FIXES: break;
8 } while(false);
9
10 do {
11 continue;
12 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'continue' in loop with false condition is equivalent to 'break' [bugprone-terminating-continue]
13 // CHECK-FIXES: break;
14 } while(0);
15
16 do {
17 continue;
18 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'continue' in loop with false condition is equivalent to 'break' [bugprone-terminating-continue]
19 // CHECK-FIXES: break;
20 } while(nullptr);
21
22 do {
23 continue;
24 // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'continue' in loop with false condition is equivalent to 'break' [bugprone-terminating-continue]
25 // CHECK-FIXES: break;
26 } while(__null);
27
28
29 do {
30 int x = 1;
31 if (x > 0) continue;
32 // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'continue' in loop with false condition is equivalent to 'break' [bugprone-terminating-continue]
33 // CHECK-FIXES: if (x > 0) break;
34 } while (false);
35 }
36
g()37 void g() {
38 do {
39 do {
40 continue;
41 int x = 1;
42 } while (1 == 1);
43 } while (false);
44
45 do {
46 for (int i = 0; i < 1; ++i) {
47 continue;
48 int x = 1;
49 }
50 } while (false);
51
52 do {
53 while (true) {
54 continue;
55 int x = 1;
56 }
57 } while (false);
58
59 int v[] = {1,2,3,34};
60 do {
61 for (int n : v) {
62 if (n>2) continue;
63 }
64 } while (false);
65 }
66