Skip to content

Commit e3aa361

Browse files
karkhazPetr Bauch
authored and
Petr Bauch
committed
Wrap local vars in std::move (Clang 7 build fix)
This commit fixes diffblue#3238, a warning emitted by clang 7.0: ``` java_bytecode_convert_method.cpp:2924:10: error: local variable 'block' will be copied despite being returned by name [-Werror,-Wreturn-std-move] return block; ^~~~~ java_bytecode_convert_method.cpp:2924:10: note: call 'std::move' explicitly to avoid copying return block; ^~~~~ std::move(block) ``` The fix is to wrap all such returned local variables in a call to std::move().
1 parent c48226f commit e3aa361

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+119
-119
lines changed

jbmc/src/java_bytecode/character_refine_preprocess.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ exprt character_refine_preprocesst::expr_of_high_surrogate(
319319
exprt u400=from_integer(0x0400, type);
320320

321321
plus_exprt high_surrogate(uD800, div_exprt(minus_exprt(chr, u10000), u400));
322-
return high_surrogate;
322+
return std::move(high_surrogate);
323323
}
324324

325325
/// Converts function call to an assignment of an expression corresponding to
@@ -496,7 +496,7 @@ exprt character_refine_preprocesst::expr_of_is_digit(
496496
or_exprt digit(
497497
or_exprt(latin_digit, or_exprt(arabic_indic_digit, extended_digit)),
498498
or_exprt(devanagari_digit, fullwidth_digit));
499-
return digit;
499+
return std::move(digit);
500500
}
501501

502502
/// Converts function call to an assignment of an expression corresponding to
@@ -555,7 +555,7 @@ exprt character_refine_preprocesst::expr_of_is_identifier_ignorable(
555555
or_exprt(
556556
in_interval_expr(chr, 0x000E, 0x001B),
557557
in_interval_expr(chr, 0x007F, 0x009F)));
558-
return ignorable;
558+
return std::move(ignorable);
559559
}
560560

561561
/// Converts function call to an assignment of an expression corresponding to
@@ -1235,7 +1235,7 @@ exprt character_refine_preprocesst::expr_of_to_lower_case(
12351235
plus_exprt(chr, from_integer('a', type)), from_integer('A', type));
12361236

12371237
if_exprt res(expr_of_is_ascii_upper_case(chr, type), transformed, chr);
1238-
return res;
1238+
return std::move(res);
12391239
}
12401240

12411241
/// Converts function call to an assignment of an expression corresponding to
@@ -1291,7 +1291,7 @@ exprt character_refine_preprocesst::expr_of_to_title_case(
12911291
plus_9,
12921292
chr))));
12931293

1294-
return res;
1294+
return std::move(res);
12951295
}
12961296

12971297
/// Converts function call to an assignment of an expression corresponding to
@@ -1328,7 +1328,7 @@ exprt character_refine_preprocesst::expr_of_to_upper_case(
13281328
plus_exprt(chr, from_integer('A', type)), from_integer('a', type));
13291329

13301330
if_exprt res(expr_of_is_ascii_lower_case(chr, type), transformed, chr);
1331-
return res;
1331+
return std::move(res);
13321332
}
13331333

13341334
/// Converts function call to an assignment of an expression corresponding to

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ const exprt java_bytecode_convert_methodt::variable(
231231
symbol_exprt result(identifier, t);
232232
result.set(ID_C_base_name, base_name);
233233
used_local_names.insert(result);
234-
return result;
234+
return std::move(result);
235235
}
236236
else
237237
{
@@ -1913,7 +1913,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
19131913
for(auto &block : root_block.statements())
19141914
code.add(block);
19151915

1916-
return code;
1916+
return std::move(code);
19171917
}
19181918

19191919
codet java_bytecode_convert_methodt::convert_pop(
@@ -1983,7 +1983,7 @@ codet java_bytecode_convert_methodt::convert_switch(
19831983
}
19841984

19851985
code_switch.body() = code_block;
1986-
return code_switch;
1986+
return std::move(code_switch);
19871987
}
19881988

