@@ -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,14 @@ 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 (it!=goto_functions.function_map .end (),
255
+ " instruction.function must be a mapped function" );
256
+ DATA_INVARIANT (it->second .body_available (),
257
+ " instruction.function implies instruction is in function" );
258
+
251
259
if (visit (l, working_set, goto_program, goto_functions, ns))
252
260
new_data=true ;
253
261
}
@@ -323,6 +331,8 @@ bool ai_baset::do_function_call(
323
331
// initialize state, if necessary
324
332
get_state (l_return);
325
333
334
+ PRECONDITION (l_call->is_function_call ());
335
+
326
336
const goto_functionst::goto_functiont &goto_function=
327
337
f_it->second ;
328
338
@@ -388,7 +398,16 @@ bool ai_baset::do_function_call_rec(
388
398
const goto_functionst &goto_functions,
389
399
const namespacet &ns)
390
400
{
391
- assert (!goto_functions.function_map .empty ());
401
+ PRECONDITION (!goto_functions.function_map .empty ());
402
+
403
+ // We can't really do this here -- we rely on
404
+ // these being removed by some previous analysis.
405
+ PRECONDITION (function.id ()!=ID_dereference);
406
+
407
+ // Can't be a function
408
+ DATA_INVARIANT (function.id ()!=" NULL-object" , " Function cannot be null object" );
409
+ DATA_INVARIANT (function.id ()!=ID_member, " Function cannot be struct field" );
410
+ DATA_INVARIANT (function.id ()!=ID_index, " Function cannot be array element" );
392
411
393
412
bool new_data=false ;
394
413
@@ -411,8 +430,7 @@ bool ai_baset::do_function_call_rec(
411
430
}
412
431
else if (function.id ()==ID_if)
413
432
{
414
- if (function.operands ().size ()!=3 )
415
- throw " if has three operands" ;
433
+ DATA_INVARIANT (function.operands ().size ()!=3 , " if has three operands" );
416
434
417
435
bool new_data1=
418
436
do_function_call_rec (
@@ -433,19 +451,6 @@ bool ai_baset::do_function_call_rec(
433
451
if (new_data1 || new_data2)
434
452
new_data=true ;
435
453
}
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
454
else
450
455
{
451
456
throw " unexpected function_call argument: " +
0 commit comments