Skip to content

Commit f34ad06

Browse files
author
Daniel Kroening
committed
introduce instructiont::has_condition()
This will eventually enable use to protect instructiont::guard.
1 parent 47d3d39 commit f34ad06

13 files changed

+46
-15
lines changed

src/analyses/dirty.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ void dirtyt::build(const goto_functiont &goto_function)
2020
forall_goto_program_instructions(it, goto_function.body)
2121
{
2222
find_dirty(it->code);
23-
find_dirty(it->guard);
23+
24+
if(it->has_condition())
25+
find_dirty(it->get_condition());
2426
}
2527
}
2628

src/analyses/goto_check.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1671,7 +1671,8 @@ void goto_checkt::goto_check(
16711671
i.is_target())
16721672
assertions.clear();
16731673

1674-
check(i.guard);
1674+
if(i.has_condition())
1675+
check(i.get_condition());
16751676

16761677
// magic ERROR label?
16771678
for(const auto &label : error_labels)

src/goto-instrument/accelerate/accelerate.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ void acceleratet::add_dirty_checks()
393393
// the right hand side of an assignment. Assume each is not dirty.
394394
find_symbols_sett read;
395395

396-
find_symbols(it->guard, read);
396+
if(it->has_condition())
397+
find_symbols(it->get_condition(), read);
397398

398399
if(it->is_assign())
399400
{

src/goto-programs/adjust_float_expressions.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ void adjust_float_expressions(
200200
Forall_goto_program_instructions(it, goto_function.body)
201201
{
202202
adjust_float_expressions(it->code, ns);
203-
adjust_float_expressions(it->guard, ns);
203+
204+
if(it->has_condition())
205+
adjust_float_expressions(it->guard, ns);
204206
}
205207
}
206208

src/goto-programs/compute_called_functions.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ void compute_address_taken_functions(
5656
{
5757
forall_goto_program_instructions(it, goto_program)
5858
{
59-
compute_address_taken_functions(it->guard, address_taken);
59+
if(it->has_condition())
60+
compute_address_taken_functions(it->get_condition(), address_taken);
61+
6062
compute_address_taken_functions(it->code, address_taken);
6163
}
6264
}

src/goto-programs/goto_inline_class.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,8 +315,10 @@ void goto_inlinet::insert_function_body(
315315
Forall_goto_program_instructions(it, tmp)
316316
{
317317
replace_location(it->source_location, target->source_location);
318-
replace_location(it->guard, target->source_location);
319318
replace_location(it->code, target->source_location);
319+
320+
if(it->has_condition())
321+
replace_location(it->guard, target->source_location);
320322
}
321323
}
322324

src/goto-programs/goto_program.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,16 @@ class goto_programt
274274
/// Use get_condition() to read
275275
exprt guard;
276276

277+
/// Does this instruction have a condition?
278+
bool has_condition() const
279+
{
280+
return is_goto() || is_incomplete_goto() || is_assume() || is_assert();
281+
}
282+
277283
/// Get the condition of gotos, assume, assert
278284
const exprt &get_condition() const
279285
{
280-
PRECONDITION(is_goto() || is_assume() || is_assert());
286+
PRECONDITION(has_condition());
281287
return guard;
282288
}
283289

src/goto-programs/link_goto_model.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ static void rename_symbols_in_function(
3333
Forall_goto_program_instructions(iit, program)
3434
{
3535
rename_symbol(iit->code);
36-
rename_symbol(iit->guard);
36+
37+
if(iit->has_condition())
38+
rename_symbol(iit->guard);
3739
}
3840
}
3941

@@ -144,7 +146,9 @@ static bool link_functions(
144146
Forall_goto_program_instructions(iit, dest_it->second.body)
145147
{
146148
object_type_updates(iit->code);
147-
object_type_updates(iit->guard);
149+
150+
if(iit->has_condition())
151+
object_type_updates(iit->guard);
148152
}
149153
}
150154

src/goto-programs/remove_complex.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,9 @@ static void remove_complex(
288288
Forall_goto_program_instructions(it, goto_function.body)
289289
{
290290
remove_complex(it->code);
291-
remove_complex(it->guard);
291+
292+
if(it->has_condition())
293+
remove_complex(it->guard);
292294
}
293295
}
294296

src/goto-programs/remove_vector.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ void remove_vector(goto_functionst::goto_functiont &goto_function)
221221
Forall_goto_program_instructions(it, goto_function.body)
222222
{
223223
remove_vector(it->code);
224-
remove_vector(it->guard);
224+
225+
if(it->has_condition())
226+
remove_vector(it->guard);
225227
}
226228
}
227229

src/goto-programs/rewrite_union.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ void rewrite_union(goto_functionst::goto_functiont &goto_function)
104104
Forall_goto_program_instructions(it, goto_function.body)
105105
{
106106
rewrite_union(it->code);
107-
rewrite_union(it->guard);
107+
108+
if(it->has_condition())
109+
rewrite_union(it->guard);
108110
}
109111
}
110112

src/goto-programs/slice_global_inits.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,12 @@ void slice_global_inits(goto_modelt &goto_model)
6767
{
6868
const codet &code = i_it->code;
6969
find_symbols(code, symbols, true, false);
70-
const exprt &expr = i_it->guard;
71-
find_symbols(expr, symbols, true, false);
70+
71+
if(i_it->has_condition())
72+
{
73+
const exprt &expr = i_it->get_condition();
74+
find_symbols(expr, symbols, true, false);
75+
}
7276
}
7377
}
7478

src/pointer-analysis/goto_program_dereference.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,8 @@ void goto_program_dereferencet::dereference_instruction(
301301
#endif
302302
goto_programt::instructiont &i=*target;
303303

304-
dereference_expr(i.guard, checks_only, value_set_dereferencet::modet::READ);
304+
if(i.has_condition())
305+
dereference_expr(i.guard, checks_only, value_set_dereferencet::modet::READ);
305306

306307
if(i.is_assign())
307308
{

0 commit comments

Comments
 (0)