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
{

src/goto-diff/change_impact.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ void full_slicert::operator()(
8484
}
8585
else if(instruction->is_dead())
8686
{
87-
const auto &s=to_code_dead(instruction->code).symbol();
87+
const auto &s=instruction->dead_symbol();
8888
decl_dead[s.get_identifier()].push(instruction_node_index);
8989
}
9090
}

src/goto-instrument/full_slicer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ void full_slicert::operator()(
290290
}
291291
else if(instruction->is_dead())
292292
{
293-
const auto &s = to_code_dead(instruction->code).symbol();
293+
const auto &s = instruction->dead_symbol();
294294
decl_dead[s.get_identifier()].push(instruction_node_index);
295295
}
296296
}

src/goto-instrument/goto_program2code.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void goto_program2codet::build_dead_map()
9494
{
9595
if(instruction.is_dead())
9696
{
97-
dead_map[instruction.get_dead().get_identifier()] =
97+
dead_map[instruction.dead_symbol().get_identifier()] =
9898
instruction.location_number;
9999
}
100100
}

src/goto-programs/goto_program.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -884,9 +884,9 @@ void goto_programt::instructiont::validate(
884884
source_location);
885885
DATA_CHECK_WITH_DIAGNOSTICS(
886886
vm,
887-
!ns.lookup(get_dead().get_identifier(), table_symbol),
887+
!ns.lookup(dead_symbol().get_identifier(), table_symbol),
888888
"removed symbols should be known",
889-
id2string(get_dead().get_identifier()),
889+
id2string(dead_symbol().get_identifier()),
890890
source_location);
891891
break;
892892
case FUNCTION_CALL:
@@ -966,13 +966,9 @@ void goto_programt::instructiont::transform(
966966

967967
case DEAD:
968968
{
969-
auto new_symbol = f(get_dead().symbol());
969+
auto new_symbol = f(dead_symbol());
970970
if(new_symbol.has_value())
971-
{
972-
auto new_dead = get_dead();
973-
new_dead.symbol() = to_symbol_expr(*new_symbol);
974-
set_dead(new_dead);
975-
}
971+
dead_symbol() = to_symbol_expr(*new_symbol);
976972
}
977973
break;
978974

@@ -1050,7 +1046,7 @@ void goto_programt::instructiont::apply(
10501046
break;
10511047

10521048
case DEAD:
1053-
f(get_dead().symbol());
1049+
f(dead_symbol());
10541050
break;
10551051

10561052
case FUNCTION_CALL:

src/goto-programs/goto_program.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Author: Daniel Kroening, [email protected]
1818
#include <sstream>
1919
#include <string>
2020

21+
#include <util/deprecate.h>
2122
#include <util/invariant.h>
2223
#include <util/namespace.h>
2324
#include <util/source_location.h>
@@ -218,13 +219,29 @@ class goto_programt
218219
}
219220

220221
/// Get the dead statement for DEAD
222+
DEPRECATED(SINCE(2021, 2, 24, "Use dead_symbol instead"))
221223
const code_deadt &get_dead() const
222224
{
223225
PRECONDITION(is_dead());
224226
return to_code_dead(code);
225227
}
226228

229+
/// Get the symbol for DEAD
230+
const symbol_exprt &dead_symbol() const
231+
{
232+
PRECONDITION(is_dead());
233+
return to_code_dead(code).symbol();
234+
}
235+
236+
/// Get the symbol for DEAD
237+
symbol_exprt &dead_symbol()
238+
{
239+
PRECONDITION(is_dead());
240+
return to_code_dead(code).symbol();
241+
}
242+
227243
/// Set the dead statement for DEAD
244+
DEPRECATED(SINCE(2021, 2, 24, "Use dead_symbol instead"))
228245
void set_dead(code_deadt c)
229246
{
230247
PRECONDITION(is_dead());

src/goto-symex/symex_dead.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ Author: Daniel Kroening, [email protected]
1919
void goto_symext::symex_dead(statet &state)
2020
{
2121
const goto_programt::instructiont &instruction=*state.source.pc;
22-
23-
const code_deadt &code = instruction.get_dead();
24-
symex_dead(state, code.symbol());
22+
symex_dead(state, instruction.dead_symbol());
2523
}
2624

2725
void goto_symext::symex_dead(statet &state, const symbol_exprt &symbol_expr)

0 commit comments

Comments
 (0)