Skip to content

Commit 0209196

Browse files
author
Daniel Kroening
committed
replace instances of numeric_cast by numeric_cast_v
1 parent 1f91726 commit 0209196

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
@@ -1069,12 +1069,10 @@ codet java_bytecode_convert_methodt::convert_instructions(
10691069
{
10701070
PRECONDITION(!i_it->args.empty());
10711071

1072-
auto target = numeric_cast<unsigned>(to_constant_expr(i_it->args[0]));
1073-
DATA_INVARIANT(
1074-
target.has_value(), "target expected to be unsigned integer");
1075-
targets.insert(target.value());
1072+
auto target = numeric_cast_v<unsigned>(to_constant_expr(i_it->args[0]));
1073+
targets.insert(target);
10761074

1077-
a_entry.first->second.successors.push_back(target.value());
1075+
a_entry.first->second.successors.push_back(target);
10781076

10791077
if(i_it->statement=="jsr" ||
10801078
i_it->statement=="jsr_w")
@@ -1094,11 +1092,9 @@ codet java_bytecode_convert_methodt::convert_instructions(
10941092
{
10951093
if(is_label)
10961094
{
1097-
auto target = numeric_cast<unsigned>(to_constant_expr(arg));
1098-
DATA_INVARIANT(
1099-
target.has_value(), "target expected to be unsigned integer");
1100-
targets.insert(target.value());
1101-
a_entry.first->second.successors.push_back(target.value());
1095+
auto target = numeric_cast_v<unsigned>(to_constant_expr(arg));
1096+
targets.insert(target);
1097+
a_entry.first->second.successors.push_back(target);
11021098
}
11031099
is_label=!is_label;
11041100
}

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)