Skip to content

Replace all uses of move_to_operands #3691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions jbmc/src/java_bytecode/character_refine_preprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1191,9 +1191,8 @@ exprt character_refine_preprocesst::expr_of_to_chars(
array_exprt case2(array_type);
exprt low_surrogate=expr_of_low_surrogate(chr, char_type);
case1.copy_to_operands(low_surrogate);
case2.move_to_operands(low_surrogate);
exprt high_surrogate=expr_of_high_surrogate(chr, char_type);
case2.move_to_operands(high_surrogate);
case2.add_to_operands(
std::move(low_surrogate), expr_of_high_surrogate(chr, char_type));
return if_exprt(expr_of_is_bmp_code_point(chr, type), case1, case2);
}

Expand Down
5 changes: 2 additions & 3 deletions jbmc/src/java_bytecode/java_bytecode_convert_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,9 +879,8 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
// TODO use this instead of a loop.
codet array_copy;
array_copy.set_statement(ID_array_copy);
array_copy.move_to_operands(new_data);
array_copy.move_to_operands(old_data);
clone_body.move_to_operands(array_copy);
array_copy.add_to_operands(std::move(new_data), std::move(old_data));
clone_body.add_to_operands(std::move(array_copy));
*/

// Begin for-loop to replace:
Expand Down
4 changes: 2 additions & 2 deletions jbmc/src/java_bytecode/java_string_literals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ symbol_exprt get_or_create_string_literal_symbol(
// _return_value global for its side-effects.
exprt init_comma_expr(ID_comma);
init_comma_expr.type() = literal_init.type();
init_comma_expr.copy_to_operands(return_symbol.symbol_expr());
init_comma_expr.move_to_operands(literal_init);
init_comma_expr.add_to_operands(
return_symbol.symbol_expr(), std::move(literal_init));
new_symbol.value = init_comma_expr;
}
else if(jls_struct.components().size()>=1 &&
Expand Down
4 changes: 2 additions & 2 deletions jbmc/unit/util/expr_iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ SCENARIO("depth_iterator_mutate_root", "[core][utils][depth_iterator]")
exprt test_root;
// This is the expression we might mutate when we find it
exprt test_operand(ID_1);
test_root.move_to_operands(test_operand);
test_expr.move_to_operands(test_root);
test_root.add_to_operands(std::move(test_operand));
test_expr.add_to_operands(std::move(test_root));
WHEN("Iteration occurs without mutation")
{
// Create shared copies
Expand Down
5 changes: 1 addition & 4 deletions src/analyses/goto_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1413,10 +1413,7 @@ void goto_checkt::add_guarded_claim(
if(guard.is_true())
new_expr.swap(expr);
else
{
new_expr=exprt(ID_implies, bool_typet());
new_expr.add_to_operands(guard.as_expr(), std::move(expr));
}
new_expr = implies_exprt(guard.as_expr(), std::move(expr));

if(assertions.insert(new_expr).second)
{
Expand Down
4 changes: 2 additions & 2 deletions src/ansi-c/c_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ void c_typecheck_baset::typecheck_side_effect_statement_expression(
{
side_effect_exprt assign(
ID_assign, sideeffect.type(), fc.source_location());
assign.move_to_operands(fc.lhs(), sideeffect);
assign.add_to_operands(fc.lhs(), std::move(sideeffect));

code_expressiont code_expr(assign);
code_expr.add_source_location() = fc.source_location();
Expand Down Expand Up @@ -1302,7 +1302,7 @@ void c_typecheck_baset::typecheck_expr_index(exprt &expr)
typecheck_arithmetic_pointer(expr.op0());
exprt addition(ID_plus, array_expr.type());
addition.operands().swap(expr.operands());
expr.move_to_operands(addition);
expr.add_to_operands(std::move(addition));
expr.id(ID_dereference);
expr.set(ID_C_lvalue, true);
expr.type() = final_array_type.subtype();
Expand Down
19 changes: 9 additions & 10 deletions src/ansi-c/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,7 @@ offsetof_member_designator:
{
$$=$1;
set($2, ID_index);
exprt tmp=convert_integer_literal("0");
stack($2).move_to_operands(tmp);
stack($2).add_to_operands(convert_integer_literal("0"));
mto($$, $2);
set($2, ID_member);
stack($2).set(ID_component_name, stack($3).get(ID_C_base_name));
Expand Down Expand Up @@ -574,7 +573,7 @@ postfix_expression:
tmp.operands().swap(stack($5).operands());
$$=$1;
set($$, ID_typecast);
stack($$).move_to_operands(tmp);
stack($$).add_to_operands(std::move(tmp));
stack($$).type().swap(stack($2));
}
| '(' type_name ')' '{' initializer_list ',' '}'
Expand All @@ -585,7 +584,7 @@ postfix_expression:
tmp.operands().swap(stack($5).operands());
$$=$1;
set($$, ID_typecast);
stack($$).move_to_operands(tmp);
stack($$).add_to_operands(std::move(tmp));
stack($$).type().swap(stack($2));
}
;
Expand Down Expand Up @@ -2080,7 +2079,7 @@ initializer_list:
exprt tmp;
tmp.swap(stack($$));
stack($$).clear();
stack($$).move_to_operands(tmp);
stack($$).add_to_operands(std::move(tmp));
}
| initializer_list ',' designated_initializer
{
Expand Down Expand Up @@ -2123,7 +2122,7 @@ designated_initializer:
exprt designator;
exprt member(ID_member);
member.set(ID_component_name, stack($1).get(ID_C_base_name));
designator.move_to_operands(member);
designator.add_to_operands(std::move(member));
stack($$).add(ID_designator).swap(designator);
mto($$, $3);
}
Expand Down Expand Up @@ -2638,14 +2637,14 @@ gcc_asm_output:
{
$$=$2;
stack($$).id(ID_gcc_asm_output);
stack($$).move_to_operands(stack($1), stack($3));
stack($$).add_to_operands(std::move(stack($1)), std::move(stack($3)));
}
| '[' identifier_or_typedef_name ']'
string '(' comma_expression ')'
{
$$=$5;
stack($$).id(ID_gcc_asm_output);
stack($$).move_to_operands(stack($4), stack($6));
stack($$).add_to_operands(std::move(stack($4)), std::move(stack($6)));
}
;

Expand Down Expand Up @@ -2675,14 +2674,14 @@ gcc_asm_input:
{
$$=$2;
stack($$).id(ID_gcc_asm_input);
stack($$).move_to_operands(stack($1), stack($3));
stack($$).add_to_operands(std::move(stack($1)), std::move(stack($3)));
}
| '[' identifier_or_typedef_name ']'
string '(' comma_expression ')'
{
$$=$5;
stack($$).id(ID_gcc_asm_input);
stack($$).move_to_operands(stack($4), stack($6));
stack($$).add_to_operands(std::move(stack($4)), std::move(stack($6)));
}
;

Expand Down
2 changes: 1 addition & 1 deletion src/ansi-c/parser_static.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#define YYSTYPE unsigned
#define YYSTYPE_IS_TRIVIAL 1

#define mto(x, y) stack(x).move_to_operands(stack(y))
#define mto(x, y) stack(x).add_to_operands(std::move(stack(y)))
#define mts(x, y) (to_type_with_subtypes(stack_type(x)).move_to_subtypes(stack_type(y)))
#define binary(x, y, l, id, z) { init(x, id); \
stack(x).add_source_location()=stack(l).source_location(); \
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/cpp_constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ optionalt<codet> cpp_typecheckt::cpp_constructor(
val=true_exprt();

side_effect_exprt assign(ID_assign, typet(), source_location);
assign.move_to_operands(member, val);
assign.add_to_operands(std::move(member), std::move(val));
typecheck_side_effect_assignment(assign);
block.add(code_expressiont(std::move(assign)));
}
Expand Down Expand Up @@ -285,7 +285,7 @@ void cpp_typecheckt::new_temporary(
if(new_code.has_value())
{
if(new_code->get_statement() == ID_assign)
tmp_object_expr.move_to_operands(new_code->op1());
tmp_object_expr.add_to_operands(std::move(new_code->op1()));
else
tmp_object_expr.add(ID_initializer) = *new_code;
}
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_destructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ optionalt<codet> cpp_typecheckt::cpp_destructor(

auto i_code = cpp_destructor(source_location, index);
if(i_code.has_value())
new_code.move_to_operands(i_code.value());
new_code.add_to_operands(std::move(i_code.value()));
}
}
else
Expand Down
2 changes: 0 additions & 2 deletions src/cpp/cpp_typecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,6 @@ void cpp_typecheckt::static_and_dynamic_initialization()

dynamic_initializations.clear();

// block_sini.move_to_operands(block_dini);

// Create the dynamic initialization procedure
symbolt init_symbol;

Expand Down
4 changes: 2 additions & 2 deletions src/cpp/cpp_typecheck_code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ void cpp_typecheckt::typecheck_decl(codet &code)
"declarator type should match symbol type");
}

new_code.move_to_operands(decl_statement);
new_code.add_to_operands(std::move(decl_statement));

// is there a constructor to be called?
if(symbol.value.is_not_nil())
Expand All @@ -439,7 +439,7 @@ void cpp_typecheckt::typecheck_decl(codet &code)
symbol.location, object_expr, declarator.init_args().operands());

if(constructor_call.has_value())
new_code.move_to_operands(constructor_call.value());
new_code.add_to_operands(std::move(constructor_call.value()));
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/cpp/cpp_typecheck_compound_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -668,14 +668,14 @@ void cpp_typecheckt::typecheck_compound_declarator(
{
expr_call.type()=to_code_type(component.type()).return_type();
exprt already_typechecked(ID_already_typechecked);
already_typechecked.move_to_operands(expr_call);
already_typechecked.add_to_operands(std::move(expr_call));

func_symb.value = code_returnt(already_typechecked).make_block();
}
else
{
exprt already_typechecked(ID_already_typechecked);
already_typechecked.move_to_operands(expr_call);
already_typechecked.add_to_operands(std::move(expr_call));

func_symb.value = code_expressiont(already_typechecked).make_block();
}
Expand Down Expand Up @@ -1103,12 +1103,12 @@ void cpp_typecheckt::typecheck_compound_body(symbolt &symbol)
{
// it's public!
exprt cpp_public("cpp-public");
body.move_to_operands(cpp_public);
body.add_to_operands(std::move(cpp_public));

// build declaration
cpp_declarationt ctor;
default_ctor(symbol.type.source_location(), symbol.base_name, ctor);
body.move_to_operands(ctor);
body.add_to_operands(std::move(ctor));
}

// Reset the access type
Expand Down
31 changes: 11 additions & 20 deletions src/cpp/cpp_typecheck_constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void cpp_typecheckt::default_ctor(

ctor.type().id(ID_constructor);
ctor.add(ID_storage_spec).id(ID_cpp_storage_spec);
ctor.move_to_operands(decl);
ctor.add_to_operands(std::move(decl));
ctor.add_source_location()=source_location;
}

Expand Down Expand Up @@ -178,7 +178,7 @@ void cpp_typecheckt::default_cpctor(
sub.push_back(cppcomp.as_type());
irept constnd(ID_const);
sub.push_back(static_cast<const typet &>(constnd));
parameter_decl.move_to_operands(parameter_tor);
parameter_decl.add_to_operands(std::move(parameter_tor));
parameter_decl.add_source_location()=source_location;

// Add parameter to function type
Expand Down Expand Up @@ -271,7 +271,7 @@ void cpp_typecheckt::default_cpctor(
if(mem_c.type().id() == ID_array)
memberexpr.set(ID_C_array_ini, true);

mem_init.move_to_operands(memberexpr);
mem_init.add_to_operands(std::move(memberexpr));
initializers.move_to_sub(mem_init);
}
}
Expand Down Expand Up @@ -568,12 +568,6 @@ void cpp_typecheckt::full_member_initialization(

if(!vbases.empty())
{
// TODO(tautschnig): this code doesn't seem to make much sense as the
// ifthenelse only gets to have two operands (instead of three)
codet cond(ID_ifthenelse);

cond.copy_to_operands(cpp_namet("@most_derived").as_expr());

code_blockt block;

while(!vbases.empty())
Expand All @@ -590,7 +584,9 @@ void cpp_typecheckt::full_member_initialization(
}
vbases.pop_front();
}
cond.move_to_operands(block);

code_ifthenelset cond(
cpp_namet("@most_derived").as_expr(), std::move(block));
final_initializers.move_to_sub(cond);
}

Expand Down Expand Up @@ -671,18 +667,13 @@ void cpp_typecheckt::full_member_initialization(

if(b.get_bool(ID_virtual))
{
// TODO(tautschnig): this code doesn't seem to make much sense as the
// ifthenelse only gets to have two operands (instead of three)
codet cond(ID_ifthenelse);
codet tmp(ID_member_initializer);
tmp.swap(final_initializers.get_sub().back());

cond.copy_to_operands(cpp_namet("@most_derived").as_expr());
code_ifthenelset cond(
cpp_namet("@most_derived").as_expr(), std::move(tmp));

{
codet tmp(ID_member_initializer);
tmp.swap(final_initializers.get_sub().back());
cond.move_to_operands(tmp);
final_initializers.get_sub().back().swap(cond);
}
final_initializers.get_sub().back().swap(cond);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subtil!

}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_typecheck_conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,7 @@ bool cpp_typecheckt::reference_binding(
tmp.set(ID_statement, ID_temporary_object);
tmp.add_source_location()=expr.source_location();
// tmp.set(ID_C_lvalue, true);
tmp.move_to_operands(new_expr);
tmp.add_to_operands(std::move(new_expr));
new_expr.swap(tmp);
}

Expand Down
4 changes: 1 addition & 3 deletions src/cpp/cpp_typecheck_declaration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ void cpp_typecheckt::convert_anonymous_union(
throw 0;
}

code_declt decl_statement(cpp_symbol_expr(symbol));

new_code.move_to_operands(decl_statement);
new_code.add_to_operands(code_declt(cpp_symbol_expr(symbol)));

// do scoping
symbolt union_symbol=
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/cpp_typecheck_destructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void cpp_typecheckt::default_dtor(

dtor.add(ID_type).id(ID_destructor);
dtor.add(ID_storage_spec).id(ID_cpp_storage_spec);
dtor.move_to_operands(decl);
dtor.add_to_operands(std::move(decl));
}

/// produces destructor code for a class object
Expand Down
Loading