brintos

brintos / llvm-project-archived public Read only

0
0
Text · 951 B · 3b90299 Raw
34 lines · cpp
1// RUN: %check_clang_tidy %s readability-braces-around-statements %t -- -config="{CheckOptions: {readability-braces-around-statements.ShortStatementLines: 2}}" --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 15  if (cond("if3") /*comment*/)16    // some comment17    do_something("three"18                 "lines");19  // CHECK-MESSAGES: :[[@LINE-4]]:31: warning: statement should be inside braces20  // CHECK-FIXES: if (cond("if3") /*comment*/) {21  // CHECK-FIXES: }22 23  if (cond("if4") /*comment*/)24    // some comment25    do_something("many"26                 "many"27                 "many"28                 "many"29                 "lines");30  // CHECK-MESSAGES: :[[@LINE-7]]:31: warning: statement should be inside braces31  // CHECK-FIXES: if (cond("if4") /*comment*/) {32  // CHECK-FIXES: }33}34