File tree 3 files changed +53
-3
lines changed 3 files changed +53
-3
lines changed Original file line number Diff line number Diff line change @@ -152,6 +152,12 @@ bvt boolbvt::conversion_failed(const exprt &expr)
152
152
return prop.new_variables (width);
153
153
}
154
154
155
+ // / TODO
156
+ // / \param expr: TODO
157
+ // / \return TODO
158
+ // / \throws bitvector_conversion_exceptiont raised if converting byte_extraction
159
+ // / goes wrong.
160
+ // / TODO: extend for other types of conversion exception (diffblue/cbmc#2103).
155
161
bvt boolbvt::convert_bitvector (const exprt &expr)
156
162
{
157
163
if (expr.type ().id ()==ID_bool)
Original file line number Diff line number Diff line change 11
11
#include < cassert>
12
12
13
13
#include < util/arith_tools.h>
14
- #include < util/std_expr.h>
15
14
#include < util/byte_operators.h>
16
15
#include < util/endianness_map.h>
16
+ #include < util/std_expr.h>
17
17
18
+ #include " bv_conversion_exceptions.h"
19
+ #include " flatten_byte_extract_exceptions.h"
18
20
#include " flatten_byte_operators.h"
19
21
20
22
bvt map_bv (const endianness_mapt &map, const bvt &src)
@@ -42,8 +44,16 @@ bvt boolbvt::convert_byte_extract(const byte_extract_exprt &expr)
42
44
// if we extract from an unbounded array, call the flattening code
43
45
if (is_unbounded_array (expr.op ().type ()))
44
46
{
45
- exprt tmp=flatten_byte_extract (expr, ns);
46
- return convert_bv (tmp);
47
+ try
48
+ {
49
+ exprt tmp = flatten_byte_extract (expr, ns);
50
+ return convert_bv (tmp);
51
+ }
52
+ catch (const flatten_byte_extract_exceptiont &byte_extract_flatten_exception)
53
+ {
54
+ std::throw_with_nested (
55
+ bitvector_conversion_exceptiont (" Can't convert byte_extraction" , expr));
56
+ }
47
57
}
48
58
49
59
std::size_t width=boolbv_width (expr.type ());
Original file line number Diff line number Diff line change
1
+ /* ******************************************************************\
2
+
3
+ Module: Bit vector conversion
4
+
5
+ Author: Diffblue Ltd.
6
+
7
+ \*******************************************************************/
8
+
9
+ // / \file
10
+ // / Exceptions that can be raised in bv_conversion
11
+
12
+ #ifndef CPROVER_SOLVERS_FLATTENING_BV_CONVERSION_EXCEPTIONS_H
13
+ #define CPROVER_SOLVERS_FLATTENING_BV_CONVERSION_EXCEPTIONS_H
14
+
15
+ #include < stdexcept>
16
+ #include < string>
17
+
18
+ #include < util/expr.h>
19
+
20
+ class bitvector_conversion_exceptiont : public std ::runtime_error
21
+ {
22
+ public:
23
+ bitvector_conversion_exceptiont (
24
+ const std::string &exception_message,
25
+ const exprt &bv_expr)
26
+ : runtime_error(exception_message), bv_expr(bv_expr)
27
+ {
28
+ }
29
+
30
+ private:
31
+ exprt bv_expr;
32
+ };
33
+
34
+ #endif // CPROVER_SOLVERS_FLATTENING_BV_CONVERSION_EXCEPTIONS_H
You can’t perform that action at this time.
0 commit comments