blob: 4f1511258f3cde031077ee0d01e183c907ee3238 [file] [log] [blame]
Alexander Kornienkof3050002014-10-13 12:46:22 +00001// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s misc-braces-around-statements %t -config="{CheckOptions: [{key: misc-braces-around-statements.ShortStatementLines, value: 1}]}" --
2// REQUIRES: shell
3
4void do_something(const char *) {}
5
6bool cond(const char *) {
7 return false;
8}
9
10void test() {
11 if (cond("if1") /*comment*/) do_something("same-line");
12
13 if (cond("if2"))
14 do_something("single-line");
15 // CHECK-MESSAGES: :[[@LINE-2]]:19: warning: statement should be inside braces
16 // CHECK-FIXES: if (cond("if2")) {
17 // CHECK-FIXES: }
18
19 if (cond("if3") /*comment*/)
20 // some comment
21 do_something("three"
22 "lines");
23 // CHECK-MESSAGES: :[[@LINE-4]]:31: warning: statement should be inside braces
24 // CHECK-FIXES: if (cond("if3") /*comment*/) {
25 // CHECK-FIXES: }
26
27 if (cond("if4") /*comment*/)
28 // some comment
29 do_something("many"
30 "many"
31 "many"
32 "many"
33 "lines");
34 // CHECK-MESSAGES: :[[@LINE-7]]:31: warning: statement should be inside braces
35 // CHECK-FIXES: if (cond("if4") /*comment*/) {
36 // CHECK-FIXES: }
37}