19891989
codet java_bytecode_convert_methodt::convert_monitorenterexit(
@@ -2006,7 +2006,7 @@ codet java_bytecode_convert_methodt::convert_monitorenterexit(
20062006
call.add_source_location() = source_location;
20072007
if(needed_lazy_methods && symbol_table.has_symbol(descriptor))
20082008
needed_lazy_methods->add_needed_method(descriptor);
2009-
return call;
2009+
return std::move(call);
20102010
}
20112011

20122012
void java_bytecode_convert_methodt::convert_dup2(
@@ -2566,7 +2566,7 @@ codet java_bytecode_convert_methodt::convert_putstatic(
25662566
bytecode_write_typet::STATIC_FIELD,
25672567
symbol_expr.get_identifier());
25682568
block.add(code_assignt(symbol_expr, op[0]));
2569-
return block;
2569+
return std::move(block);
25702570
}
25712571

25722572
codet java_bytecode_convert_methodt::convert_putfield(
@@ -2581,7 +2581,7 @@ codet java_bytecode_convert_methodt::convert_putfield(
25812581
bytecode_write_typet::FIELD,
25822582
arg0.get(ID_component_name));
25832583
block.add(code_assignt(to_member(op[0], arg0), op[1]));
2584-
return block;
2584+
return std::move(block);
25852585
}
25862586

25872587
void java_bytecode_convert_methodt::convert_getstatic(
@@ -2722,7 +2722,7 @@ codet java_bytecode_convert_methodt::convert_iinc(
27222722
plus_exprt(variable(arg0, 'i', address, CAST_AS_NEEDED), arg1_int_type));
27232723
block.add(code_assign);
27242724

2725-
return block;
2725+
return std::move(block);
27262726
}
27272727

27282728
codet java_bytecode_convert_methodt::convert_ifnull(
@@ -2740,7 +2740,7 @@ codet java_bytecode_convert_methodt::convert_ifnull(
27402740
code_branch.then_case().add_source_location() =
27412741
address_map.at(label_number).source->source_location;
27422742
code_branch.add_source_location() = location;
2743-
return code_branch;
2743+
return std::move(code_branch);
27442744
}
27452745

27462746
codet java_bytecode_convert_methodt::convert_ifnonull(
@@ -2758,7 +2758,7 @@ codet java_bytecode_convert_methodt::convert_ifnonull(
27582758
code_branch.then_case().add_source_location() =
27592759
address_map.at(label_number).source->source_location;
27602760
code_branch.add_source_location() = location;
2761-
return code_branch;
2761+
return std::move(code_branch);
27622762
}
27632763

27642764
codet java_bytecode_convert_methodt::convert_if(
@@ -2780,7 +2780,7 @@ codet java_bytecode_convert_methodt::convert_if(
27802780
code_branch.then_case().add_source_location().set_function(method_id);
27812781
code_branch.add_source_location() = location;
27822782
code_branch.add_source_location().set_function(method_id);
2783-
return code_branch;
2783+
return std::move(code_branch);
27842784
}
27852785

27862786
codet java_bytecode_convert_methodt::convert_if_cmp(
@@ -2809,7 +2809,7 @@ codet java_bytecode_convert_methodt::convert_if_cmp(
28092809
address_map.at(label_number).source->source_location;
28102810
code_branch.add_source_location() = location;
28112811

2812-
return code_branch;
2812+
return std::move(code_branch);
28132813
}
28142814

28152815
code_blockt java_bytecode_convert_methodt::convert_ret(
@@ -2889,7 +2889,7 @@ codet java_bytecode_convert_methodt::convert_store(
28892889
code_assignt assign(var, toassign);
28902890
assign.add_source_location() = location;
28912891
block.add(assign);
2892-
return block;
2892+
return std::move(block);
28932893
}
28942894

28952895
codet java_bytecode_convert_methodt::convert_astore(
@@ -2921,7 +2921,7 @@ codet java_bytecode_convert_methodt::convert_astore(
29212921
code_assignt array_put(element, op[2]);
29222922
array_put.add_source_location() = location;
29232923
block.add(array_put);
2924-
return block;
2924+
return std::move(block);
29252925
}
29262926

29272927
optionalt<exprt> java_bytecode_convert_methodt::convert_invoke_dynamic(

jbmc/src/java_bytecode/java_bytecode_instrument.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ codet java_bytecode_instrumentt::throw_exception(
133133
if_code.cond()=cond;
134134
if_code.then_case() = code_blockt({assign_new, code_expressiont(throw_expr)});
135135

136-
return if_code;
136+
return std::move(if_code);
137137
}
138138

139139

@@ -205,7 +205,7 @@ codet java_bytecode_instrumentt::check_array_access(
205205
bounds_checks.add(create_fatal_assertion(ge_zero, low_check_loc));
206206
bounds_checks.add(create_fatal_assertion(lt_length, high_check_loc));
207207

208-
return bounds_checks;
208+
return std::move(bounds_checks);
209209
}
210210

211211
/// Checks whether `class1` is an instance of `class2` and throws
@@ -255,7 +255,7 @@ codet java_bytecode_instrumentt::check_class_cast(
255255
notequal_exprt op_not_null(null_check_op, null_pointer_exprt(voidptr));
256256
conditional_check.cond()=std::move(op_not_null);
257257
conditional_check.then_case()=std::move(check_code);
258-
return conditional_check;
258+
return std::move(conditional_check);
259259
}
260260

261261
/// Checks whether `expr` is null and throws NullPointerException/
@@ -540,7 +540,7 @@ optionalt<codet> java_bytecode_instrumentt::instrument_expr(const exprt &expr)
540540
if(result==code_blockt())
541541
return {};
542542
else
543-
return result;
543+
return std::move(result);
544544
}
545545

546546
/// Instruments `expr`

jbmc/src/java_bytecode/java_bytecode_parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ exprt java_bytecode_parsert::get_relement_value()
15721572
{
15731573
values.operands().push_back(get_relement_value());
15741574
}
1575-
return values;
1575+
return std::move(values);
15761576
}
15771577

15781578
case 's':

jbmc/src/java_bytecode/java_static_initializers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ codet get_thread_safe_clinit_wrapper_body(
627627
function_body.add(code_returnt());
628628
}
629629

630-
return function_body;
630+
return std::move(function_body);
631631
}
632632

633633
/// Produces the static initializer wrapper body for the given function.
@@ -702,7 +702,7 @@ codet get_clinit_wrapper_body(
702702

703703
wrapper_body.then_case() = init_body;
704704

705-
return wrapper_body;
705+
return std::move(wrapper_body);
706706
}
707707

708708

@@ -891,5 +891,5 @@ codet stub_global_initializer_factoryt::get_stub_initializer_body(
891891
update_in_placet::NO_UPDATE_IN_PLACE);
892892
}
893893

894-
return static_init_body;
894+
return std::move(static_init_body);
895895
}

jbmc/src/java_bytecode/java_string_library_preprocess.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ codet java_string_library_preprocesst::make_float_to_string_code(
10391039

10401040
// Return str
10411041
code.add(code_returnt(str), loc);
1042-
return code;
1042+
return std::move(code);
10431043
}
10441044

10451045
/// Generate the goto code for string initialization.
@@ -1088,7 +1088,7 @@ codet java_string_library_preprocesst::make_init_function_from_call(
10881088
code_assign_string_expr_to_java_string(arg_this, string_expr, symbol_table),
10891089
loc);
10901090

1091-
return code;
1091+
return std::move(code);
10921092
}
10931093

10941094
/// Call a cprover internal function, assign the result to object `this` and
@@ -1114,7 +1114,7 @@ codet java_string_library_preprocesst::
11141114
loc);
11151115
const symbol_exprt arg_this(params[0].get_identifier(), params[0].type());
11161116
code.add(code_returnt(arg_this), loc);
1117-
return code;
1117+
return std::move(code);
11181118
}
11191119

