@@ -72,13 +72,7 @@ typedef __CPROVER_contracts_obj_set_t *__CPROVER_contracts_obj_set_ptr_t;
72
72
/// pointer equals, pointer_in_range_dfcc, pointer_is_fresh, obeys_contract.
73
73
typedef struct
74
74
{
75
- /// \brief Nondet variable ranging over the set of objects allocated
76
- /// by __CPROVER_contracts_is_fresh. Used to check separation constraints
77
- /// in __CPROVER_contracts_is_fresh.
78
- void * fresh_ptr ;
79
- /// \brief Nondet variable ranging over the set of locations storing
80
- /// pointers on which predicates were assumed/asserted. Used to ensure
81
- /// that at most one predicate is assumed per pointer.
75
+ __CPROVER_contracts_car_t fresh_car ;
82
76
void * * ptr_pred ;
83
77
} __CPROVER_contracts_ptr_pred_ctx_t ;
84
78
@@ -419,7 +413,8 @@ void __CPROVER_contracts_ptr_pred_ctx_init(
419
413
__CPROVER_contracts_ptr_pred_ctx_ptr_t set )
420
414
{
421
415
__CPROVER_HIDE :;
422
- set -> fresh_ptr = (void * )0 ;
416
+ set -> fresh_car = (__CPROVER_contracts_car_t ){
417
+ .is_writable = 0 , .size = 0 , .lb = (void * )0 , .ub = (void * )0 };
423
418
set -> ptr_pred = (void * * )0 ;
424
419
}
425
420
@@ -1345,10 +1340,10 @@ __CPROVER_HIDE:;
1345
1340
__VERIFIER_nondet___CPROVER_bool ()
1346
1341
? elem
1347
1342
: write_set -> linked_ptr_pred_ctx -> ptr_pred ;
1348
- write_set -> linked_ptr_pred_ctx -> fresh_ptr =
1343
+ write_set -> linked_ptr_pred_ctx -> fresh_car =
1349
1344
__VERIFIER_nondet___CPROVER_bool ()
1350
- ? ptr
1351
- : write_set -> linked_ptr_pred_ctx -> fresh_ptr ;
1345
+ ? __CPROVER_contracts_car_create ( ptr , size )
1346
+ : write_set -> linked_ptr_pred_ctx -> fresh_car ;
1352
1347
1353
1348
// record the object size for non-determistic bounds checking
1354
1349
__CPROVER_bool record_malloc = __VERIFIER_nondet___CPROVER_bool ();
@@ -1403,10 +1398,10 @@ __CPROVER_HIDE:;
1403
1398
__VERIFIER_nondet___CPROVER_bool ()
1404
1399
? elem
1405
1400
: write_set -> linked_ptr_pred_ctx -> ptr_pred ;
1406
- write_set -> linked_ptr_pred_ctx -> fresh_ptr =
1401
+ write_set -> linked_ptr_pred_ctx -> fresh_car =
1407
1402
__VERIFIER_nondet___CPROVER_bool ()
1408
- ? ptr
1409
- : write_set -> linked_ptr_pred_ctx -> fresh_ptr ;
1403
+ ? __CPROVER_contracts_car_create ( ptr , size )
1404
+ : write_set -> linked_ptr_pred_ctx -> fresh_car ;
1410
1405
1411
1406
// record the object size for non-determistic bounds checking
1412
1407
__CPROVER_bool record_malloc = __VERIFIER_nondet___CPROVER_bool ();
@@ -1440,11 +1435,15 @@ __CPROVER_HIDE:;
1440
1435
(write_set -> assume_ensures_ctx == 0 ),
1441
1436
"only one context flag at a time" );
1442
1437
#endif
1438
+ // check separation
1443
1439
void * ptr = * elem ;
1440
+ __CPROVER_contracts_car_t car = __CPROVER_contracts_car_create (ptr , size );
1441
+ __CPROVER_contracts_car_t fresh_car =
1442
+ write_set -> linked_ptr_pred_ctx -> fresh_car ;
1444
1443
if (
1445
- ptr != (void * )0 &&
1446
- !__CPROVER_same_object (write_set -> linked_ptr_pred_ctx -> fresh_ptr , ptr ) &&
1447
- __CPROVER_r_ok ( ptr , size ))
1444
+ ptr != (void * )0 && __CPROVER_r_ok ( ptr , size ) &&
1445
+ ( !__CPROVER_same_object (car . lb , fresh_car . lb ) ||
1446
+ ( car . ub <= fresh_car . lb ) || ( fresh_car . ub <= car . lb ) ))
1448
1447
{
1449
1448
__CPROVER_assert (
1450
1449
write_set -> linked_ptr_pred_ctx -> ptr_pred != elem ,
@@ -1454,10 +1453,10 @@ __CPROVER_HIDE:;
1454
1453
__VERIFIER_nondet___CPROVER_bool ()
1455
1454
? elem
1456
1455
: write_set -> linked_ptr_pred_ctx -> ptr_pred ;
1457
- write_set -> linked_ptr_pred_ctx -> fresh_ptr =
1456
+ write_set -> linked_ptr_pred_ctx -> fresh_car =
1458
1457
__VERIFIER_nondet___CPROVER_bool ()
1459
- ? ptr
1460
- : write_set -> linked_ptr_pred_ctx -> fresh_ptr ;
1458
+ ? car
1459
+ : write_set -> linked_ptr_pred_ctx -> fresh_car ;
1461
1460
return 1 ;
1462
1461
}
1463
1462
return 0 ;
0 commit comments