Skip to content

Commit 9b549f4

Browse files
committed
introduce instructiont::dead_symbol()
This mirrors the change in #5861 by replacing the use of code_deadt by directly returning the symbol_exprt. The client code is simplified.
1 parent a4c81ef commit 9b549f4

16 files changed

+47
-70
lines changed

src/analyses/constant_propagator.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ void constant_propagator_domaint::transform(
191191
}
192192
else if(from->is_dead())
193193
{
194-
const auto &code_dead = from->get_dead();
195-
values.set_to_top(code_dead.symbol());
194+
values.set_to_top(from->dead_symbol());
196195
}
197196
else if(from->is_function_call())
198197
{

src/analyses/custom_bitvector_analysis.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,11 @@ void custom_bitvector_domaint::transform(
304304
break;
305305

306306
case DEAD:
307-
{
308-
const code_deadt &code_dead=to_code_dead(instruction.code);
309-
assign_lhs(code_dead.symbol(), vectorst());
307+
assign_lhs(instruction.dead_symbol(), vectorst());
310308

311-
// is it a pointer?
312-
if(code_dead.symbol().type().id()==ID_pointer)
313-
assign_lhs(dereference_exprt(code_dead.symbol()), vectorst());
314-
}
309+
// is it a pointer?
310+
if(instruction.dead_symbol().type().id() == ID_pointer)
311+
assign_lhs(dereference_exprt(instruction.dead_symbol()), vectorst());
315312
break;
316313

317314
case FUNCTION_CALL:

src/analyses/escape_analysis.cpp

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,8 @@ void escape_domaint::transform(
210210
break;
211211

212212
case DEAD:
213-
{
214-
const code_deadt &code_dead=to_code_dead(instruction.code);
215-
aliases.isolate(code_dead.get_identifier());
216-
assign_lhs_cleanup(code_dead.symbol(), std::set<irep_idt>());
217-
}
213+
aliases.isolate(instruction.dead_symbol().get_identifier());
214+
assign_lhs_cleanup(instruction.dead_symbol(), std::set<irep_idt>());
218215
break;
219216

220217
case FUNCTION_CALL:
@@ -487,14 +484,14 @@ void escape_analysist::instrument(
487484
}
488485
else if(instruction.type == DEAD)
489486
{
490-
const code_deadt &code_dead = to_code_dead(instruction.code);
487+
const auto &dead_symbol = instruction.dead_symbol();
491488

492489
std::set<irep_idt> cleanup_functions1;
493490

494491
const escape_domaint &d = operator[](i_it);
495492

496493
const escape_domaint::cleanup_mapt::const_iterator m_it =
497-
d.cleanup_map.find("&" + id2string(code_dead.get_identifier()));
494+
d.cleanup_map.find("&" + id2string(dead_symbol.get_identifier()));
498495

499496
// does it have a cleanup function for the object?
500497
if(m_it != d.cleanup_map.end())
@@ -506,22 +503,12 @@ void escape_analysist::instrument(
506503

507504
std::set<irep_idt> cleanup_functions2;
508505

509-
d.check_lhs(code_dead.symbol(), cleanup_functions2);
506+
d.check_lhs(dead_symbol, cleanup_functions2);
510507

511508
insert_cleanup(
512-
gf_entry.second,
513-
i_it,
514-
code_dead.symbol(),
515-
cleanup_functions1,
516-
true,
517-
ns);
509+
gf_entry.second, i_it, dead_symbol, cleanup_functions1, true, ns);
518510
insert_cleanup(
519-
gf_entry.second,
520-
i_it,
521-
code_dead.symbol(),
522-
cleanup_functions2,
523-
false,
524-
ns);
511+
gf_entry.second, i_it, dead_symbol, cleanup_functions2, false, ns);
525512

526513
for(const auto &c : cleanup_functions1)
527514
{

src/analyses/global_may_alias.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,8 @@ void global_may_alias_domaint::transform(
127127
}
128128

129129
case DEAD:
130-
{
131-
const code_deadt &code_dead = to_code_dead(instruction.code);
132-
aliases.isolate(code_dead.get_identifier());
130+
aliases.isolate(instruction.dead_symbol().get_identifier());
133131
break;
134-
}
135132

136133
case FUNCTION_CALL: // Probably safe
137134
case GOTO: // Ignoring the guard is a valid over-approximation

src/analyses/goto_rw.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -815,10 +815,7 @@ void goto_rw(
815815

816816
case DEAD:
817817
rw_set.get_objects_rec(
818-
function,
819-
target,
820-
rw_range_sett::get_modet::LHS_W,
821-
to_code_dead(target->code).symbol());
818+
function, target, rw_range_sett::get_modet::LHS_W, target->dead_symbol());
822819
break;
823820

824821
case DECL:

src/analyses/interval_domain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void interval_domaint::transform(
7575
break;
7676

7777
case DEAD:
78-
havoc_rec(to_code_dead(instruction.code).symbol());
78+
havoc_rec(instruction.dead_symbol());
7979
break;
8080

8181
case ASSIGN:

src/analyses/local_bitvector_analysis.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,15 +293,12 @@ void local_bitvector_analysist::build()
293293
}
294294

295295
case DEAD:
296-
{
297-
const code_deadt &code_dead = to_code_dead(instruction.code);
298296
assign_lhs(
299-
code_dead.symbol(),
297+
instruction.dead_symbol(),
300298
exprt(ID_uninitialized),
301299
loc_info_src,
302300
loc_info_dest);
303301
break;
304-
}
305302

306303
case FUNCTION_CALL:
307304
{

src/analyses/local_may_alias.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,9 @@ void local_may_aliast::build(const goto_functiont &goto_function)
390390
}
391391

392392
case DEAD:
393-
{
394-
const code_deadt &code_dead = to_code_dead(instruction.code);
395-
assign_lhs(code_dead.symbol(), nil_exprt(), loc_info_src, loc_info_dest);
393+
assign_lhs(
394+
instruction.dead_symbol(), nil_exprt(), loc_info_src, loc_info_dest);
396395
break;
397-
}
398396

399397
case FUNCTION_CALL:
400398
{

src/analyses/reaching_definitions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ void rd_range_domaint::transform_dead(
169169
const namespacet &,
170170
locationt from)
171171
{
172-
const irep_idt &identifier = to_code_dead(from->code).get_identifier();
172+
const irep_idt &identifier = from->dead_symbol().get_identifier();
173173

174174
valuest::iterator entry=values.find(identifier);
175175

src/analyses/variable-sensitivity/variable_sensitivity_domain.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,10 @@ void variable_sensitivity_domaint::transform(
5555
break;
5656

5757
case DEAD:
58-
{
5958
// Remove symbol from map, the only time this occurs now (keep TOP.)
6059
// It should be the case that DEAD only provides symbols for deletion.
61-
const exprt &expr = to_code_dead(instruction.code).symbol();
62-
if(expr.id() == ID_symbol)
63-
{
64-
abstract_state.erase(to_symbol_expr(expr));
65-
}
66-
}
67-
break;
60+
abstract_state.erase(instruction.dead_symbol());
61+
break;
6862

6963
case ASSIGN:
7064
{

0 commit comments

Comments
 (0)