Skip to content

Commit ae4bc0e

Browse files
committed
Add test case for initialization statement and fix expected column number
1 parent 71dc2be commit ae4bc0e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

clang-tools-extra/test/clang-tidy/checkers/readability/simplify-boolean-expr.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,10 +1035,19 @@ void instantiate() {
10351035
ignoreInstantiations<true>();
10361036
ignoreInstantiations<false>();
10371037
}
1038+
10381039
void if_with_init_statement() {
10391040
bool x = true;
10401041
if (bool y = x; y == true) {
1041-
// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr]
1042+
// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr]
10421043
// CHECK-FIXES: if (bool y = x; y) {
10431044
}
10441045
}
1046+
1047+
void test_init_stmt_true() {
1048+
void foo(int i);
1049+
if (int i = 0; true)
1050+
foo(i);
1051+
// CHECK-MESSAGES: :[[@LINE-2]]:18: warning: redundant boolean literal in if statement condition [readability-simplify-boolean-expr]
1052+
// CHECK-FIXES: { int i = 0;foo(i) };
1053+
}

0 commit comments

Comments
 (0)