File tree 3 files changed +19
-8
lines changed 3 files changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -113,7 +113,9 @@ bool boolbvt::literal(
113
113
throw " found no literal for expression" ;
114
114
}
115
115
116
- const bvt &boolbvt::convert_bv (const exprt &expr)
116
+ const bvt &boolbvt::convert_bv (
117
+ const exprt &expr,
118
+ optionalt<std::size_t > expected_width)
117
119
{
118
120
// check cache first
119
121
std::pair<bv_cachet::iterator, bool > cache_result=
@@ -126,18 +128,21 @@ const bvt &boolbvt::convert_bv(const exprt &expr)
126
128
// Iterators into hash_maps supposedly stay stable
127
129
// even though we are inserting more elements recursively.
128
130
129
- cache_result.first ->second =convert_bitvector (expr);
131
+ const bvt &bv = convert_bitvector (expr);
132
+ CHECK_RETURN (!expected_width || bv.size () == *expected_width);
133
+
134
+ cache_result.first ->second = bv;
130
135
131
136
// check
132
137
forall_literals (it, cache_result.first ->second )
133
138
{
134
139
if (freeze_all && !it->is_constant ())
135
140
prop.set_frozen (*it);
136
- if (it-> var_no ()== literalt::unused_var_no ())
137
- {
138
- error () << " unused_var_no: " << expr. pretty () << eom;
139
- assert ( false );
140
- }
141
+
142
+ INVARIANT_WITH_DIAGNOSTICS (
143
+ it-> var_no () != literalt::unused_var_no (),
144
+ " variable number must be different from the unused variable number " ,
145
+ expr. pretty ());
141
146
}
142
147
143
148
return cache_result.first ->second ;
Original file line number Diff line number Diff line change 17
17
#include < util/mp_arith.h>
18
18
#include < util/expr.h>
19
19
#include < util/byte_operators.h>
20
+ #include < util/optional.h>
20
21
21
22
#include " bv_utils.h"
22
23
#include " boolbv_width.h"
@@ -43,7 +44,10 @@ class boolbvt:public arrayst
43
44
{
44
45
}
45
46
46
- virtual const bvt &convert_bv (const exprt &expr); // check cache
47
+ virtual const bvt &convert_bv ( // check cache
48
+ const exprt &expr,
49
+ const optionalt<std::size_t > expected_width = nullopt);
50
+
47
51
virtual bvt convert_bitvector (const exprt &expr); // no cache
48
52
49
53
// overloading
Original file line number Diff line number Diff line change @@ -36,4 +36,6 @@ using optionalt=nonstd::optional<T>; // NOLINT template typedef
36
36
37
37
typedef nonstd::bad_optional_access bad_optional_accesst;
38
38
39
+ using nonstd::nullopt;
40
+
39
41
#endif // CPROVER_UTIL_OPTIONAL_H
You can’t perform that action at this time.
0 commit comments