File tree Expand file tree Collapse file tree 4 files changed +12
-5
lines changed
regression/cbmc/object-bits-parsing Expand file tree Collapse file tree 4 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 1
1
CORE
2
2
test.c
3
3
--object-bits foobar
4
+ Value of "foobar" given for object-bits is not a valid unsigned integer.
4
5
object-bits must be positive and less than the pointer width
5
6
^EXIT=1$
6
7
^SIGNAL=0$
Original file line number Diff line number Diff line change 1
1
CORE
2
2
test.c
3
3
--object-bits 65
4
+ Value of "65" given for object-bits is out of range.
4
5
object-bits must be positive and less than the pointer width
5
6
^EXIT=1$
6
7
^SIGNAL=0$
Original file line number Diff line number Diff line change 1
1
CORE
2
2
test.c
3
3
--object-bits 0
4
+ Value of "0" given for object-bits is out of range.
4
5
object-bits must be positive and less than the pointer width
5
6
^EXIT=1$
6
7
^SIGNAL=0$
Original file line number Diff line number Diff line change @@ -776,14 +776,18 @@ configt::bv_encodingt parse_object_bits_encoding(
776
776
const std::string &argument,
777
777
const std::size_t pointer_width)
778
778
{
779
- const auto object_bits = string2optional<unsigned int >(argument);
780
- if (!object_bits || *object_bits <= 0 || *object_bits >= pointer_width)
781
- {
779
+ const auto throw_for_reason = [&](const std::string &reason) {
782
780
throw invalid_command_line_argument_exceptiont (
783
- " object-bits must be positive and less than the pointer width (" +
781
+ " Value of \" " + argument + " \" given for object-bits is " + reason +
782
+ " . object-bits must be positive and less than the pointer width (" +
784
783
std::to_string (pointer_width) + " ) " ,
785
784
" --object_bits" );
786
- }
785
+ };
786
+ const auto object_bits = string2optional<unsigned int >(argument);
787
+ if (!object_bits)
788
+ throw_for_reason (" not a valid unsigned integer" );
789
+ if (*object_bits <= 0 || *object_bits >= pointer_width)
790
+ throw_for_reason (" out of range" );
787
791
788
792
configt::bv_encodingt bv_encoding;
789
793
bv_encoding.object_bits = *object_bits;
You can’t perform that action at this time.
0 commit comments