Skip to content

Commit fc44d99

Browse files
Use invariant instead if printing error message to cout
1 parent a15b75f commit fc44d99

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

src/solvers/flattening/boolbv_equality.cpp

+14-12
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,20 @@ Author: Daniel Kroening, [email protected]
1212

1313
#include <util/std_expr.h>
1414
#include <util/base_type.h>
15+
#include <util/invariant.h>
1516

1617
#include <langapi/language_util.h>
1718

1819
#include "flatten_byte_operators.h"
1920

2021
literalt boolbvt::convert_equality(const equal_exprt &expr)
2122
{
22-
if(!base_type_eq(expr.lhs().type(), expr.rhs().type(), ns))
23-
{
24-
std::cout << "######### lhs: " << expr.lhs().pretty() << '\n';
25-
std::cout << "######### rhs: " << expr.rhs().pretty() << '\n';
26-
throw "equality without matching types";
27-
}
23+
const bool is_base_type_eq =
24+
base_type_eq(expr.lhs().type(), expr.rhs().type(), ns);
25+
DATA_INVARIANT(
26+
is_base_type_eq,
27+
std::string("equality without matching types:\n") + "######### lhs: " +
28+
expr.lhs().pretty() + '\n' + "######### rhs: " + expr.rhs().pretty());
2829

2930
// see if it is an unbounded array
3031
if(is_unbounded_array(expr.lhs().type()))
@@ -68,12 +69,13 @@ literalt boolbvt::convert_verilog_case_equality(
6869
// This is 4-valued comparison, i.e., z===z, x===x etc.
6970
// The result is always Boolean.
7071

71-
if(!base_type_eq(expr.lhs().type(), expr.rhs().type(), ns))
72-
{
73-
std::cout << "######### lhs: " << expr.lhs().pretty() << '\n';
74-
std::cout << "######### rhs: " << expr.rhs().pretty() << '\n';
75-
throw "verilog_case_equality without matching types";
76-
}
72+
const bool is_base_type_eq =
73+
base_type_eq(expr.lhs().type(), expr.rhs().type(), ns);
74+
DATA_INVARIANT(
75+
is_base_type_eq,
76+
std::string("verilog_case_equality without matching types:\n") +
77+
"######### lhs: " + expr.lhs().pretty() + '\n' +
78+
"######### rhs: " + expr.rhs().pretty());
7779

7880
const bvt &bv0=convert_bv(expr.lhs());
7981
const bvt &bv1=convert_bv(expr.rhs());

0 commit comments

Comments
 (0)