@@ -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 ()))
@@ -41,24 +39,25 @@ literalt boolbvt::convert_equality(const equal_exprt &expr)
41
39
return record_array_equality (expr);
42
40
}
43
41
44
- const bvt &bv0= convert_bv (expr.lhs ());
45
- const bvt &bv1= convert_bv (expr.rhs ());
42
+ const bvt &lhs_bv = convert_bv (expr.lhs ());
43
+ const bvt &rhs_bv = convert_bv (expr.rhs ());
46
44
47
- DATA_INVARIANT (
48
- bv0.size () == bv1.size (),
49
- std::string (" unexpected size mismatch on equality:\n " ) + " lhs: " +
50
- expr.lhs ().pretty () + ' \n ' + " lhs size: " + std::to_string (bv0.size ()) +
51
- ' \n ' + " rhs: " + expr.rhs ().pretty () + ' \n ' +
52
- " rhs size: " + std::to_string (bv1.size ()));
45
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
46
+ lhs_bv.size () == 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
- if (bv0 .empty ())
53
+ if (lhs_bv .empty ())
55
54
{
56
55
// An empty bit-vector comparison. It's not clear
57
56
// what this is meant to say.
58
57
return prop.new_variable ();
59
58
}
60
59
61
- return bv_utils.equal (bv0, bv1 );
60
+ return bv_utils.equal (lhs_bv, rhs_bv );
62
61
}
63
62
64
63
literalt boolbvt::convert_verilog_case_equality (
@@ -69,24 +68,25 @@ 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
- const bvt &bv0= convert_bv (expr.lhs ());
79
- const bvt &bv1= convert_bv (expr.rhs ());
77
+ const bvt &lhs_bv = convert_bv (expr.lhs ());
78
+ const bvt &rhs_bv = convert_bv (expr.rhs ());
80
79
81
- DATA_INVARIANT (
82
- bv0.size () == bv1.size (),
83
- std::string (" unexpected size mismatch on verilog_case_equality:\n " ) +
84
- " lhs: " + expr.lhs ().pretty () + ' \n ' + " lhs size: " +
85
- std::to_string (bv0.size ()) + ' \n ' + " rhs: " + expr.rhs ().pretty () + ' \n ' +
86
- " rhs size: " + std::to_string (bv1.size ()));
80
+ DATA_INVARIANT_WITH_DIAGNOSTICS (
81
+ lhs_bv.size () == 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
- return !bv_utils.equal (bv0, bv1 );
89
+ return !bv_utils.equal (lhs_bv, rhs_bv );
90
90
else
91
- return bv_utils.equal (bv0, bv1 );
91
+ return bv_utils.equal (lhs_bv, rhs_bv );
92
92
}
0 commit comments