@@ -77,7 +77,9 @@ void remove_exceptionst::add_exceptional_returns(
77
77
const irep_idt &function_id=func_it->first ;
78
78
goto_programt &goto_program=func_it->second .body ;
79
79
80
- assert (symbol_table.has_symbol (function_id));
80
+ INVARIANT (
81
+ symbol_table.has_symbol (function_id),
82
+ " functions should be recorded in the symbol table" );
81
83
const symbolt &function_symbol=symbol_table.lookup (function_id);
82
84
83
85
// for now only add exceptional returns for Java
@@ -116,7 +118,9 @@ void remove_exceptionst::add_exceptional_returns(
116
118
{
117
119
const exprt &function_expr=
118
120
to_code_function_call (instr_it->code ).function ();
119
- assert (function_expr.id ()==ID_symbol);
121
+ DATA_INVARIANT (
122
+ function_expr.id ()==ID_symbol,
123
+ " identifier expected to be a symbol" );
120
124
const irep_idt &function_name=
121
125
to_symbol_expr (function_expr).get_identifier ();
122
126
has_uncaught_exceptions=!exceptions_map[function_name].empty ();
@@ -142,7 +146,9 @@ void remove_exceptionst::add_exceptional_returns(
142
146
symbol_tablet::symbolst::iterator s_it=
143
147
symbol_table.symbols .find (function_id);
144
148
145
- assert (s_it!=symbol_table.symbols .end ());
149
+ INVARIANT (
150
+ s_it!=symbol_table.symbols .end (),
151
+ " functions should be recorded in the symbol table" );
146
152
147
153
auxiliary_symbolt new_symbol;
148
154
new_symbol.is_static_lifetime =true ;
@@ -180,7 +186,7 @@ void remove_exceptionst::instrument_exception_handler(
180
186
const irep_idt &function_id=func_it->first ;
181
187
goto_programt &goto_program=func_it->second .body ;
182
188
183
- assert (instr_it->type ==CATCH && instr_it->code .has_operands ());
189
+ PRECONDITION (instr_it->type ==CATCH && instr_it->code .has_operands ());
184
190
185
191
// retrieve the exception variable
186
192
const exprt &exception=instr_it->code .op0 ();
@@ -226,9 +232,13 @@ static goto_programt::targett get_exceptional_output(
226
232
const irep_idt &statement=it->code .get_statement ();
227
233
if (statement==ID_output)
228
234
{
229
- assert (it->code .operands ().size ()>=2 );
235
+ DATA_INVARIANT (
236
+ it->code .operands ().size ()>=2 ,
237
+ " output expected to have at least 2 operands" );
230
238
const exprt &expr=it->code .op1 ();
231
- assert (expr.id ()==ID_symbol);
239
+ DATA_INVARIANT (
240
+ expr.id ()==ID_symbol,
241
+ " identifier expected to be a symbol" );
232
242
const symbol_exprt &symbol=to_symbol_expr (expr);
233
243
if (id2string (symbol.get_identifier ()).find (EXC_SUFFIX)
234
244
!=std::string::npos)
@@ -246,7 +256,7 @@ void remove_exceptionst::instrument_throw(
246
256
const remove_exceptionst::stack_catcht &stack_catch,
247
257
std::vector<exprt> &locals)
248
258
{
249
- assert (instr_it->type ==THROW);
259
+ PRECONDITION (instr_it->type ==THROW);
250
260
251
261
const exprt &exc_expr=
252
262
uncaught_exceptions_domaint::get_exception_symbol (instr_it->code );
@@ -263,8 +273,6 @@ void remove_exceptionst::instrument_throw(
263
273
goto_programt &goto_program=func_it->second .body ;
264
274
const irep_idt &function_id=func_it->first ;
265
275
266
- assert (instr_it->code .operands ().size ()==1 );
267
-
268
276
// find the end of the function
269
277
goto_programt::targett exceptional_output=
270
278
get_exceptional_output (goto_program);
@@ -334,7 +342,7 @@ void remove_exceptionst::instrument_function_call(
334
342
const stack_catcht &stack_catch,
335
343
std::vector<exprt> &locals)
336
344
{
337
- assert (instr_it->type ==FUNCTION_CALL);
345
+ PRECONDITION (instr_it->type ==FUNCTION_CALL);
338
346
339
347
goto_programt &goto_program=func_it->second .body ;
340
348
const irep_idt &function_id=func_it->first ;
@@ -344,7 +352,9 @@ void remove_exceptionst::instrument_function_call(
344
352
next_it++;
345
353
346
354
code_function_callt &function_call=to_code_function_call (instr_it->code );
347
- assert (function_call.function ().id ()==ID_symbol);
355
+ DATA_INVARIANT (
356
+ function_call.function ().id ()==ID_symbol,
357
+ " identified expected to be a symbol" );
348
358
const irep_idt &callee_id=
349
359
to_symbol_expr (function_call.function ()).get_identifier ();
350
360
@@ -480,7 +490,9 @@ void remove_exceptionst::instrument_exceptions(
480
490
// copy targets
481
491
const irept::subt &exception_list=
482
492
instr_it->code .find (ID_exception_list).get_sub ();
483
- assert (exception_list.size ()==instr_it->targets .size ());
493
+ INVARIANT (
494
+ exception_list.size ()==instr_it->targets .size (),
495
+ " `exception_list` should contain current instruction's targets" );
484
496
485
497
// Fill the map with the catch type and the target
486
498
unsigned i=0 ;
0 commit comments