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