@@ -19,13 +19,11 @@ literalt boolbvt::convert_equality(const equal_exprt &expr)
19
19
{
20
20
const bool is_base_type_eq =
21
21
base_type_eq (expr.lhs ().type (), expr.rhs ().type (), ns);
22
- if (!is_base_type_eq)
23
- {
24
- const std::string error_msg =
25
- std::string (" equality without matching types:\n " ) + " ######### lhs: " +
26
- expr.lhs ().pretty () + ' \n ' + " ######### rhs: " + expr.rhs ().pretty ();
27
- throw bitvector_conversion_exceptiont (error_msg, expr);
28
- }
22
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
23
+ is_base_type_eq,
24
+ " types of expressions on each side of equality should match" ,
25
+ irep_pretty_diagnosticst{expr.lhs ()},
26
+ irep_pretty_diagnosticst{expr.rhs ()});
29
27
30
28
// see if it is an unbounded array
31
29
if (is_unbounded_array (expr.lhs ().type ()))
@@ -44,12 +42,13 @@ literalt boolbvt::convert_equality(const equal_exprt &expr)
44
42
const bvt &lhs_bv = convert_bv (expr.lhs ());
45
43
const bvt &rhs_bv = convert_bv (expr.rhs ());
46
44
47
- DATA_INVARIANT (
45
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
48
46
lhs_bv.size () == rhs_bv.size (),
49
- std::string (" unexpected size mismatch on equality:\n " ) +
50
- " lhs: " + expr.lhs ().pretty () + ' \n ' + " lhs size: " +
51
- std::to_string (lhs_bv.size ()) + ' \n ' + " rhs: " + expr.rhs ().pretty () +
52
- ' \n ' + " rhs size: " + std::to_string (rhs_bv.size ()));
47
+ " sizes of lhs and rhs bitvectors should match" ,
48
+ irep_pretty_diagnosticst{expr.lhs ()},
49
+ " lhs size: " + std::to_string (lhs_bv.size ()),
50
+ irep_pretty_diagnosticst{expr.rhs ()},
51
+ " rhs size: " + std::to_string (rhs_bv.size ()));
53
52
54
53
if (lhs_bv.empty ())
55
54
{
@@ -69,21 +68,22 @@ literalt boolbvt::convert_verilog_case_equality(
69
68
70
69
const bool is_base_type_eq =
71
70
base_type_eq (expr.lhs ().type (), expr.rhs ().type (), ns);
72
- DATA_INVARIANT (
71
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
73
72
is_base_type_eq,
74
- std::string ( " verilog_case_equality without matching types: \n " ) +
75
- " ######### lhs: " + expr.lhs (). pretty () + ' \n ' +
76
- " ######### rhs: " + expr.rhs (). pretty () );
73
+ " lhs and rhs types should match in verilog_case_equality " ,
74
+ irep_pretty_diagnosticst{ expr.lhs ()},
75
+ irep_pretty_diagnosticst{ expr.rhs ()} );
77
76
78
77
const bvt &lhs_bv = convert_bv (expr.lhs ());
79
78
const bvt &rhs_bv = convert_bv (expr.rhs ());
80
79
81
- DATA_INVARIANT (
80
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
82
81
lhs_bv.size () == rhs_bv.size (),
83
- std::string (" unexpected size mismatch on verilog_case_equality:\n " ) +
84
- " lhs: " + expr.lhs ().pretty () + ' \n ' + " lhs size: " +
85
- std::to_string (lhs_bv.size ()) + ' \n ' + " rhs: " + expr.rhs ().pretty () +
86
- ' \n ' + " rhs size: " + std::to_string (rhs_bv.size ()));
82
+ " bitvector arguments to verilog_case_equality should have the same size" ,
83
+ irep_pretty_diagnosticst{expr.lhs ()},
84
+ " lhs size: " + std::to_string (lhs_bv.size ()),
85
+ irep_pretty_diagnosticst{expr.rhs ()},
86
+ " rhs size: " + std::to_string (rhs_bv.size ()));
87
87
88
88
if (expr.id ()==ID_verilog_case_inequality)
89
89
return !bv_utils.equal (lhs_bv, rhs_bv);
0 commit comments