@@ -220,7 +220,7 @@ void ai_baset::finalize()
220
220
ai_baset::locationt ai_baset::get_next (
221
221
working_sett &working_set)
222
222
{
223
- assert (!working_set.empty ());
223
+ PRECONDITION (!working_set.empty ());
224
224
225
225
working_sett::iterator i=working_set.begin ();
226
226
locationt l=i->second ;
@@ -248,6 +248,16 @@ bool ai_baset::fixedpoint(
248
248
{
249
249
locationt l=get_next (working_set);
250
250
251
+ // goto_program is really only needed for iterator manipulation
252
+ auto it = goto_functions.function_map .find (l->function );
253
+
254
+ DATA_INVARIANT (
255
+ it != goto_functions.function_map .end (),
256
+ " instruction.function must be a mapped function" );
257
+ DATA_INVARIANT (
258
+ it->second .body_available (),
259
+ " instruction.function implies instruction is in function" );
260
+
251
261
if (visit (l, working_set, goto_program, goto_functions, ns))
252
262
new_data=true ;
253
263
}
@@ -323,6 +333,8 @@ bool ai_baset::do_function_call(
323
333
// initialize state, if necessary
324
334
get_state (l_return);
325
335
336
+ PRECONDITION (l_call->is_function_call ());
337
+
326
338
const goto_functionst::goto_functiont &goto_function=
327
339
f_it->second ;
328
340
@@ -388,7 +400,17 @@ bool ai_baset::do_function_call_rec(
388
400
const goto_functionst &goto_functions,
389
401
const namespacet &ns)
390
402
{
391
- assert (!goto_functions.function_map .empty ());
403
+ PRECONDITION (!goto_functions.function_map .empty ());
404
+
405
+ // We can't really do this here -- we rely on
406
+ // these being removed by some previous analysis.
407
+ PRECONDITION (function.id () != ID_dereference);
408
+
409
+ // Can't be a function
410
+ DATA_INVARIANT (
411
+ function.id () != " NULL-object" , " Function cannot be null object" );
412
+ DATA_INVARIANT (function.id () != ID_member, " Function cannot be struct field" );
413
+ DATA_INVARIANT (function.id () != ID_index, " Function cannot be array element" );
392
414
393
415
bool new_data=false ;
394
416
@@ -411,8 +433,7 @@ bool ai_baset::do_function_call_rec(
411
433
}
412
434
else if (function.id ()==ID_if)
413
435
{
414
- if (function.operands ().size ()!=3 )
415
- throw " if has three operands" ;
436
+ DATA_INVARIANT (function.operands ().size () != 3 , " if has three operands" );
416
437
417
438
bool new_data1=
418
439
do_function_call_rec (
@@ -433,19 +454,6 @@ bool ai_baset::do_function_call_rec(
433
454
if (new_data1 || new_data2)
434
455
new_data=true ;
435
456
}
436
- else if (function.id ()==ID_dereference)
437
- {
438
- // We can't really do this here -- we rely on
439
- // these being removed by some previous analysis.
440
- }
441
- else if (function.id () == ID_null_object)
442
- {
443
- // ignore, can't be a function
444
- }
445
- else if (function.id ()==ID_member || function.id ()==ID_index)
446
- {
447
- // ignore, can't be a function
448
- }
449
457
else
450
458
{
451
459
throw " unexpected function_call argument: " +
0 commit comments