15
15
#include < memory>
16
16
#include < sstream>
17
17
18
- #include < util/std_expr .h>
18
+ #include < util/invariant .h>
19
19
#include < util/std_code.h>
20
+ #include < util/std_expr.h>
20
21
21
22
#include " is_threaded.h"
22
23
@@ -220,7 +221,7 @@ void ai_baset::finalize()
220
221
ai_baset::locationt ai_baset::get_next (
221
222
working_sett &working_set)
222
223
{
223
- assert (!working_set.empty ());
224
+ PRECONDITION (!working_set.empty ());
224
225
225
226
working_sett::iterator i=working_set.begin ();
226
227
locationt l=i->second ;
@@ -248,6 +249,7 @@ bool ai_baset::fixedpoint(
248
249
{
249
250
locationt l=get_next (working_set);
250
251
252
+ // goto_program is really only needed for iterator manipulation
251
253
if (visit (l, working_set, goto_program, goto_functions, ns))
252
254
new_data=true ;
253
255
}
@@ -323,6 +325,8 @@ bool ai_baset::do_function_call(
323
325
// initialize state, if necessary
324
326
get_state (l_return);
325
327
328
+ PRECONDITION (l_call->is_function_call ());
329
+
326
330
const goto_functionst::goto_functiont &goto_function=
327
331
f_it->second ;
328
332
@@ -388,7 +392,17 @@ bool ai_baset::do_function_call_rec(
388
392
const goto_functionst &goto_functions,
389
393
const namespacet &ns)
390
394
{
391
- assert (!goto_functions.function_map .empty ());
395
+ PRECONDITION (!goto_functions.function_map .empty ());
396
+
397
+ // We can't really do this here -- we rely on
398
+ // these being removed by some previous analysis.
399
+ PRECONDITION (function.id () != ID_dereference);
400
+
401
+ // Can't be a function
402
+ DATA_INVARIANT (
403
+ function.id () != " NULL-object" , " Function cannot be null object" );
404
+ DATA_INVARIANT (function.id () != ID_member, " Function cannot be struct field" );
405
+ DATA_INVARIANT (function.id () != ID_index, " Function cannot be array element" );
392
406
393
407
bool new_data=false ;
394
408
@@ -411,8 +425,7 @@ bool ai_baset::do_function_call_rec(
411
425
}
412
426
else if (function.id ()==ID_if)
413
427
{
414
- if (function.operands ().size ()!=3 )
415
- throw " if has three operands" ;
428
+ DATA_INVARIANT (function.operands ().size () != 3 , " if has three operands" );
416
429
417
430
bool new_data1=
418
431
do_function_call_rec (
@@ -433,19 +446,6 @@ bool ai_baset::do_function_call_rec(
433
446
if (new_data1 || new_data2)
434
447
new_data=true ;
435
448
}
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
449
else
450
450
{
451
451
throw " unexpected function_call argument: " +
0 commit comments