Skip to content

Commit 191c798

Browse files
author
Daniel Kroening
authored
Merge pull request #3265 from diffblue/code_dead_operand
code_deadt operand is now typed
2 parents a167783 + 93efb98 commit 191c798

File tree

8 files changed

+29
-32
lines changed

8 files changed

+29
-32
lines changed

jbmc/src/java_bytecode/remove_exceptions.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,19 @@ class remove_exceptionst
135135
goto_programt &goto_program,
136136
const goto_programt::targett &instr_it,
137137
const stack_catcht &stack_catch,
138-
const std::vector<exprt> &locals);
138+
const std::vector<symbol_exprt> &locals);
139139

140140
bool instrument_throw(
141141
goto_programt &goto_program,
142142
const goto_programt::targett &,
143143
const stack_catcht &,
144-
const std::vector<exprt> &);
144+
const std::vector<symbol_exprt> &);
145145

146146
bool instrument_function_call(
147147
goto_programt &goto_program,
148148
const goto_programt::targett &,
149149
const stack_catcht &,
150-
const std::vector<exprt> &);
150+
const std::vector<symbol_exprt> &);
151151

152152
void instrument_exceptions(
153153
goto_programt &goto_program);
@@ -308,7 +308,7 @@ void remove_exceptionst::add_exception_dispatch_sequence(
308308
goto_programt &goto_program,
309309
const goto_programt::targett &instr_it,
310310
const remove_exceptionst::stack_catcht &stack_catch,
311-
const std::vector<exprt> &locals)
311+
const std::vector<symbol_exprt> &locals)
312312
{
313313
// Jump to the universal handler or function end, as appropriate.
314314
// This will appear after the GOTO-based dynamic dispatch below
@@ -388,7 +388,7 @@ bool remove_exceptionst::instrument_throw(
388388
goto_programt &goto_program,
389389
const goto_programt::targett &instr_it,
390390
const remove_exceptionst::stack_catcht &stack_catch,
391-
const std::vector<exprt> &locals)
391+
const std::vector<symbol_exprt> &locals)
392392
{
393393
PRECONDITION(instr_it->type==THROW);
394394

@@ -419,7 +419,7 @@ bool remove_exceptionst::instrument_function_call(
419419
goto_programt &goto_program,
420420
const goto_programt::targett &instr_it,
421421
const stack_catcht &stack_catch,
422-
const std::vector<exprt> &locals)
422+
const std::vector<symbol_exprt> &locals)
423423
{
424424
PRECONDITION(instr_it->type==FUNCTION_CALL);
425425

@@ -473,8 +473,8 @@ void remove_exceptionst::instrument_exceptions(
473473
goto_programt &goto_program)
474474
{
475475
stack_catcht stack_catch; // stack of try-catch blocks
476-
std::vector<std::vector<exprt>> stack_locals; // stack of local vars
477-
std::vector<exprt> locals;
476+
std::vector<std::vector<symbol_exprt>> stack_locals; // stack of local vars
477+
std::vector<symbol_exprt> locals;
478478

479479
if(goto_program.empty())
480480
return;

src/analyses/constant_propagator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void constant_propagator_domaint::transform(
134134
else if(from->is_dead())
135135
{
136136
const code_deadt &code_dead=to_code_dead(from->code);
137-
values.set_to_top(to_symbol_expr(code_dead.symbol()));
137+
values.set_to_top(code_dead.symbol());
138138
}
139139
else if(from->is_function_call())
140140
{

src/analyses/reaching_definitions.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ void rd_range_domaint::transform_dead(
130130
const namespacet &,
131131
locationt from)
132132
{
133-
const irep_idt &identifier=
134-
to_symbol_expr(to_code_dead(from->code).symbol()).get_identifier();
133+
const irep_idt &identifier = to_code_dead(from->code).get_identifier();
135134

136135
valuest::iterator entry=values.find(identifier);
137136

src/goto-diff/change_impact.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ void full_slicert::operator()(
8585
}
8686
else if(e_it->first->is_dead())
8787
{
88-
const exprt &s=to_code_dead(e_it->first->code).symbol();
89-
decl_dead[to_symbol_expr(s).get_identifier()].push(e_it->second);
88+
const auto &s=to_code_dead(e_it->first->code).symbol();
89+
decl_dead[s.get_identifier()].push(e_it->second);
9090
}
9191
}
9292

src/goto-instrument/full_slicer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,8 @@ void full_slicert::operator()(
315315
}
316316
else if(e_it->first->is_dead())
317317
{
318-
const exprt &s=to_code_dead(e_it->first->code).symbol();
319-
decl_dead[to_symbol_expr(s).get_identifier()].push(e_it->second);
318+
const auto &s = to_code_dead(e_it->first->code).symbol();
319+
decl_dead[s.get_identifier()].push(e_it->second);
320320
}
321321
}
322322

src/goto-symex/symex_dead.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void goto_symext::symex_dead(statet &state)
2626
// We increase the L2 renaming to make these non-deterministic.
2727
// We also prevent propagation of old values.
2828

29-
ssa_exprt ssa(to_symbol_expr(code.symbol()));
29+
ssa_exprt ssa(code.symbol());
3030
state.rename(ssa, ns, goto_symex_statet::L1);
3131

3232
// in case of pointers, put something into the value set

src/util/std_code.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ Author: Daniel Kroening, [email protected]
1313

1414
#include "std_expr.h"
1515

16-
const irep_idt &code_deadt::get_identifier() const
17-
{
18-
return to_symbol_expr(symbol()).get_identifier();
19-
}
20-
2116
/// If this `codet` is a \ref code_blockt (i.e.\ it represents a block of
2217
/// statements), return the unmodified input. Otherwise (i.e.\ the `codet`
2318
/// represents a single statement), convert it to a \ref code_blockt with the

src/util/std_code.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -335,28 +335,25 @@ inline code_declt &to_code_decl(codet &code)
335335
class code_deadt:public codet
336336
{
337337
public:
338-
DEPRECATED("use code_deadt(symbol) instead")
339-
code_deadt():codet(ID_dead)
338+
explicit code_deadt(const symbol_exprt &symbol) : codet(ID_dead)
340339
{
341-
operands().resize(1);
340+
add_to_operands(symbol);
342341
}
343342

344-
explicit code_deadt(const exprt &symbol):codet(ID_dead)
343+
symbol_exprt &symbol()
345344
{
346-
copy_to_operands(symbol);
345+
return static_cast<symbol_exprt &>(op0());
347346
}
348347

349-
exprt &symbol()
348+
const symbol_exprt &symbol() const
350349
{
351-
return op0();
350+
return static_cast<const symbol_exprt &>(op0());
352351
}
353352

354-
const exprt &symbol() const
353+
const irep_idt &get_identifier() const
355354
{
356-
return op0();
355+
return symbol().get_identifier();
357356
}
358-
359-
const irep_idt &get_identifier() const;
360357
};
361358

362359
template<> inline bool can_cast_expr<code_deadt>(const exprt &base)
@@ -374,6 +371,9 @@ inline const code_deadt &to_code_dead(const codet &code)
374371
PRECONDITION(code.get_statement() == ID_dead);
375372
DATA_INVARIANT(
376373
code.operands().size() == 1, "dead statement must have one operand");
374+
DATA_INVARIANT(
375+
to_unary_expr(code).op().id() == ID_symbol,
376+
"dead statement must take symbol operand");
377377
return static_cast<const code_deadt &>(code);
378378
}
379379

@@ -382,6 +382,9 @@ inline code_deadt &to_code_dead(codet &code)
382382
PRECONDITION(code.get_statement() == ID_dead);
383383
DATA_INVARIANT(
384384
code.operands().size() == 1, "dead statement must have one operand");
385+
DATA_INVARIANT(
386+
to_unary_expr(code).op().id() == ID_symbol,
387+
"dead statement must take symbol operand");
385388
return static_cast<code_deadt &>(code);
386389
}
387390

0 commit comments

Comments
 (0)