Skip to content

Commit 7903623

Browse files
author
Daniel Kroening
committed
replace instances of numeric_cast by numeric_cast_v
1 parent 61a6b3f commit 7903623

File tree

3 files changed

+8
-18
lines changed

3 files changed

+8
-18
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,12 +1065,10 @@ codet java_bytecode_convert_methodt::convert_instructions(
10651065
{
10661066
PRECONDITION(!i_it->args.empty());
10671067

1068-
auto target = numeric_cast<unsigned>(to_constant_expr(i_it->args[0]));
1069-
DATA_INVARIANT(
1070-
target.has_value(), "target expected to be unsigned integer");
1071-
targets.insert(target.value());
1068+
auto target = numeric_cast_v<unsigned>(to_constant_expr(i_it->args[0]));
1069+
targets.insert(target);
10721070

1073-
a_entry.first->second.successors.push_back(target.value());
1071+
a_entry.first->second.successors.push_back(target);
10741072

10751073
if(i_it->statement=="jsr" ||
10761074
i_it->statement=="jsr_w")
@@ -1090,11 +1088,9 @@ codet java_bytecode_convert_methodt::convert_instructions(
10901088
{
10911089
if(is_label)
10921090
{
1093-
auto target = numeric_cast<unsigned>(to_constant_expr(arg));
1094-
DATA_INVARIANT(
1095-
target.has_value(), "target expected to be unsigned integer");
1096-
targets.insert(target.value());
1097-
a_entry.first->second.successors.push_back(target.value());
1091+
auto target = numeric_cast_v<unsigned>(to_constant_expr(arg));
1092+
targets.insert(target);
1093+
a_entry.first->second.successors.push_back(target);
10981094
}
10991095
is_label=!is_label;
11001096
}

jbmc/src/java_bytecode/java_local_variable_table.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,7 @@ static bool is_store_to_slot(
193193
{
194194
// Store with an argument:
195195
const auto &arg=inst.args[0];
196-
auto v = numeric_cast<unsigned>(to_constant_expr(arg));
197-
CHECK_RETURN(v.has_value());
198-
storeslotidx = v.value();
196+
storeslotidx = numeric_cast_v<unsigned>(to_constant_expr(arg));
199197
}
200198
else
201199
{

src/solvers/refinement/string_constraint_generator_format.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -488,11 +488,7 @@ utf16_constant_array_to_java(const array_exprt &arr, std::size_t length)
488488
std::wstring out(length, '?');
489489

490490
for(std::size_t i=0; i<arr.operands().size() && i<length; i++)
491-
{
492-
auto c = numeric_cast<unsigned>(to_constant_expr(arr.operands()[i]));
493-
INVARIANT(c.has_value(), "constant should be convertible to unsigned");
494-
out[i] = c.value();
495-
}
491+
out[i] = numeric_cast_v<unsigned>(to_constant_expr(arr.operands()[i]));
496492

497493
return utf16_native_endian_to_java(out);
498494
}

0 commit comments

Comments
 (0)