2015-08-21 01:58:07 +08:00
|
|
|
// RUN: %python %S/check_clang_tidy.py %s readability-braces-around-statements %t -config="{CheckOptions: [{key: readability-braces-around-statements.ShortStatementLines, value: 2}]}" --
|
2014-10-13 20:46:22 +08:00
|
|
|
|
|
|
|
void do_something(const char *) {}
|
|
|
|
|
|
|
|
bool cond(const char *) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void test() {
|
|
|
|
if (cond("if1") /*comment*/) do_something("same-line");
|
|
|
|
|
|
|
|
if (cond("if2"))
|
|
|
|
do_something("single-line");
|
|
|
|
|
|
|
|
if (cond("if3") /*comment*/)
|
|
|
|
// some comment
|
|
|
|
do_something("three"
|
|
|
|
"lines");
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-4]]:31: warning: statement should be inside braces
|
|
|
|
// CHECK-FIXES: if (cond("if3") /*comment*/) {
|
|
|
|
// CHECK-FIXES: }
|
|
|
|
|
|
|
|
if (cond("if4") /*comment*/)
|
|
|
|
// some comment
|
|
|
|
do_something("many"
|
|
|
|
"many"
|
|
|
|
"many"
|
|
|
|
"many"
|
|
|
|
"lines");
|
|
|
|
// CHECK-MESSAGES: :[[@LINE-7]]:31: warning: statement should be inside braces
|
|
|
|
// CHECK-FIXES: if (cond("if4") /*comment*/) {
|
|
|
|
// CHECK-FIXES: }
|
|
|
|
}
|