File tree Expand file tree Collapse file tree 5 files changed +71
-0
lines changed Expand file tree Collapse file tree 5 files changed +71
-0
lines changed Original file line number Diff line number Diff line change @@ -2524,6 +2524,22 @@ exprt c_typecheck_baset::do_special_functions(
2524
2524
2525
2525
return writeable_object_expr;
2526
2526
}
2527
+ else if (identifier == CPROVER_PREFIX " separate" )
2528
+ {
2529
+ if (expr.arguments ().size () < 2 )
2530
+ {
2531
+ error ().source_location = f_op.source_location ();
2532
+ error () << " separate expects two or more arguments" << eom;
2533
+ throw 0 ;
2534
+ }
2535
+
2536
+ typecheck_function_call_arguments (expr);
2537
+
2538
+ exprt separate_expr = separate_exprt (expr.arguments ());
2539
+ separate_expr.add_source_location () = source_location;
2540
+
2541
+ return separate_expr;
2542
+ }
2527
2543
else if (identifier==CPROVER_PREFIX " POINTER_OFFSET" )
2528
2544
{
2529
2545
if (expr.arguments ().size ()!=1 )
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ __CPROVER_size_t __CPROVER_POINTER_OBJECT(const void *);
54
54
__CPROVER_ssize_t __CPROVER_POINTER_OFFSET (const void * );
55
55
__CPROVER_size_t __CPROVER_OBJECT_SIZE (const void * );
56
56
__CPROVER_bool __CPROVER_DYNAMIC_OBJECT (const void * );
57
+ __CPROVER_bool __CPROVER_separate (const void * , const void * , ...);
57
58
void __CPROVER_allocated_memory (__CPROVER_size_t address , __CPROVER_size_t extent );
58
59
59
60
// float stuff
Original file line number Diff line number Diff line change @@ -3995,6 +3995,7 @@ optionalt<std::string> expr2ct::convert_function(const exprt &src)
3995
3995
{ID_dynamic_object, " DYNAMIC_OBJECT" },
3996
3996
{ID_live_object, " LIVE_OBJECT" },
3997
3997
{ID_writeable_object, " WRITEABLE_OBJECT" },
3998
+ {ID_separate, " SEPARATE" },
3998
3999
{ID_floatbv_div, " FLOAT/" },
3999
4000
{ID_floatbv_minus, " FLOAT-" },
4000
4001
{ID_floatbv_mult, " FLOAT*" },
Original file line number Diff line number Diff line change @@ -456,6 +456,7 @@ IREP_ID_TWO(C_dynamic, #dynamic)
456
456
IREP_ID_ONE(live_object)
457
457
IREP_ID_ONE(writeable_object)
458
458
IREP_ID_ONE(object_size)
459
+ IREP_ID_ONE(separate)
459
460
IREP_ID_ONE(good_pointer)
460
461
IREP_ID_ONE(integer_address)
461
462
IREP_ID_ONE(integer_address_object)
Original file line number Diff line number Diff line change @@ -1172,4 +1172,56 @@ inline writeable_object_exprt &to_writeable_object_expr(exprt &expr)
1172
1172
return ret;
1173
1173
}
1174
1174
1175
+ // / A predicate that indicates that the objects pointed to are distinct
1176
+ class separate_exprt : public multi_ary_exprt
1177
+ {
1178
+ public:
1179
+ explicit separate_exprt (exprt::operandst __operands)
1180
+ : multi_ary_exprt(ID_separate, std::move(__operands), bool_typet())
1181
+ {
1182
+ }
1183
+
1184
+ separate_exprt (exprt __op0, exprt __op1)
1185
+ : multi_ary_exprt(
1186
+ std::move (__op0),
1187
+ ID_separate,
1188
+ std::move(__op1),
1189
+ bool_typet())
1190
+ {
1191
+ }
1192
+ };
1193
+
1194
+ template <>
1195
+ inline bool can_cast_expr<separate_exprt>(const exprt &base)
1196
+ {
1197
+ return base.id () == ID_separate;
1198
+ }
1199
+
1200
+ inline void validate_expr (const separate_exprt &value)
1201
+ {
1202
+ }
1203
+
1204
+ // / \brief Cast an exprt to a \ref separate_exprt
1205
+ // /
1206
+ // / \a expr must be known to be \ref separate_exprt.
1207
+ // /
1208
+ // / \param expr: Source expression
1209
+ // / \return Object of type \ref separate_exprt
1210
+ inline const separate_exprt &to_separate_expr (const exprt &expr)
1211
+ {
1212
+ PRECONDITION (expr.id () == ID_separate);
1213
+ const separate_exprt &ret = static_cast <const separate_exprt &>(expr);
1214
+ validate_expr (ret);
1215
+ return ret;
1216
+ }
1217
+
1218
+ // / \copydoc to_separate_expr(const exprt &)
1219
+ inline separate_exprt &to_separate_expr (exprt &expr)
1220
+ {
1221
+ PRECONDITION (expr.id () == ID_separate);
1222
+ separate_exprt &ret = static_cast <separate_exprt &>(expr);
1223
+ validate_expr (ret);
1224
+ return ret;
1225
+ }
1226
+
1175
1227
#endif // CPROVER_UTIL_POINTER_EXPR_H
You can’t perform that action at this time.
0 commit comments