Skip to content

Commit 4787717

Browse files
author
Daniel Kroening
committed
added instructiont::get_other()
This will eventually enable us to prevent direct access to instructiont::code.
1 parent 85d61b5 commit 4787717

File tree

10 files changed

+38
-22
lines changed

10 files changed

+38
-22
lines changed

src/analyses/constant_propagator.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,9 +785,10 @@ void constant_propagator_ait::replace(
785785
}
786786
else if(it->is_other())
787787
{
788-
if(it->code.get_statement()==ID_expression)
788+
if(it->get_other().get_statement() == ID_expression)
789789
{
790-
constant_propagator_domaint::partial_evaluate(d.values, it->code, ns);
790+
constant_propagator_domaint::partial_evaluate(
791+
d.values, it->get_other(), ns);
791792
}
792793
}
793794
}

src/analyses/custom_bitvector_analysis.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,17 +447,18 @@ void custom_bitvector_domaint::transform(
447447

448448
case OTHER:
449449
{
450-
const irep_idt &statement=instruction.code.get_statement();
450+
const auto &code = instruction.get_other();
451+
const irep_idt &statement = code.get_statement();
451452

452453
if(statement=="set_may" ||
453454
statement=="set_must" ||
454455
statement=="clear_may" ||
455456
statement=="clear_must")
456457
{
457-
assert(instruction.code.operands().size()==2);
458+
DATA_INVARIANT(
459+
code.operands().size() == 2, "set/clear_may/must has two operands");
458460

459-
unsigned bit_nr=
460-
cba.get_bit_nr(instruction.code.op1());
461+
unsigned bit_nr = cba.get_bit_nr(code.op1());
461462

462463
// initialize to make Visual Studio happy
463464
modet mode = modet::SET_MUST;
@@ -473,7 +474,7 @@ void custom_bitvector_domaint::transform(
473474
else
474475
UNREACHABLE;
475476

476-
exprt lhs=instruction.code.op0();
477+
exprt lhs = code.op0();
477478

478479
if(lhs.type().id()==ID_pointer)
479480
{

src/analyses/goto_check.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,15 +1704,16 @@ void goto_checkt::goto_check(
17041704

17051705
if(i.is_other())
17061706
{
1707-
const irep_idt &statement=i.code.get(ID_statement);
1707+
const auto &code = i.get_other();
1708+
const irep_idt &statement = code.get_statement();
17081709

17091710
if(statement==ID_expression)
17101711
{
1711-
check(i.code);
1712+
check(code);
17121713
}
17131714
else if(statement==ID_printf)
17141715
{
1715-
for(const auto &op : i.code.operands())
1716+
for(const auto &op : code.operands())
17161717
check(op);
17171718
}
17181719
}

src/analyses/goto_rw.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -781,11 +781,11 @@ void goto_rw(
781781

782782
case OTHER:
783783
// if it's printf, mark the operands as read here
784-
if(target->code.get(ID_statement)==ID_printf)
784+
if(target->get_other().get_statement() == ID_printf)
785785
{
786-
forall_expr(it, target->code.operands())
786+
for(const auto &op : target->get_other().operands())
787787
rw_set.get_objects_rec(
788-
function, target, rw_range_sett::get_modet::READ, *it);
788+
function, target, rw_range_sett::get_modet::READ, op);
789789
}
790790
break;
791791

src/analyses/invariant_set_domain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ void invariant_set_domaint::transform(
6161
break;
6262

6363
case OTHER:
64-
if(from_l->code.is_not_nil())
64+
if(from_l->get_other().is_not_nil())
6565
invariant_set.apply_code(from_l->code);
6666
break;
6767

src/goto-programs/goto_program.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,20 @@ class goto_programt
250250
return to_code_function_call(code);
251251
}
252252

253+
/// Get the statement for OTHER
254+
const codet &get_other() const
255+
{
256+
PRECONDITION(is_other());
257+
return code;
258+
}
259+
260+
/// Get the statement for OTHER
261+
codet &get_other()
262+
{
263+
PRECONDITION(is_other());
264+
return code;
265+
}
266+
253267
/// The function this instruction belongs to
254268
irep_idt function;
255269

src/goto-programs/interpreter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ void interpretert::execute_goto()
383383
/// executes side effects of 'other' instructions
384384
void interpretert::execute_other()
385385
{
386-
const irep_idt &statement=pc->code.get_statement();
386+
const irep_idt &statement = pc->get_other().get_statement();
387387
if(statement==ID_expression)
388388
{
389389
DATA_INVARIANT(

src/goto-programs/remove_asm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ void remove_asmt::process_function(
488488

489489
Forall_goto_program_instructions(it, goto_function.body)
490490
{
491-
if(it->is_other() && it->code.get_statement()==ID_asm)
491+
if(it->is_other() && it->get_other().get_statement() == ID_asm)
492492
{
493493
goto_programt tmp_dest;
494494
process_instruction(*it, tmp_dest);

src/goto-programs/remove_skip.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ bool is_skip(
5252

5353
if(it->is_other())
5454
{
55-
if(it->code.is_nil())
55+
if(it->get_other().is_nil())
5656
return true;
5757

58-
const irep_idt &statement=it->code.get_statement();
58+
const irep_idt &statement = it->get_other().get_statement();
5959

6060
if(statement==ID_skip)
6161
return true;

src/pointer-analysis/goto_program_dereference.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ void goto_program_dereferencet::dereference_instruction(
337337
}
338338
else if(i.is_other())
339339
{
340-
const irep_idt &statement=i.code.get(ID_statement);
340+
const irep_idt &statement = i.get_other().get_statement();
341341

342342
if(statement==ID_expression)
343343
{
@@ -349,9 +349,8 @@ void goto_program_dereferencet::dereference_instruction(
349349
}
350350
else if(statement==ID_printf)
351351
{
352-
Forall_operands(it, i.code)
353-
dereference_expr(
354-
*it, checks_only, value_set_dereferencet::modet::READ);
352+
for(auto &op : i.get_other().operands())
353+
dereference_expr(op, checks_only, value_set_dereferencet::modet::READ);
355354
}
356355
}
357356
}

0 commit comments

Comments
 (0)