1 // RUN: %check_clang_tidy %s readability-braces-around-statements %t -- -format-style="{IndentWidth: 3}" --
2
do_something(const char *)3 void do_something(const char *) {}
4
cond(const char *)5 bool cond(const char *) {
6 return false;
7 }
8
test()9 void test() {
10 if (cond("if0") /*comment*/) do_something("same-line");
11 // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: statement should be inside braces
12 // CHECK-FIXES: {{^}} if (cond("if0") /*comment*/) {{{$}}
13 // CHECK-FIXES-NEXT: {{^}} do_something("same-line");{{$}}
14 // CHECK-FIXES-NEXT: {{^}} }{{$}}
15
16 if (1) while (2) if (3) for (;;) do ; while(false) /**/;/**/
17 // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: statement should be inside braces
18 // CHECK-MESSAGES: :[[@LINE-2]]:19: warning: statement should be inside braces
19 // CHECK-MESSAGES: :[[@LINE-3]]:26: warning: statement should be inside braces
20 // CHECK-MESSAGES: :[[@LINE-4]]:35: warning: statement should be inside braces
21 // CHECK-MESSAGES: :[[@LINE-5]]:38: warning: statement should be inside braces
22 // CHECK-FIXES: {{^}} if (1) {{{$}}
23 // CHECK-FIXES-NEXT: {{^}} while (2) {
24 // CHECK-FIXES-NEXT: {{^}} if (3) {
25 // CHECK-FIXES-NEXT: {{^}} for (;;) {
26 // CHECK-FIXES-NEXT: {{^}} do {
27 // CHECK-FIXES-NEXT: {{^}} ;
28 // CHECK-FIXES-NEXT: {{^}} } while (false) /**/; /**/
29 // CHECK-FIXES-NEXT: {{^}} }
30 // CHECK-FIXES-NEXT: {{^}} }
31 // CHECK-FIXES-NEXT: {{^}} }
32 // CHECK-FIXES-NEXT: {{^}} }
33 }
34