Skip to content

Commit 867fb02

Browse files
committed
Do not use redundant comparison with true or false
We generally don't do so, and using it in selected places is an unnecessary surprise to the (code) reader.
1 parent c89d376 commit 867fb02

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

jbmc/src/java_bytecode/java_static_initializers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ codet get_clinit_wrapper_body(
656656
//
657657
// java::C::clinit_wrapper()
658658
// {
659-
// if (java::C::clinit_already_run == false)
659+
// if (!java::C::clinit_already_run)
660660
// {
661661
// java::C::clinit_already_run = true; // before recursive calls!
662662
//

src/cpp/cpp_typecheck_code.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code)
258258
// a reference member
259259
if(symbol_expr.id() == ID_dereference &&
260260
symbol_expr.op0().id() == ID_member &&
261-
symbol_expr.get_bool(ID_C_implicit) == true)
261+
symbol_expr.get_bool(ID_C_implicit))
262262
{
263263
// treat references as normal pointers
264264
exprt tmp = symbol_expr.op0();
@@ -286,7 +286,7 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code)
286286

287287
if(symbol_expr.id() == ID_dereference &&
288288
symbol_expr.op0().id() == ID_member &&
289-
symbol_expr.get_bool(ID_C_implicit) == true)
289+
symbol_expr.get_bool(ID_C_implicit))
290290
{
291291
// treat references as normal pointers
292292
exprt tmp = symbol_expr.op0();

src/cpp/cpp_typecheck_conversions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1643,7 +1643,7 @@ bool cpp_typecheckt::const_typecast(
16431643
const typet &type,
16441644
exprt &new_expr)
16451645
{
1646-
assert(is_reference(expr.type())==false);
1646+
PRECONDITION(!is_reference(expr.type()));
16471647

16481648
exprt curr_expr=expr;
16491649

src/solvers/smt2/smt2_conv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4102,7 +4102,7 @@ void smt2_convt::set_to(const exprt &expr, bool value)
41024102
// special treatment for "set_to(a=b, true)" where
41034103
// a is a new symbol
41044104

4105-
if(expr.id()==ID_equal && value==true)
4105+
if(expr.id() == ID_equal && value)
41064106
{
41074107
const equal_exprt &equal_expr=to_equal_expr(expr);
41084108

unit/util/optional.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@
1212
TEST_CASE("Optional without a value", "[core][util][optional]")
1313
{
1414
optionalt<bool> maybe_value;
15-
REQUIRE(maybe_value.has_value()==false);
15+
REQUIRE(!maybe_value.has_value());
1616
REQUIRE_THROWS_AS(maybe_value.value(), bad_optional_accesst);
1717
}
1818

1919
TEST_CASE("Optional with a value", "[core][util][optional]")
2020
{
2121
optionalt<bool> maybe_value=false;
2222
REQUIRE(maybe_value.has_value());
23-
REQUIRE(maybe_value.value()==false);
23+
REQUIRE(!maybe_value.value());
2424
}
2525

2626

2727
TEST_CASE("Optional with a value (operator access)", "[core][util][optional]")
2828
{
2929
optionalt<bool> maybe_value=true;
3030
REQUIRE(maybe_value.has_value());
31-
REQUIRE(*maybe_value==true);
31+
REQUIRE(*maybe_value);
3232
}

unit/util/replace_symbol.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ TEST_CASE("Replace all symbols in expression", "[core][util][replace_symbol]")
3232
REQUIRE(r.replaces_symbol("a"));
3333
REQUIRE(r.get_expr_map().size() == 1);
3434

35-
REQUIRE(r.replace(binary) == false);
35+
REQUIRE(!r.replace(binary));
3636
REQUIRE(binary.op0() == other_expr);
3737

38-
REQUIRE(r.replace(s1) == false);
38+
REQUIRE(!r.replace(s1));
3939
REQUIRE(s1 == other_expr);
4040

41-
REQUIRE(r.replace(s2) == true);
41+
REQUIRE(r.replace(s2));
4242
REQUIRE(s2 == symbol_exprt("b", typet("some_type")));
4343

4444

45-
REQUIRE(r.replace(array_type) == false);
45+
REQUIRE(!r.replace(array_type));
4646
REQUIRE(array_type.size() == other_expr);
4747

4848
REQUIRE(r.erase("a") == 1);
@@ -65,7 +65,7 @@ TEST_CASE("Lvalue only", "[core][util][replace_symbol]")
6565
address_of_aware_replace_symbolt r;
6666
r.insert(s1, c);
6767

68-
REQUIRE(r.replace(binary) == false);
68+
REQUIRE(!r.replace(binary));
6969
REQUIRE(binary.op0() == address_of_exprt(s1));
7070
const index_exprt &index_expr =
7171
to_index_expr(to_address_of_expr(binary.op1()).object());
@@ -76,7 +76,7 @@ TEST_CASE("Lvalue only", "[core][util][replace_symbol]")
7676
r.erase("a");
7777
r.insert(s1, address_of);
7878

79-
REQUIRE(r.replace(binary) == true);
79+
REQUIRE(r.replace(binary));
8080
REQUIRE(binary.op0() == address_of_exprt(s1));
8181
}
8282

@@ -96,7 +96,7 @@ TEST_CASE("Replace always", "[core][util][replace_symbol]")
9696
unchecked_replace_symbolt r;
9797
r.insert(s1, c);
9898

99-
REQUIRE(r.replace(binary) == false);
99+
REQUIRE(!r.replace(binary));
100100
REQUIRE(binary.op0() == address_of_exprt(c));
101101
const index_exprt &index_expr =
102102
to_index_expr(to_address_of_expr(binary.op1()).object());

0 commit comments

Comments
 (0)