Skip to content

Commit 92fbfc5

Browse files
authored
Merge pull request #3004 from tautschnig/true-false
Do not use redundant comparison with true or false
2 parents ae57b25 + 187430e commit 92fbfc5

File tree

6 files changed

+21
-20
lines changed

6 files changed

+21
-20
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: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,10 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code)
255255
else
256256
{
257257
// a reference member
258-
if(symbol_expr.id() == ID_dereference &&
259-
symbol_expr.op0().id() == ID_member &&
260-
symbol_expr.get_bool(ID_C_implicit) == true)
258+
if(
259+
symbol_expr.id() == ID_dereference &&
260+
symbol_expr.op0().id() == ID_member &&
261+
symbol_expr.get_bool(ID_C_implicit))
261262
{
262263
// treat references as normal pointers
263264
exprt tmp = symbol_expr.op0();
@@ -283,9 +284,10 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code)
283284
symbol_expr=resolve(member, cpp_typecheck_resolvet::wantt::VAR, fargs);
284285
}
285286

286-
if(symbol_expr.id() == ID_dereference &&
287-
symbol_expr.op0().id() == ID_member &&
288-
symbol_expr.get_bool(ID_C_implicit) == true)
287+
if(
288+
symbol_expr.id() == ID_dereference &&
289+
symbol_expr.op0().id() == ID_member &&
290+
symbol_expr.get_bool(ID_C_implicit))
289291
{
290292
// treat references as normal pointers
291293
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
@@ -1631,7 +1631,7 @@ bool cpp_typecheckt::const_typecast(
16311631
const typet &type,
16321632
exprt &new_expr)
16331633
{
1634-
assert(is_reference(expr.type())==false);
1634+
PRECONDITION(!is_reference(expr.type()));
16351635

16361636
exprt curr_expr=expr;
16371637

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 & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,16 @@ 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

44-
45-
REQUIRE(r.replace(array_type) == false);
44+
REQUIRE(!r.replace(array_type));
4645
REQUIRE(array_type.size() == other_expr);
4746

4847
REQUIRE(r.erase("a") == 1);
@@ -65,7 +64,7 @@ TEST_CASE("Lvalue only", "[core][util][replace_symbol]")
6564
address_of_aware_replace_symbolt r;
6665
r.insert(s1, c);
6766

68-
REQUIRE(r.replace(binary) == false);
67+
REQUIRE(!r.replace(binary));
6968
REQUIRE(binary.op0() == address_of_exprt(s1));
7069
const index_exprt &index_expr =
7170
to_index_expr(to_address_of_expr(binary.op1()).object());
@@ -76,7 +75,7 @@ TEST_CASE("Lvalue only", "[core][util][replace_symbol]")
7675
r.erase("a");
7776
r.insert(s1, address_of);
7877

79-
REQUIRE(r.replace(binary) == true);
78+
REQUIRE(r.replace(binary));
8079
REQUIRE(binary.op0() == address_of_exprt(s1));
8180
}
8281

@@ -96,7 +95,7 @@ TEST_CASE("Replace always", "[core][util][replace_symbol]")
9695
unchecked_replace_symbolt r;
9796
r.insert(s1, c);
9897

99-
REQUIRE(r.replace(binary) == false);
98+
REQUIRE(!r.replace(binary));
10099
REQUIRE(binary.op0() == address_of_exprt(c));
101100
const index_exprt &index_expr =
102101
to_index_expr(to_address_of_expr(binary.op1()).object());

0 commit comments

Comments
 (0)