Skip to content

Commit 928fc1a

Browse files
committed
Address feedback: Revert docs/existing tests and fix CI column mismatches
1 parent 096ca90 commit 928fc1a

File tree

1 file changed

+15
-42
lines changed

1 file changed

+15
-42
lines changed
Lines changed: 15 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,19 @@
1-
// RUN: %check_clang_tidy %s readability-simplify-boolean-expr %t -- -- -std=c++17
1+
// RUN: clang-tidy %s -checks='-*,readability-simplify-boolean-expr' -- -std=c++17 | count 0
2+
struct RAII {};
3+
bool foo(bool Cond) {
4+
bool Result;
25

3-
void test_init_stmt_true() {
4-
void foo(int i);
5-
if (int i = 0; true)
6-
foo(i);
7-
// CHECK-MESSAGES: :[[@LINE-2]]:18: warning: redundant boolean literal in if statement condition [readability-simplify-boolean-expr]
8-
// CHECK-FIXES: { int i = 0; foo(i); };
9-
}
10-
11-
void test_init_stmt_false() {
12-
void foo(int i);
13-
if (int i = 0; false)
14-
foo(i);
15-
// CHECK-MESSAGES: :[[@LINE-2]]:18: warning: redundant boolean literal in if statement condition [readability-simplify-boolean-expr]
16-
// CHECK-FIXES: { int i = 0; };
17-
}
18-
19-
void if_with_init_statement() {
20-
bool x = true;
21-
if (bool y = x; y == true) {
22-
// CHECK-MESSAGES: :[[@LINE-1]]:24: warning: redundant boolean literal supplied to boolean operator [readability-simplify-boolean-expr]
23-
// CHECK-FIXES: if (bool y = x; y) {
24-
}
25-
}
26-
27-
// This test verifies that we don't crash on C++17 init-statements with complex objects.
28-
// We use function calls to prevent the "conditional assignment" check from triggering.
29-
void test_cxx17_no_crash() {
30-
struct RAII {};
31-
bool Cond = true;
32-
void body();
33-
void else_body();
6+
if (RAII Object; Cond)
7+
Result = true;
8+
else
9+
Result = false;
3410

35-
if (RAII Object; Cond) {
36-
body();
37-
} else {
38-
else_body();
39-
}
11+
if (bool X = Cond; X)
12+
Result = true;
13+
else
14+
Result = false;
4015

41-
if (bool X = Cond; X) {
42-
body();
43-
} else {
44-
else_body();
45-
}
16+
if (bool X = Cond; X)
17+
return true;
18+
return false;
4619
}

0 commit comments

Comments
 (0)