Skip to content

Commit 9e596c9

Browse files
Daniel Kroeningtautschnig
Daniel Kroening
authored andcommitted
use make_assignment(lhs, rhs)
This is slightly shorter.
1 parent c6dba6a commit 9e596c9

File tree

4 files changed

+33
-52
lines changed

4 files changed

+33
-52
lines changed

src/analyses/goto_check.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1852,7 +1852,7 @@ void goto_checkt::goto_check(
18521852
lhs);
18531853
goto_programt::targett t =
18541854
new_code.add(goto_programt::make_assignment(
1855-
code_assignt(std::move(lhs), std::move(rhs)), i.source_location));
1855+
std::move(lhs), std::move(rhs), i.source_location));
18561856
t->code.add_source_location()=i.source_location;
18571857
}
18581858
}
@@ -1867,8 +1867,7 @@ void goto_checkt::goto_check(
18671867
const symbol_exprt leak_expr=leak.symbol_expr();
18681868

18691869
// add self-assignment to get helpful counterexample output
1870-
new_code.add(
1871-
goto_programt::make_assignment(code_assignt(leak_expr, leak_expr)));
1870+
new_code.add(goto_programt::make_assignment(leak_expr, leak_expr));
18721871

18731872
source_locationt source_location;
18741873
source_location.set_function(function_identifier);

src/goto-instrument/dump_c.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ void dump_ct::cleanup_decl(
593593
tmp.add(goto_programt::make_decl(decl.symbol()));
594594

595595
if(value.is_not_nil())
596-
tmp.add(goto_programt::make_assignment(code_assignt(decl.op0(), value)));
596+
tmp.add(goto_programt::make_assignment(decl.symbol(), value));
597597

598598
tmp.add(goto_programt::make_end_function());
599599

src/goto-programs/string_abstraction.cpp

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,30 +1281,27 @@ goto_programt::targett string_abstractiont::value_assignments_string_struct(
12811281
goto_programt tmp;
12821282

12831283
{
1284-
goto_programt::targett assignment=tmp.add_instruction(ASSIGN);
1285-
assignment->code=code_assignt(
1286-
member(lhs, whatt::IS_ZERO),
1287-
member(rhs, whatt::IS_ZERO));
1284+
goto_programt::targett assignment = tmp.add(goto_programt::make_assignment(
1285+
member(lhs, whatt::IS_ZERO),
1286+
member(rhs, whatt::IS_ZERO),
1287+
target->source_location));
12881288
assignment->code.add_source_location()=target->source_location;
1289-
assignment->source_location=target->source_location;
12901289
}
12911290

12921291
{
1293-
goto_programt::targett assignment=tmp.add_instruction(ASSIGN);
1294-
assignment->code=code_assignt(
1295-
member(lhs, whatt::LENGTH),
1296-
member(rhs, whatt::LENGTH));
1292+
goto_programt::targett assignment = tmp.add(goto_programt::make_assignment(
1293+
member(lhs, whatt::LENGTH),
1294+
member(rhs, whatt::LENGTH),
1295+
target->source_location));
12971296
assignment->code.add_source_location()=target->source_location;
1298-
assignment->source_location=target->source_location;
12991297
}
13001298

13011299
{
1302-
goto_programt::targett assignment=tmp.add_instruction(ASSIGN);
1303-
assignment->code=code_assignt(
1304-
member(lhs, whatt::SIZE),
1305-
member(rhs, whatt::SIZE));
1300+
goto_programt::targett assignment = tmp.add(goto_programt::make_assignment(
1301+
member(lhs, whatt::SIZE),
1302+
member(rhs, whatt::SIZE),
1303+
target->source_location));
13061304
assignment->code.add_source_location()=target->source_location;
1307-
assignment->source_location=target->source_location;
13081305
}
13091306

13101307
goto_programt::targett last=target;

src/goto-programs/string_instrumentation.cpp

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,11 @@ void string_instrumentationt::do_sprintf(
296296

297297
if(call.lhs().is_not_nil())
298298
{
299-
goto_programt::targett return_assignment=tmp.add_instruction(ASSIGN);
300-
return_assignment->source_location=target->source_location;
301-
302299
exprt rhs =
303300
side_effect_expr_nondett(call.lhs().type(), target->source_location);
304301

305-
return_assignment->code=code_assignt(call.lhs(), rhs);
302+
tmp.add(
303+
goto_programt::make_assignment(call.lhs(), rhs, target->source_location));
306304
}
307305

308306
target->turn_into_skip();
@@ -337,13 +335,11 @@ void string_instrumentationt::do_snprintf(
337335

338336
if(call.lhs().is_not_nil())
339337
{
340-
goto_programt::targett return_assignment=tmp.add_instruction(ASSIGN);
341-
return_assignment->source_location=target->source_location;
342-
343338
exprt rhs =
344339
side_effect_expr_nondett(call.lhs().type(), target->source_location);
345340

346-
return_assignment->code=code_assignt(call.lhs(), rhs);
341+
tmp.add(
342+
goto_programt::make_assignment(call.lhs(), rhs, target->source_location));
347343
}
348344

349345
target->turn_into_skip();
@@ -369,13 +365,11 @@ void string_instrumentationt::do_fscanf(
369365

370366
if(call.lhs().is_not_nil())
371367
{
372-
goto_programt::targett return_assignment=tmp.add_instruction(ASSIGN);
373-
return_assignment->source_location=target->source_location;
374-
375368
exprt rhs =
376369
side_effect_expr_nondett(call.lhs().type(), target->source_location);
377370

378-
return_assignment->code=code_assignt(call.lhs(), rhs);
371+
tmp.add(
372+
goto_programt::make_assignment(call.lhs(), rhs, target->source_location));
379373
}
380374

381375
target->turn_into_skip();
@@ -560,14 +554,12 @@ void string_instrumentationt::do_format_string_write(
560554
const exprt &argument=arguments[argument_start_inx+args];
561555
const typet &arg_type = argument.type();
562556

563-
goto_programt::targett assignment=dest.add_instruction(ASSIGN);
564-
assignment->source_location=target->source_location;
565-
566557
const dereference_exprt lhs(argument, arg_type.subtype());
567558

568559
side_effect_expr_nondett rhs(lhs.type(), target->source_location);
569560

570-
assignment->code=code_assignt(lhs, rhs);
561+
dest.add(
562+
goto_programt::make_assignment(lhs, rhs, target->source_location));
571563

572564
args++;
573565
break;
@@ -602,14 +594,12 @@ void string_instrumentationt::do_format_string_write(
602594
}
603595
else
604596
{
605-
goto_programt::targett assignment=dest.add_instruction(ASSIGN);
606-
assignment->source_location=target->source_location;
607-
608597
dereference_exprt lhs(arguments[i], arg_type.subtype());
609598

610599
side_effect_expr_nondett rhs(lhs.type(), target->source_location);
611600

612-
assignment->code=code_assignt(lhs, rhs);
601+
dest.add(
602+
goto_programt::make_assignment(lhs, rhs, target->source_location));
613603
}
614604
}
615605
}
@@ -804,11 +794,8 @@ void string_instrumentationt::do_strerror(
804794
address_of_exprt ptr(index);
805795

806796
// make that zero-terminated
807-
{
808-
goto_programt::targett assignment2=tmp.add_instruction(ASSIGN);
809-
assignment2->code=code_assignt(is_zero_string(ptr, true), true_exprt());
810-
assignment2->source_location=it->source_location;
811-
}
797+
tmp.add(goto_programt::make_assignment(
798+
is_zero_string(ptr, true), true_exprt(), it->source_location));
812799

813800
// assign address
814801
{
@@ -851,23 +838,21 @@ void string_instrumentationt::invalidate_buffer(
851838
// create a loop that runs over the buffer
852839
// and invalidates every element
853840

854-
goto_programt::targett init=dest.add_instruction(ASSIGN);
855-
init->source_location=target->source_location;
856-
init->code=
857-
code_assignt(cntr_sym.symbol_expr(), from_integer(0, cntr_sym.type));
841+
dest.add(goto_programt::make_assignment(
842+
cntr_sym.symbol_expr(),
843+
from_integer(0, cntr_sym.type),
844+
target->source_location));
858845

859846
goto_programt::targett check=dest.add_instruction();
860847

861848
goto_programt::targett invalidate=dest.add_instruction(ASSIGN);
862849
invalidate->source_location=target->source_location;
863850

864-
goto_programt::targett increment=dest.add_instruction(ASSIGN);
865-
increment->source_location=target->source_location;
866-
867851
const plus_exprt plus(
868852
cntr_sym.symbol_expr(), from_integer(1, unsigned_int_type()));
869853

870-
increment->code=code_assignt(cntr_sym.symbol_expr(), plus);
854+
dest.add(goto_programt::make_assignment(
855+
cntr_sym.symbol_expr(), plus, target->source_location));
871856

872857
dest.add(
873858
goto_programt::make_goto(check, true_exprt(), target->source_location));

0 commit comments

Comments
 (0)