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(
26712671 }
26722672 else if (identifier == CPROVER_PREFIX " pointer_in_range" )
26732673 {
2674- // experimental feature for CHC encodings -- do not use
26752674 if (expr.arguments ().size () != 3 )
26762675 {
26772676 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)
35723572 return dest;
35733573}
35743574
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+
35753593std::string expr2ct::convert_with_precedence (
35763594 const exprt &src,
35773595 unsigned &precedence)
@@ -3984,6 +4002,9 @@ std::string expr2ct::convert_with_precedence(
39844002 else if (src.id () == ID_r_ok || src.id () == ID_w_ok || src.id () == ID_rw_ok)
39854003 return convert_r_or_w_ok (to_r_or_w_ok_expr (src));
39864004
4005+ else if (src.id () == ID_pointer_in_range)
4006+ return convert_pointer_in_range (to_pointer_in_range_expr (src));
4007+
39874008 auto function_string_opt = convert_function (src);
39884009 if (function_string_opt.has_value ())
39894010 return *function_string_opt;
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ class annotated_pointer_constant_exprt;
2727class qualifierst ;
2828class namespacet ;
2929class r_or_w_ok_exprt ;
30+ class pointer_in_range_exprt ;
3031
3132class expr2ct
3233{
@@ -284,6 +285,7 @@ class expr2ct
284285 std::string convert_bitreverse (const bitreverse_exprt &src);
285286
286287 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);
287289};
288290
289291#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
385385 PRECONDITION (op2 ().type ().id () == ID_pointer);
386386 }
387387
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+
388403 // translate into equivalent conjunction
389404 exprt lower () const ;
390405};
@@ -414,7 +429,7 @@ inline pointer_in_range_exprt &to_pointer_in_range_expr(exprt &expr)
414429{
415430 PRECONDITION (expr.id () == ID_pointer_in_range);
416431 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 " );
418433 return static_cast <pointer_in_range_exprt &>(expr);
419434}
420435
You can’t perform that action at this time.
0 commit comments