@@ -165,7 +165,8 @@ std::ostream &goto_programt::output_instruction(
165
165
instruction.code .find (ID_exception_list).get_sub ();
166
166
DATA_INVARIANT (
167
167
instruction.targets .size () == exception_list.size (),
168
- " size of target list" );
168
+ " unexpected discrepancy between sizes of instruction"
169
+ " targets and exception list" );
169
170
for (instructiont::targetst::const_iterator
170
171
gt_it=instruction.targets .begin ();
171
172
gt_it!=instruction.targets .end ();
@@ -223,10 +224,11 @@ void goto_programt::get_decl_identifiers(
223
224
if (it->is_decl ())
224
225
{
225
226
DATA_INVARIANT (
226
- it->code .get_statement () == ID_decl, " declaration statements" );
227
+ it->code .get_statement () == ID_decl,
228
+ " expected statement to be declaration statement" );
227
229
DATA_INVARIANT (
228
230
it->code .operands ().size () == 1 ,
229
- " declaration statement expects 1 operand" );
231
+ " declaration statement expects one operand" );
230
232
const symbol_exprt &symbol_expr=to_symbol_expr (it->code .op0 ());
231
233
decl_identifiers.insert (symbol_expr.get_identifier ());
232
234
}
@@ -237,26 +239,24 @@ void parse_lhs_read(const exprt &src, std::list<exprt> &dest)
237
239
{
238
240
if (src.id ()==ID_dereference)
239
241
{
240
- PRECONDITION (src.operands ().size () == 1 );
241
- dest.push_back (src.op0 ());
242
+ dest.push_back (to_dereference_expr (src).pointer ());
242
243
}
243
244
else if (src.id ()==ID_index)
244
245
{
245
- PRECONDITION (src. operands (). size () == 2 );
246
- dest.push_back (src. op1 ());
247
- parse_lhs_read (src. op0 (), dest);
246
+ auto &index_expr = to_index_expr (src );
247
+ dest.push_back (index_expr. index ());
248
+ parse_lhs_read (index_expr. array (), dest);
248
249
}
249
250
else if (src.id ()==ID_member)
250
251
{
251
- PRECONDITION (src.operands ().size () == 1 );
252
- parse_lhs_read (src.op0 (), dest);
252
+ parse_lhs_read (to_member_expr (src).compound (), dest);
253
253
}
254
254
else if (src.id ()==ID_if)
255
255
{
256
- PRECONDITION (src. operands (). size () == 3 );
257
- dest.push_back (src. op0 ());
258
- parse_lhs_read (src. op1 (), dest);
259
- parse_lhs_read (src. op2 (), dest);
256
+ auto &if_expr = to_if_expr (src );
257
+ dest.push_back (if_expr. cond ());
258
+ parse_lhs_read (if_expr. true_case (), dest);
259
+ parse_lhs_read (if_expr. false_case (), dest);
260
260
}
261
261
}
262
262
@@ -346,9 +346,9 @@ void objects_read(
346
346
else if (src.id ()==ID_dereference)
347
347
{
348
348
// this reads what is pointed to plus the pointer
349
- PRECONDITION (src. operands (). size () == 1 );
350
- dest.push_back (src );
351
- objects_read (src. op0 (), dest);
349
+ auto &deref = to_dereference_expr (src );
350
+ dest.push_back (deref );
351
+ objects_read (deref. pointer (), dest);
352
352
}
353
353
else
354
354
{
@@ -376,9 +376,9 @@ void objects_written(
376
376
{
377
377
if (src.id ()==ID_if)
378
378
{
379
- PRECONDITION (src. operands (). size () == 3 );
380
- objects_written (src. op1 (), dest);
381
- objects_written (src. op2 (), dest);
379
+ auto &if_expr = to_if_expr (src );
380
+ objects_written (if_expr. true_case (), dest);
381
+ objects_written (if_expr. false_case (), dest);
382
382
}
383
383
else
384
384
dest.push_back (src);
@@ -544,7 +544,8 @@ void goto_programt::compute_target_numbers()
544
544
if (i.is_target ())
545
545
{
546
546
i.target_number =++cnt;
547
- DATA_INVARIANT (i.target_number != 0 , " instruction's number cannot be 0" );
547
+ DATA_INVARIANT (
548
+ i.target_number != 0 , " instruction's number cannot be zero" );
548
549
}
549
550
}
550
551
@@ -558,7 +559,7 @@ void goto_programt::compute_target_numbers()
558
559
if (t!=instructions.end ())
559
560
{
560
561
DATA_INVARIANT (
561
- t->target_number != 0 , " instruction's number cannot be 0 " );
562
+ t->target_number != 0 , " instruction's number cannot be zero " );
562
563
DATA_INVARIANT (
563
564
t->target_number != instructiont::nil_target,
564
565
" instruction cannot be an invalid target" );
0 commit comments