11201120
/// Call a cprover internal function and assign the result to object `this`.
@@ -1266,7 +1266,7 @@ exprt java_string_library_preprocesst::get_object_at_index(
12661266
data_member, from_integer(index, java_int_type()), data_member.type());
12671267
dereference_exprt data_at_index(
12681268
data_pointer_plus_index, data_pointer_plus_index.type().subtype());
1269-
return data_at_index;
1269+
return std::move(data_at_index);
12701270
}
12711271

12721272
/// Helper for format function. Adds code:
@@ -1393,7 +1393,7 @@ exprt java_string_library_preprocesst::make_argument_for_format(
13931393
}
13941394

13951395
code.add(code_not_null, loc);
1396-
return arg_i_struct;
1396+
return std::move(arg_i_struct);
13971397
}
13981398

13991399
/// Used to provide code for the Java String.format function.
@@ -1451,7 +1451,7 @@ codet java_string_library_preprocesst::make_string_format_code(
14511451
java_string, string_expr, symbol_table),
14521452
loc);
14531453
code.add(code_returnt(java_string), loc);
1454-
return code;
1454+
return std::move(code);
14551455
}
14561456

14571457
/// Used to provide our own implementation of the java.lang.Object.getClass()
@@ -1532,7 +1532,7 @@ codet java_string_library_preprocesst::make_object_get_class_code(
15321532

15331533
// > return class1;
15341534
code.add(code_returnt(class1), loc);
1535-
return code;
1535+
return std::move(code);
15361536
}
15371537

