@@ -99,10 +99,14 @@ void rw_range_sett::get_objects_complex_imag(
99
99
{
100
100
const exprt &op = expr.op ();
101
101
102
- range_spect sub_size =
103
- to_range_spect (pointer_offset_bits (op.type ().subtype (), ns));
104
- assert (sub_size>0 );
105
- range_spect offset = range_start == -1 ? 0 : sub_size;
102
+ auto subtype_bits = pointer_offset_bits (op.type ().subtype (), ns);
103
+ CHECK_RETURN (subtype_bits.has_value ());
104
+
105
+ range_spect sub_size = to_range_spect (*subtype_bits);
106
+ CHECK_RETURN (sub_size > 0 );
107
+
108
+ range_spect offset=
109
+ (range_start==-1 || expr.id ()==ID_complex_real) ? 0 : sub_size;
106
110
107
111
get_objects_rec (mode, op, range_start + offset, size);
108
112
}
@@ -173,8 +177,9 @@ void rw_range_sett::get_objects_shift(
173
177
{
174
178
const exprt simp_distance=simplify_expr (shift.distance (), ns);
175
179
176
- range_spect src_size=
177
- to_range_spect (pointer_offset_bits (shift.op ().type (), ns));
180
+ auto op_bits = pointer_offset_bits (shift.op ().type (), ns);
181
+
182
+ range_spect src_size = op_bits.has_value () ? to_range_spect (*op_bits) : -1 ;
178
183
179
184
mp_integer dist;
180
185
if (range_start==-1 ||
@@ -230,15 +235,18 @@ void rw_range_sett::get_objects_member(
230
235
231
236
const struct_typet &struct_type=to_struct_type (type);
232
237
233
- range_spect offset=
234
- to_range_spect (
235
- member_offset_bits (
236
- struct_type,
237
- expr.get_component_name (),
238
- ns));
238
+ auto offset_bits =
239
+ member_offset_bits (struct_type, expr.get_component_name (), ns);
239
240
240
- if (offset!=-1 )
241
- offset+=range_start;
241
+ range_spect offset;
242
+
243
+ if (offset_bits.has_value ())
244
+ {
245
+ offset = to_range_spect (*offset_bits);
246
+ offset += range_start;
247
+ }
248
+ else
249
+ offset = -1 ;
242
250
243
251
get_objects_rec (mode, expr.struct_op (), offset, size);
244
252
}
@@ -259,15 +267,17 @@ void rw_range_sett::get_objects_index(
259
267
{
260
268
const vector_typet &vector_type=to_vector_type (type);
261
269
262
- sub_size=
263
- to_range_spect (pointer_offset_bits (vector_type.subtype (), ns));
270
+ auto subtype_bits = pointer_offset_bits (vector_type.subtype (), ns);
271
+
272
+ sub_size = subtype_bits.has_value () ? to_range_spect (*subtype_bits) : -1 ;
264
273
}
265
274
else if (type.id ()==ID_array)
266
275
{
267
276
const array_typet &array_type=to_array_type (type);
268
277
269
- sub_size=
270
- to_range_spect (pointer_offset_bits (array_type.subtype (), ns));
278
+ auto subtype_bits = pointer_offset_bits (array_type.subtype (), ns);
279
+
280
+ sub_size = subtype_bits.has_value () ? to_range_spect (*subtype_bits) : -1 ;
271
281
}
272
282
else
273
283
return ;
@@ -302,10 +312,13 @@ void rw_range_sett::get_objects_array(
302
312
const array_typet &array_type=
303
313
to_array_type (ns.follow (expr.type ()));
304
314
305
- range_spect sub_size=
306
- to_range_spect (pointer_offset_bits (array_type.subtype (), ns));
315
+ auto subtype_bits = pointer_offset_bits (array_type.subtype (), ns);
316
+
317
+ range_spect sub_size;
307
318
308
- if (sub_size==-1 )
319
+ if (subtype_bits.has_value ())
320
+ sub_size = to_range_spect (*subtype_bits);
321
+ else
309
322
{
310
323
forall_operands (it, expr)
311
324
get_objects_rec (mode, *it, 0 , -1 );
@@ -342,17 +355,20 @@ void rw_range_sett::get_objects_struct(
342
355
const struct_typet &struct_type=
343
356
to_struct_type (ns.follow (expr.type ()));
344
357
345
- range_spect full_size=
346
- to_range_spect (pointer_offset_bits (struct_type, ns));
358
+ auto struct_bits = pointer_offset_bits (struct_type, ns);
359
+
360
+ range_spect full_size =
361
+ struct_bits.has_value () ? to_range_spect (*struct_bits) : -1 ;
347
362
348
363
range_spect offset=0 ;
349
364
range_spect full_r_s=range_start==-1 ? 0 : range_start;
350
365
range_spect full_r_e=size==-1 || full_size==-1 ? -1 : full_r_s+size;
351
366
352
367
forall_operands (it, expr)
353
368
{
354
- range_spect sub_size=
355
- to_range_spect (pointer_offset_bits (it->type (), ns));
369
+ auto it_bits = pointer_offset_bits (it->type (), ns);
370
+
371
+ range_spect sub_size = it_bits.has_value () ? to_range_spect (*it_bits) : -1 ;
356
372
357
373
if (offset==-1 )
358
374
{
@@ -401,8 +417,9 @@ void rw_range_sett::get_objects_typecast(
401
417
{
402
418
const exprt &op=tc.op ();
403
419
404
- range_spect new_size=
405
- to_range_spect (pointer_offset_bits (op.type (), ns));
420
+ auto op_bits = pointer_offset_bits (op.type (), ns);
421
+
422
+ range_spect new_size = op_bits.has_value () ? to_range_spect (*op_bits) : -1 ;
406
423
407
424
if (range_start==-1 )
408
425
new_size=-1 ;
@@ -537,8 +554,11 @@ void rw_range_sett::get_objects_rec(
537
554
{
538
555
const symbol_exprt &symbol=to_symbol_expr (expr);
539
556
const irep_idt identifier=symbol.get_identifier ();
540
- range_spect full_size=
541
- to_range_spect (pointer_offset_bits (symbol.type (), ns));
557
+
558
+ auto symbol_bits = pointer_offset_bits (symbol.type (), ns);
559
+
560
+ range_spect full_size =
561
+ symbol_bits.has_value () ? to_range_spect (*symbol_bits) : -1 ;
542
562
543
563
if (full_size==0 ||
544
564
(full_size>0 && range_start>=full_size))
@@ -584,8 +604,10 @@ void rw_range_sett::get_objects_rec(
584
604
585
605
void rw_range_sett::get_objects_rec (get_modet mode, const exprt &expr)
586
606
{
587
- range_spect size=
588
- to_range_spect (pointer_offset_bits (expr.type (), ns));
607
+ auto expr_bits = pointer_offset_bits (expr.type (), ns);
608
+
609
+ range_spect size = expr_bits.has_value () ? to_range_spect (*expr_bits) : -1 ;
610
+
589
611
get_objects_rec (mode, expr, 0 , size);
590
612
}
591
613
@@ -614,16 +636,24 @@ void rw_range_set_value_sett::get_objects_dereference(
614
636
exprt object=deref;
615
637
dereference (target, object, ns, value_sets);
616
638
617
- range_spect new_size=
618
- to_range_spect (pointer_offset_bits (object.type (), ns));
639
+ auto type_bits = pointer_offset_bits (object.type (), ns);
619
640
620
- if (range_start==- 1 || new_size<=range_start)
621
- new_size=- 1 ;
622
- else
641
+ range_spect new_size;
642
+
643
+ if (type_bits. has_value ())
623
644
{
624
- new_size-=range_start;
625
- new_size=std::min (size, new_size);
645
+ new_size = to_range_spect (*type_bits);
646
+
647
+ if (range_start == -1 || new_size <= range_start)
648
+ new_size = -1 ;
649
+ else
650
+ {
651
+ new_size -= range_start;
652
+ new_size = std::min (size, new_size);
653
+ }
626
654
}
655
+ else
656
+ new_size = -1 ;
627
657
628
658
// value_set_dereferencet::build_reference_to will turn *p into
629
659
// DYNAMIC_OBJECT(p) ? *p : invalid_objectN
0 commit comments