1// RUN: %check_clang_tidy %s readability-braces-around-statements %t -- -config="{CheckOptions: {readability-braces-around-statements.ShortStatementLines: 1}}" --
2
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}
37

source code of clang-tools-extra/test/clang-tidy/checkers/readability/braces-around-statements-same-line.cpp