Skip to content

Commit d6e1984

Browse files
committed
Wrap return value in std::move
This fixes diffblue#3238 (again).
1 parent 43c84f8 commit d6e1984

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

jbmc/src/java_bytecode/java_string_library_preprocess.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,8 @@ codet java_string_library_preprocesst::make_assign_function_from_call(
11711171
/// \return An expression contaning a symbol `tmp_type_name` where `type_name`
11721172
/// is the given argument (ie. boolean, char etc.). Which represents the
11731173
/// primitive value contained in the given object.
1174-
exprt java_string_library_preprocesst::get_primitive_value_of_object(
1174+
optionalt<symbol_exprt>
1175+
java_string_library_preprocesst::get_primitive_value_of_object(
11751176
const exprt &object,
11761177
irep_idt type_name,
11771178
const source_locationt &loc,
@@ -1222,7 +1223,7 @@ exprt java_string_library_preprocesst::get_primitive_value_of_object(
12221223
object_type=symbol_typet("java::java.lang.Double");
12231224
}
12241225
else if(type_name==ID_void)
1225-
return nil_exprt();
1226+
return {};
12261227
else
12271228
UNREACHABLE;
12281229

@@ -1398,9 +1399,12 @@ exprt java_string_library_preprocesst::make_argument_for_format(
13981399
}
13991400
else if(name==ID_int || name==ID_float || name==ID_char || name==ID_boolean)
14001401
{
1401-
exprt value=get_primitive_value_of_object(
1402+
const auto value = get_primitive_value_of_object(
14021403
arg_i, name, loc, symbol_table, code_not_null);
1403-
code_not_null.add(code_assignt(field_expr, value), loc);
1404+
if(value.has_value())
1405+
code_not_null.add(code_assignt(field_expr, *value), loc);
1406+
else
1407+
code_not_null.add(code_assignt(field_expr, nil_exprt()), loc);
14041408
}
14051409
else
14061410
{

jbmc/src/java_bytecode/java_string_library_preprocess.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Date: March 2017
2121
#include <util/string_expr.h>
2222

2323
#include <util/ieee_float.h> // should get rid of this
24+
#include <util/optional.h>
2425

2526
#include <array>
2627
#include <unordered_set>
@@ -324,7 +325,7 @@ class java_string_library_preprocesst:public messaget
324325
symbol_table_baset &symbol_table,
325326
code_blockt &code);
326327

327-
exprt get_primitive_value_of_object(
328+
optionalt<symbol_exprt> get_primitive_value_of_object(
328329
const exprt &object,
329330
irep_idt type_name,
330331
const source_locationt &loc,

src/ansi-c/literals/convert_float_literal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,5 @@ exprt convert_float_literal(const std::string &src)
101101
return complex_exprt(zero_real_component, result, complex_type);
102102
}
103103

104-
return result;
104+
return std::move(result);
105105
}

0 commit comments

Comments
 (0)