Skip to content

Commit 3c77ddf

Browse files
authored
Merge pull request #6381 from diffblue/cleanup_goto_program_api
remove 8 deprecated goto-program API methods
2 parents a76195a + e5dc989 commit 3c77ddf

28 files changed

+136
-232
lines changed

jbmc/src/java_bytecode/replace_java_nondet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static bool is_assignment_from(
145145
{
146146
return false;
147147
}
148-
const auto &rhs = instr.get_assign().rhs();
148+
const auto &rhs = instr.assign_rhs();
149149
return is_symbol_with_id(rhs, identifier) ||
150150
is_typecast_with_id(rhs, identifier);
151151
}
@@ -223,7 +223,7 @@ static goto_programt::targett check_and_replace_target(
223223
"either have a variable for the return value in its lhs() or the next "
224224
"instruction should be an assignment of the return value to a temporary "
225225
"variable");
226-
const exprt &return_value_assignment = next_instr->get_assign().lhs();
226+
const exprt &return_value_assignment = next_instr->assign_lhs();
227227

228228
// If the assignment is null, return.
229229
if(
@@ -285,7 +285,7 @@ static goto_programt::targett check_and_replace_target(
285285
else if(target_instruction->is_assign())
286286
{
287287
// Assume that the LHS of *this* assignment is the actual nondet variable
288-
const auto &nondet_var = target_instruction->get_assign().lhs();
288+
const auto &nondet_var = target_instruction->assign_lhs();
289289

290290
side_effect_expr_nondett inserted_expr(
291291
nondet_var.type(), target_instruction->source_location);

jbmc/unit/java_bytecode/java_replace_nondet/replace_nondet.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ void validate_nondet_method_removed(
3434
// Check that our NONDET(<type>) exists on a rhs somewhere.
3535
if(inst.is_assign())
3636
{
37-
const code_assignt &assignment = inst.get_assign();
38-
if(assignment.rhs().id() == ID_side_effect)
37+
const exprt &assignment_rhs = inst.assign_rhs();
38+
if(assignment_rhs.id() == ID_side_effect)
3939
{
40-
const side_effect_exprt &see = to_side_effect_expr(assignment.rhs());
40+
const side_effect_exprt &see = to_side_effect_expr(assignment_rhs);
4141
if(see.get_statement() == ID_nondet)
4242
{
4343
replacement_nondet_exists = true;
@@ -92,7 +92,7 @@ void validate_nondets_converted(
9292
// Check that our NONDET(<type>) exists on a rhs somewhere.
9393
exprt target_expression =
9494
(inst.is_assign()
95-
? inst.get_assign().rhs()
95+
? inst.assign_rhs()
9696
: inst.is_set_return_value() ? inst.return_value() : inst.get_code());
9797

9898
if(

src/analyses/custom_bitvector_analysis.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,8 @@ void custom_bitvector_domaint::transform(
286286
switch(instruction.type)
287287
{
288288
case ASSIGN:
289-
{
290-
const code_assignt &code_assign = instruction.get_assign();
291-
assign_struct_rec(from, code_assign.lhs(), code_assign.rhs(), cba, ns);
292-
}
289+
assign_struct_rec(
290+
from, instruction.assign_lhs(), instruction.assign_rhs(), cba, ns);
293291
break;
294292

295293
case DECL:

src/analyses/does_remove_const.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,19 @@ std::pair<bool, source_locationt> does_remove_constt::operator()() const
3939
continue;
4040
}
4141

42-
const code_assignt &assign = instruction.get_assign();
43-
const typet &rhs_type=assign.rhs().type();
44-
const typet &lhs_type=assign.lhs().type();
42+
const typet &rhs_type = instruction.assign_rhs().type();
43+
const typet &lhs_type = instruction.assign_lhs().type();
4544

4645
// Compare the types recursively for a point where the rhs is more
4746
// const that the lhs
4847
if(!does_type_preserve_const_correctness(&lhs_type, &rhs_type))
4948
{
50-
return {true, assign.find_source_location()};
49+
return {true, instruction.source_location};
5150
}
5251

53-
if(does_expr_lose_const(assign.rhs()))
52+
if(does_expr_lose_const(instruction.assign_rhs()))
5453
{
55-
return {true, assign.rhs().find_source_location()};
54+
return {true, instruction.assign_rhs().find_source_location()};
5655
}
5756
}
5857

src/analyses/escape_analysis.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,16 @@ void escape_domaint::transform(
188188
{
189189
case ASSIGN:
190190
{
191-
const code_assignt &code_assign = instruction.get_assign();
191+
const exprt &assign_lhs = instruction.assign_lhs();
192+
const exprt &assign_rhs = instruction.assign_rhs();
192193

193194
std::set<irep_idt> cleanup_functions;
194-
get_rhs_cleanup(code_assign.rhs(), cleanup_functions);
195-
assign_lhs_cleanup(code_assign.lhs(), cleanup_functions);
195+
get_rhs_cleanup(assign_rhs, cleanup_functions);
196+
assign_lhs_cleanup(assign_lhs, cleanup_functions);
196197

197198
std::set<irep_idt> rhs_aliases;
198-
get_rhs_aliases(code_assign.rhs(), rhs_aliases);
199-
assign_lhs_aliases(code_assign.lhs(), rhs_aliases);
199+
get_rhs_aliases(assign_rhs, rhs_aliases);
200+
assign_lhs_aliases(assign_lhs, rhs_aliases);
200201
}
201202
break;
202203

@@ -461,17 +462,12 @@ void escape_analysist::instrument(
461462

462463
if(instruction.type == ASSIGN)
463464
{
464-
const code_assignt &code_assign = instruction.get_assign();
465+
const exprt &assign_lhs = instruction.assign_lhs();
465466

466467
std::set<irep_idt> cleanup_functions;
467-
operator[](i_it).check_lhs(code_assign.lhs(), cleanup_functions);
468+
operator[](i_it).check_lhs(assign_lhs, cleanup_functions);
468469
insert_cleanup(
469-
gf_entry.second,
470-
i_it,
471-
code_assign.lhs(),
472-
cleanup_functions,
473-
false,
474-
ns);
470+
gf_entry.second, i_it, assign_lhs, cleanup_functions, false, ns);
475471
}
476472
else if(instruction.type == DEAD)
477473
{

src/analyses/global_may_alias.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,9 @@ void global_may_alias_domaint::transform(
111111
{
112112
case ASSIGN:
113113
{
114-
const code_assignt &code_assign = instruction.get_assign();
115-
116114
std::set<irep_idt> rhs_aliases;
117-
get_rhs_aliases(code_assign.rhs(), rhs_aliases);
118-
assign_lhs_aliases(code_assign.lhs(), rhs_aliases);
115+
get_rhs_aliases(instruction.assign_rhs(), rhs_aliases);
116+
assign_lhs_aliases(instruction.assign_lhs(), rhs_aliases);
119117
break;
120118
}
121119

src/analyses/goto_check.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,33 +1982,30 @@ void goto_checkt::goto_check(
19821982
}
19831983
else if(i.is_assign())
19841984
{
1985-
const code_assignt &code_assign = i.get_assign();
1985+
const exprt &assign_lhs = i.assign_lhs();
1986+
const exprt &assign_rhs = i.assign_rhs();
19861987

19871988
// Reset the no_enum_check with the flag reset for exception
19881989
// safety
19891990
{
19901991
flag_resett no_enum_check_flag_resetter;
19911992
no_enum_check_flag_resetter.set_flag(no_enum_check, true);
1992-
check(code_assign.lhs());
1993+
check(assign_lhs);
19931994
}
1994-
check(code_assign.rhs());
1995+
1996+
check(assign_rhs);
19951997

19961998
// the LHS might invalidate any assertion
1997-
invalidate(code_assign.lhs());
1999+
invalidate(assign_lhs);
19982000

1999-
if(has_subexpr(code_assign.rhs(), [](const exprt &expr) {
2001+
if(has_subexpr(assign_rhs, [](const exprt &expr) {
20002002
return expr.id() == ID_r_ok || expr.id() == ID_w_ok ||
20012003
expr.id() == ID_rw_ok;
20022004
}))
20032005
{
2004-
const exprt &rhs = i.get_assign().rhs();
2005-
auto rw_ok_cond = rw_ok_check(rhs);
2006+
auto rw_ok_cond = rw_ok_check(assign_rhs);
20062007
if(rw_ok_cond.has_value())
2007-
{
2008-
auto new_assign = i.get_assign(); // copy
2009-
new_assign.rhs() = *rw_ok_cond;
2010-
i.set_assign(new_assign);
2011-
}
2008+
i.assign_rhs_nonconst() = *rw_ok_cond;
20122009
}
20132010
}
20142011
else if(i.is_function_call())

src/analyses/goto_rw.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -717,16 +717,16 @@ void rw_guarded_range_set_value_sett::add(
717717
{range_start, {range_end, guard.as_expr()}});
718718
}
719719

720-
static void goto_rw(
720+
static void goto_rw_assign(
721721
const irep_idt &function,
722722
goto_programt::const_targett target,
723-
const code_assignt &assign,
723+
const exprt &lhs,
724+
const exprt &rhs,
724725
rw_range_sett &rw_set)
725726
{
726727
rw_set.get_objects_rec(
727-
function, target, rw_range_sett::get_modet::LHS_W, assign.lhs());
728-
rw_set.get_objects_rec(
729-
function, target, rw_range_sett::get_modet::READ, assign.rhs());
728+
function, target, rw_range_sett::get_modet::LHS_W, lhs);
729+
rw_set.get_objects_rec(function, target, rw_range_sett::get_modet::READ, rhs);
730730
}
731731

732732
static void goto_rw(
@@ -801,7 +801,8 @@ void goto_rw(
801801
break;
802802

803803
case ASSIGN:
804-
goto_rw(function, target, target->get_assign(), rw_set);
804+
goto_rw_assign(
805+
function, target, target->assign_lhs(), target->assign_rhs(), rw_set);
805806
break;
806807

807808
case DEAD:

src/analyses/interval_domain.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void interval_domaint::transform(
7979
break;
8080

8181
case ASSIGN:
82-
assign(instruction.get_assign());
82+
assign(instruction.assign_lhs(), instruction.assign_rhs());
8383
break;
8484

8585
case GOTO:
@@ -208,10 +208,10 @@ bool interval_domaint::join(
208208
return result;
209209
}
210210

211-
void interval_domaint::assign(const code_assignt &code_assign)
211+
void interval_domaint::assign(const exprt &lhs, const exprt &rhs)
212212
{
213-
havoc_rec(code_assign.lhs());
214-
assume_rec(code_assign.lhs(), ID_equal, code_assign.rhs());
213+
havoc_rec(lhs);
214+
assume_rec(lhs, ID_equal, rhs);
215215
}
216216

217217
void interval_domaint::havoc_rec(const exprt &lhs)

src/analyses/interval_domain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class interval_domaint:public ai_domain_baset
120120
void havoc_rec(const exprt &);
121121
void assume_rec(const exprt &, bool negation=false);
122122
void assume_rec(const exprt &lhs, irep_idt id, const exprt &rhs);
123-
void assign(const class code_assignt &assignment);
123+
void assign(const exprt &lhs, const exprt &rhs);
124124
integer_intervalt get_int_rec(const exprt &);
125125
ieee_float_intervalt get_float_rec(const exprt &);
126126
};

src/analyses/invariant_set_domain.cpp

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -55,44 +55,41 @@ void invariant_set_domaint::transform(
5555
break;
5656

5757
case ASSIGN:
58-
{
59-
const code_assignt &assignment = from_l->get_assign();
60-
invariant_set.assignment(assignment.lhs(), assignment.rhs());
61-
}
62-
break;
58+
invariant_set.assignment(from_l->assign_lhs(), from_l->assign_rhs());
59+
break;
6360

64-
case OTHER:
65-
if(from_l->get_other().is_not_nil())
66-
invariant_set.apply_code(from_l->get_code());
67-
break;
61+
case OTHER:
62+
if(from_l->get_other().is_not_nil())
63+
invariant_set.apply_code(from_l->get_code());
64+
break;
6865

69-
case DECL:
70-
invariant_set.apply_code(from_l->get_code());
71-
break;
66+
case DECL:
67+
invariant_set.apply_code(from_l->get_code());
68+
break;
7269

73-
case FUNCTION_CALL:
74-
invariant_set.apply_code(from_l->get_code());
75-
break;
70+
case FUNCTION_CALL:
71+
invariant_set.apply_code(from_l->get_code());
72+
break;
7673

77-
case START_THREAD:
78-
invariant_set.make_threaded();
79-
break;
74+
case START_THREAD:
75+
invariant_set.make_threaded();
76+
break;
8077

81-
case CATCH:
82-
case THROW:
83-
DATA_INVARIANT(false, "Exceptions must be removed before analysis");
84-
break;
85-
case DEAD: // No action required
86-
case ATOMIC_BEGIN: // Ignoring is a valid over-approximation
87-
case ATOMIC_END: // Ignoring is a valid over-approximation
88-
case END_FUNCTION: // No action required
89-
case LOCATION: // No action required
90-
case END_THREAD: // Require a concurrent analysis at higher level
91-
case SKIP: // No action required
92-
break;
93-
case INCOMPLETE_GOTO:
94-
case NO_INSTRUCTION_TYPE:
95-
DATA_INVARIANT(false, "Only complete instructions can be analyzed");
96-
break;
78+
case CATCH:
79+
case THROW:
80+
DATA_INVARIANT(false, "Exceptions must be removed before analysis");
81+
break;
82+
case DEAD: // No action required
83+
case ATOMIC_BEGIN: // Ignoring is a valid over-approximation
84+
case ATOMIC_END: // Ignoring is a valid over-approximation
85+
case END_FUNCTION: // No action required
86+
case LOCATION: // No action required
87+
case END_THREAD: // Require a concurrent analysis at higher level
88+
case SKIP: // No action required
89+
break;
90+
case INCOMPLETE_GOTO:
91+
case NO_INSTRUCTION_TYPE:
92+
DATA_INVARIANT(false, "Only complete instructions can be analyzed");
93+
break;
9794
}
9895
}

src/analyses/local_bitvector_analysis.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,12 +269,12 @@ void local_bitvector_analysist::build()
269269
switch(instruction.type)
270270
{
271271
case ASSIGN:
272-
{
273-
const code_assignt &code_assign = instruction.get_assign();
274272
assign_lhs(
275-
code_assign.lhs(), code_assign.rhs(), loc_info_src, loc_info_dest);
273+
instruction.assign_lhs(),
274+
instruction.assign_rhs(),
275+
loc_info_src,
276+
loc_info_dest);
276277
break;
277-
}
278278

279279
case DECL:
280280
assign_lhs(

src/analyses/local_may_alias.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,11 @@ void local_may_aliast::build(const goto_functiont &goto_function)
375375
{
376376
case ASSIGN:
377377
{
378-
const code_assignt &code_assign = instruction.get_assign();
379378
assign_lhs(
380-
code_assign.lhs(), code_assign.rhs(), loc_info_src, loc_info_dest);
379+
instruction.assign_lhs(),
380+
instruction.assign_rhs(),
381+
loc_info_src,
382+
loc_info_dest);
381383
break;
382384
}
383385

src/analyses/variable-sensitivity/variable_sensitivity_dependence_graph.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,7 @@ void variable_sensitivity_dependence_domaint::data_dependencies(
140140
domain_data_deps.clear();
141141
if(to->is_assign())
142142
{
143-
const code_assignt &inst = to->get_assign();
144-
const exprt &rhs = inst.rhs();
143+
const exprt &rhs = to->assign_rhs();
145144

146145
// Handle return value of a 'no body' function
147146
if(rhs.id() == ID_side_effect)

src/analyses/variable-sensitivity/variable_sensitivity_domain.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ void variable_sensitivity_domaint::transform(
5959
case ASSIGN:
6060
{
6161
// TODO : check return values
62-
const code_assignt &inst = instruction.get_assign();
6362
abstract_object_pointert rhs =
64-
abstract_state.eval(inst.rhs(), ns)->write_location_context(from);
65-
abstract_state.assign(inst.lhs(), rhs, ns);
63+
abstract_state.eval(instruction.assign_rhs(), ns)
64+
->write_location_context(from);
65+
abstract_state.assign(instruction.assign_lhs(), rhs, ns);
6666
}
6767
break;
6868

0 commit comments

Comments
 (0)