File tree 4 files changed +46
-13
lines changed 4 files changed +46
-13
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ SRC = allocate_objects.cpp \
4
4
array_name.cpp \
5
5
base_type.cpp \
6
6
bv_arithmetic.cpp \
7
+ bv_encoding.cpp \
7
8
byte_operators.cpp \
8
9
c_types.cpp \
9
10
cmdline.cpp \
Original file line number Diff line number Diff line change
1
+ /* ******************************************************************\
2
+
3
+ Module: bv_encoding configuration
4
+
5
+ Author: Diffblue Ltd
6
+
7
+ \*******************************************************************/
8
+
9
+ #include " bv_encoding.h"
10
+
11
+ #include " exception_utils.h"
12
+ #include " string2int.h"
13
+
14
+ bv_encodingt parse_object_bits_encoding (
15
+ const std::string &argument,
16
+ const std::size_t pointer_width)
17
+ {
18
+ const unsigned int object_bits = unsafe_string2unsigned (argument);
19
+ if (object_bits <= 0 || object_bits >= pointer_width)
20
+ {
21
+ throw invalid_command_line_argument_exceptiont (
22
+ " object-bits must be positive and less than the pointer width (" +
23
+ std::to_string (pointer_width) + " ) " ,
24
+ " --object_bits" );
25
+ }
26
+
27
+ bv_encodingt bv_encoding;
28
+ bv_encoding.object_bits = object_bits;
29
+ bv_encoding.is_object_bits_default = false ;
30
+ return bv_encoding;
31
+ }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ Author: Diffblue Ltd
10
10
#define CPROVER_UTIL_BV_ENCODING_H
11
11
12
12
#include < cstddef>
13
+ #include < string>
13
14
14
15
struct bv_encodingt final
15
16
{
@@ -18,4 +19,15 @@ struct bv_encodingt final
18
19
bool is_object_bits_default = true ;
19
20
};
20
21
22
+ // / \brief Parses the `object_bits` argument from the command line arguments.
23
+ // / \param argument The command line argument to parse the `object_bits` from.
24
+ // / \param pointer_width The width of a pointer in bits. This is used to check
25
+ // / the value of object_bits is within the valid range.
26
+ // / \return A `bv_encodingt` on successful parsing. In the case where an invalid
27
+ // / argument is specified, an `invalid_command_line_argument_exceptiont` will
28
+ // / be thrown.
29
+ bv_encodingt parse_object_bits_encoding (
30
+ const std::string &argument,
31
+ const std::size_t pointer_width);
32
+
21
33
#endif // CPROVER_UTIL_BV_ENCODING_H
Original file line number Diff line number Diff line change @@ -1074,19 +1074,8 @@ bool configt::set(const cmdlinet &cmdline)
1074
1074
1075
1075
if (cmdline.isset (" object-bits" ))
1076
1076
{
1077
- bv_encoding.object_bits =
1078
- unsafe_string2unsigned (cmdline.get_value (" object-bits" ));
1079
-
1080
- if (!(0 <bv_encoding.object_bits &&
1081
- bv_encoding.object_bits <ansi_c.pointer_width ))
1082
- {
1083
- throw invalid_command_line_argument_exceptiont (
1084
- " object-bits must be positive and less than the pointer width (" +
1085
- std::to_string (ansi_c.pointer_width ) + " ) " ,
1086
- " --object_bits" );
1087
- }
1088
-
1089
- bv_encoding.is_object_bits_default = false ;
1077
+ bv_encoding = parse_object_bits_encoding (
1078
+ cmdline.get_value (" object-bits" ), ansi_c.pointer_width );
1090
1079
}
1091
1080
1092
1081
if (cmdline.isset (" malloc-fail-assert" ) && cmdline.isset (" malloc-fail-null" ))
You can’t perform that action at this time.
0 commit comments