linux-packaging-mono/external/llvm-project/clang-tools-extra/test/clang-tidy/readability-braces-around-statements-format.cpp
Xamarin Public Jenkins (auto-signing) 468663ddbb Imported Upstream version 6.10.0.49
Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
2020-01-16 16:38:04 +00:00

34 lines
1.4 KiB
C++

// RUN: %check_clang_tidy %s readability-braces-around-statements %t -- -format-style="{IndentWidth: 3}" --
void do_something(const char *) {}
bool cond(const char *) {
return false;
}
void test() {
if (cond("if0") /*comment*/) do_something("same-line");
// CHECK-MESSAGES: :[[@LINE-1]]:31: warning: statement should be inside braces
// CHECK-FIXES: {{^}} if (cond("if0") /*comment*/) {{{$}}
// CHECK-FIXES-NEXT: {{^}} do_something("same-line");{{$}}
// CHECK-FIXES-NEXT: {{^}} }{{$}}
if (1) while (2) if (3) for (;;) do ; while(false) /**/;/**/
// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: statement should be inside braces
// CHECK-MESSAGES: :[[@LINE-2]]:19: warning: statement should be inside braces
// CHECK-MESSAGES: :[[@LINE-3]]:26: warning: statement should be inside braces
// CHECK-MESSAGES: :[[@LINE-4]]:35: warning: statement should be inside braces
// CHECK-MESSAGES: :[[@LINE-5]]:38: warning: statement should be inside braces
// CHECK-FIXES: {{^}} if (1) {{{$}}
// CHECK-FIXES-NEXT: {{^}} while (2) {
// CHECK-FIXES-NEXT: {{^}} if (3) {
// CHECK-FIXES-NEXT: {{^}} for (;;) {
// CHECK-FIXES-NEXT: {{^}} do {
// CHECK-FIXES-NEXT: {{^}} ;
// CHECK-FIXES-NEXT: {{^}} } while (false) /**/; /**/
// CHECK-FIXES-NEXT: {{^}} }
// CHECK-FIXES-NEXT: {{^}} }
// CHECK-FIXES-NEXT: {{^}} }
// CHECK-FIXES-NEXT: {{^}} }
}