Skip to content

Commit 2f504f5

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

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

jbmc/src/java_bytecode/java_string_library_preprocess.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ 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> java_string_library_preprocesst::get_primitive_value_of_object(
11751175
const exprt &object,
11761176
irep_idt type_name,
11771177
const source_locationt &loc,
@@ -1222,7 +1222,7 @@ exprt java_string_library_preprocesst::get_primitive_value_of_object(
12221222
object_type=symbol_typet("java::java.lang.Double");
12231223
}
12241224
else if(type_name==ID_void)
1225-
return nil_exprt();
1225+
return optionalt<symbol_exprt>();
12261226
else
12271227
UNREACHABLE;
12281228

@@ -1251,14 +1251,14 @@ exprt java_string_library_preprocesst::get_primitive_value_of_object(
12511251
typecast_exprt(object, pointer_type), pointer_type.subtype());
12521252
member_exprt deref_value(deref, value_comp.get_name(), value_comp.type());
12531253
code.add(code_assignt(value, deref_value), loc);
1254-
return value;
1254+
return optionalt<symbol_exprt>(value);
12551255
}
12561256
}
12571257

12581258
warning() << object_type->get_identifier()
12591259
<< " not available to format function" << eom;
12601260
code.add(code_declt(value), loc);
1261-
return value;
1261+
return optionalt<symbol_exprt>(value);
12621262
}
12631263

12641264
/// Helper for format function. Returns the expression:
@@ -1398,9 +1398,12 @@ exprt java_string_library_preprocesst::make_argument_for_format(
13981398
}
13991399
else if(name==ID_int || name==ID_float || name==ID_char || name==ID_boolean)
14001400
{
1401-
exprt value=get_primitive_value_of_object(
1401+
optionalt<symbol_exprt> value=get_primitive_value_of_object(
14021402
arg_i, name, loc, symbol_table, code_not_null);
1403-
code_not_null.add(code_assignt(field_expr, value), loc);
1403+
if(value.has_value())
1404+
code_not_null.add(code_assignt(field_expr, *value), loc);
1405+
else
1406+
code_not_null.add(code_assignt(field_expr, nil_exprt()), loc);
14041407
}
14051408
else
14061409
{

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> // should get rid of this
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)