linux-packaging-mono/external/llvm-project/clang-tools-extra/test/clang-tidy/readability-simplify-bool-expr-chained-conditional-assignment.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

35 lines
1.0 KiB
C++

// RUN: %check_clang_tidy %s readability-simplify-boolean-expr %t -- -config="{CheckOptions: [{key: "readability-simplify-boolean-expr.ChainedConditionalAssignment", value: 1}]}" --
void chained_conditional_compound_assignment(int i) {
bool b;
if (i < 0) {
b = true;
} else if (i < 10) {
b = false;
} else if (i > 20) {
b = true;
} else {
b = false;
}
// CHECK-MESSAGES: :[[@LINE-4]]:9: warning: redundant boolean literal in conditional assignment [readability-simplify-boolean-expr]
// CHECK-FIXES: {{^}} } else if (i < 10) {{{$}}
// CHECK-FIXES-NEXT: {{^}} b = false;{{$}}
// CHECK-FIXES-NEXT: {{^}} } else b = i > 20;{{$}}
}
void chained_conditional_assignment(int i) {
bool b;
if (i < 0)
b = true;
else if (i < 10)
b = false;
else if (i > 20)
b = true;
else
b = false;
// CHECK-MESSAGES: :[[@LINE-3]]:9: warning: {{.*}} in conditional assignment
// CHECK-FIXES: {{^}} else if (i < 10)
// CHECK-FIXES-NEXT: {{^}} b = false;
// CHECK-FIXES-NEXT: {{^}} else b = i > 20;
}