File tree Expand file tree Collapse file tree 4 files changed +39
-2
lines changed Expand file tree Collapse file tree 4 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -2671,7 +2671,6 @@ exprt c_typecheck_baset::do_special_functions(
2671
2671
}
2672
2672
else if (identifier == CPROVER_PREFIX " pointer_in_range" )
2673
2673
{
2674
- // experimental feature for CHC encodings -- do not use
2675
2674
if (expr.arguments ().size () != 3 )
2676
2675
{
2677
2676
error ().source_location = f_op.source_location ();
Original file line number Diff line number Diff line change @@ -3572,6 +3572,24 @@ std::string expr2ct::convert_r_or_w_ok(const r_or_w_ok_exprt &src)
3572
3572
return dest;
3573
3573
}
3574
3574
3575
+ std::string expr2ct::convert_pointer_in_range (const pointer_in_range_exprt &src)
3576
+ {
3577
+ std::string dest = CPROVER_PREFIX " pointer_in_range" ;
3578
+
3579
+ dest += ' (' ;
3580
+
3581
+ unsigned p;
3582
+ dest += convert_with_precedence (src.lower_bound (), p);
3583
+ dest += " , " ;
3584
+ dest += convert_with_precedence (src.pointer (), p);
3585
+ dest += " , " ;
3586
+ dest += convert_with_precedence (src.upper_bound (), p);
3587
+
3588
+ dest += ' )' ;
3589
+
3590
+ return dest;
3591
+ }
3592
+
3575
3593
std::string expr2ct::convert_with_precedence (
3576
3594
const exprt &src,
3577
3595
unsigned &precedence)
@@ -3984,6 +4002,9 @@ std::string expr2ct::convert_with_precedence(
3984
4002
else if (src.id () == ID_r_ok || src.id () == ID_w_ok || src.id () == ID_rw_ok)
3985
4003
return convert_r_or_w_ok (to_r_or_w_ok_expr (src));
3986
4004
4005
+ else if (src.id () == ID_pointer_in_range)
4006
+ return convert_pointer_in_range (to_pointer_in_range_expr (src));
4007
+
3987
4008
auto function_string_opt = convert_function (src);
3988
4009
if (function_string_opt.has_value ())
3989
4010
return *function_string_opt;
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ class annotated_pointer_constant_exprt;
27
27
class qualifierst ;
28
28
class namespacet ;
29
29
class r_or_w_ok_exprt ;
30
+ class pointer_in_range_exprt ;
30
31
31
32
class expr2ct
32
33
{
@@ -284,6 +285,7 @@ class expr2ct
284
285
std::string convert_bitreverse (const bitreverse_exprt &src);
285
286
286
287
std::string convert_r_or_w_ok (const r_or_w_ok_exprt &src);
288
+ std::string convert_pointer_in_range (const pointer_in_range_exprt &src);
287
289
};
288
290
289
291
#endif // CPROVER_ANSI_C_EXPR2C_CLASS_H
Original file line number Diff line number Diff line change @@ -385,6 +385,21 @@ class pointer_in_range_exprt : public ternary_exprt
385
385
PRECONDITION (op2 ().type ().id () == ID_pointer);
386
386
}
387
387
388
+ const exprt &lower_bound () const
389
+ {
390
+ return op0 ();
391
+ }
392
+
393
+ const exprt &pointer () const
394
+ {
395
+ return op1 ();
396
+ }
397
+
398
+ const exprt &upper_bound () const
399
+ {
400
+ return op2 ();
401
+ }
402
+
388
403
// translate into equivalent conjunction
389
404
exprt lower () const ;
390
405
};
@@ -414,7 +429,7 @@ inline pointer_in_range_exprt &to_pointer_in_range_expr(exprt &expr)
414
429
{
415
430
PRECONDITION (expr.id () == ID_pointer_in_range);
416
431
DATA_INVARIANT (
417
- expr.operands ().size () == 3 , " pointer_in_range must have one operand " );
432
+ expr.operands ().size () == 3 , " pointer_in_range must have three operands " );
418
433
return static_cast <pointer_in_range_exprt &>(expr);
419
434
}
420
435
You can’t perform that action at this time.
0 commit comments