File tree Expand file tree Collapse file tree 5 files changed +72
-0
lines changed
Expand file tree Collapse file tree 5 files changed +72
-0
lines changed Original file line number Diff line number Diff line change @@ -2538,6 +2538,23 @@ exprt c_typecheck_baset::do_special_functions(
25382538
25392539 return writeable_object_expr;
25402540 }
2541+ else if (identifier == CPROVER_PREFIX " separate" )
2542+ {
2543+ // experimental feature for CHC encodings -- do not use
2544+ if (expr.arguments ().size () < 2 )
2545+ {
2546+ error ().source_location = f_op.source_location ();
2547+ error () << " separate expects two or more arguments" << eom;
2548+ throw 0 ;
2549+ }
2550+
2551+ typecheck_function_call_arguments (expr);
2552+
2553+ exprt separate_expr = separate_exprt (expr.arguments ());
2554+ separate_expr.add_source_location () = source_location;
2555+
2556+ return separate_expr;
2557+ }
25412558 else if (identifier==CPROVER_PREFIX " POINTER_OFFSET" )
25422559 {
25432560 if (expr.arguments ().size ()!=1 )
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ __CPROVER_bool __CPROVER_is_cyclic_dll();
2323__CPROVER_bool __CPROVER_is_sentinel_dll ();
2424__CPROVER_bool __CPROVER_is_cstring (const char * );
2525__CPROVER_size_t __CPROVER_cstrlen (const char * );
26+ __CPROVER_bool __CPROVER_separate (const void * , const void * , ...);
2627
2728// bitvector analysis
2829__CPROVER_bool __CPROVER_get_flag (const void * , const char * );
Original file line number Diff line number Diff line change @@ -3988,6 +3988,7 @@ optionalt<std::string> expr2ct::convert_function(const exprt &src)
39883988 {ID_live_object, " LIVE_OBJECT" },
39893989 {ID_writeable_object, " WRITEABLE_OBJECT" },
39903990 {ID_find_first_set, " __builtin_ffs" },
3991+ {ID_separate, " SEPARATE" },
39913992 {ID_floatbv_div, " FLOAT/" },
39923993 {ID_floatbv_minus, " FLOAT-" },
39933994 {ID_floatbv_mult, " FLOAT*" },
Original file line number Diff line number Diff line change @@ -457,6 +457,7 @@ IREP_ID_ONE(is_dynamic_object)
457457IREP_ID_ONE(dynamic_object)
458458IREP_ID_TWO(C_dynamic, #dynamic)
459459IREP_ID_ONE(object_size)
460+ IREP_ID_ONE(separate)
460461IREP_ID_ONE(good_pointer)
461462IREP_ID_ONE(live_object)
462463IREP_ID_ONE(writeable_object)
Original file line number Diff line number Diff line change @@ -1287,4 +1287,56 @@ inline writeable_object_exprt &to_writeable_object_expr(exprt &expr)
12871287 return ret;
12881288}
12891289
1290+ // / A predicate that indicates that the objects pointed to are distinct
1291+ class separate_exprt : public multi_ary_exprt
1292+ {
1293+ public:
1294+ explicit separate_exprt (exprt::operandst __operands)
1295+ : multi_ary_exprt(ID_separate, std::move(__operands), bool_typet())
1296+ {
1297+ }
1298+
1299+ separate_exprt (exprt __op0, exprt __op1)
1300+ : multi_ary_exprt(
1301+ std::move (__op0),
1302+ ID_separate,
1303+ std::move(__op1),
1304+ bool_typet())
1305+ {
1306+ }
1307+ };
1308+
1309+ template <>
1310+ inline bool can_cast_expr<separate_exprt>(const exprt &base)
1311+ {
1312+ return base.id () == ID_separate;
1313+ }
1314+
1315+ inline void validate_expr (const separate_exprt &value)
1316+ {
1317+ }
1318+
1319+ // / \brief Cast an exprt to a \ref separate_exprt
1320+ // /
1321+ // / \a expr must be known to be \ref separate_exprt.
1322+ // /
1323+ // / \param expr: Source expression
1324+ // / \return Object of type \ref separate_exprt
1325+ inline const separate_exprt &to_separate_expr (const exprt &expr)
1326+ {
1327+ PRECONDITION (expr.id () == ID_separate);
1328+ const separate_exprt &ret = static_cast <const separate_exprt &>(expr);
1329+ validate_expr (ret);
1330+ return ret;
1331+ }
1332+
1333+ // / \copydoc to_separate_expr(const exprt &)
1334+ inline separate_exprt &to_separate_expr (exprt &expr)
1335+ {
1336+ PRECONDITION (expr.id () == ID_separate);
1337+ separate_exprt &ret = static_cast <separate_exprt &>(expr);
1338+ validate_expr (ret);
1339+ return ret;
1340+ }
1341+
12901342#endif // CPROVER_UTIL_POINTER_EXPR_H
You can’t perform that action at this time.
0 commit comments