15381538
/// Provide code for a function that calls a function from the solver and simply
@@ -1558,7 +1558,7 @@ codet java_string_library_preprocesst::make_function_from_call(
15581558
code_return_function_application(
15591559
function_name, args, type.return_type(), symbol_table),
15601560
loc);
1561-
return code;
1561+
return std::move(code);
15621562
}
15631563

15641564
/// Provide code for a function that calls a function from the solver and return
@@ -1600,7 +1600,7 @@ codet java_string_library_preprocesst::make_string_returning_function_from_call(
16001600

16011601
// Return value
16021602
code.add(code_returnt(str), loc);
1603-
return code;
1603+
return std::move(code);
16041604
}
16051605

16061606
/// Generates code for a function which copies a string object to a new string
@@ -1643,7 +1643,7 @@ codet java_string_library_preprocesst::make_copy_string_code(
16431643

16441644
// Return value
16451645
code.add(code_returnt(str), loc);
1646-
return code;
1646+
return std::move(code);
16471647
}
16481648

16491649
/// Generates code for a constructor of a string object from another string
@@ -1684,7 +1684,7 @@ codet java_string_library_preprocesst::make_copy_constructor_code(
16841684
code_assign_string_expr_to_java_string(arg_this, string_expr, symbol_table),
16851685
loc);
16861686

1687-
return code;
1687+
return std::move(code);
16881688
}
16891689

16901690
/// Generates code for the String.length method
@@ -1714,7 +1714,7 @@ codet java_string_library_preprocesst::make_string_length_code(
17141714
code_returnt ret(get_length(deref, symbol_table));
17151715
ret.add_source_location() = loc;
17161716

1717-
return ret;
1717+
return std::move(ret);
17181718
}
17191719

17201720
bool java_string_library_preprocesst::implements_function(

jbmc/src/java_bytecode/java_types.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ build_class_name(const std::string &src, const std::string &class_name_prefix)
415415
// Look for the next generic type info (if it exists)
416416
f_pos = src.find('<', e_pos + 1);
417417
} while(f_pos != std::string::npos);
418-
return result;
418+
return std::move(result);
419419
}
420420

421421
return java_reference_type(symbol_type);

src/analyses/ai.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ jsont ai_baset::output_json(
8282
}
8383
}
8484

85-
return result;
85+
return std::move(result);
8686
}
8787

8888
/// Output the domains for a single function as JSON
@@ -113,7 +113,7 @@ jsont ai_baset::output_json(
113113
contents.push_back(location);
114114
}
115115

116-
return contents;
116+
return std::move(contents);
117117
}
118118

119119
/// Output the domains for the whole program as XML

src/analyses/ai_domain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jsont ai_domain_baset::output_json(const ai_baset &ai, const namespacet &ns)
1919
std::ostringstream out;
2020
output(out, ai, ns);
2121
json_stringt json(out.str());
22-
return json;
22+
return std::move(json);
2323
}
2424

2525
xmlt ai_domain_baset::output_xml(const ai_baset &ai, const namespacet &ns) const

src/analyses/dependence_graph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ jsont dep_graph_domaint::output_json(
299299
link["type"]=json_stringt("data");
300300
}
301301

302-
return graph;
302+
return std::move(graph);
303303
}
304304

305305
void dependence_grapht::add_dep(

0 commit comments

Comments
 (0)