@@ -291,17 +291,18 @@ void dfcc_wrapper_programt::encode_requires_write_set()
291
291
// assume_ensures_ctx = false,
292
292
// assert_ensures_ctx = false,
293
293
// )
294
- const auto write_set = requires_write_set;
295
- preamble.add (goto_programt::make_decl (write_set, wrapper_sl));
294
+ preamble.add (goto_programt::make_decl (requires_write_set, wrapper_sl));
296
295
297
- const auto address_of_write_set = addr_of_requires_write_set;
298
- preamble. add ( goto_programt::make_decl (address_of_write_set , wrapper_sl));
296
+ preamble. add (
297
+ goto_programt::make_decl (addr_of_requires_write_set , wrapper_sl));
299
298
preamble.add (goto_programt::make_assignment (
300
- address_of_write_set, address_of_exprt (write_set), wrapper_sl));
299
+ addr_of_requires_write_set,
300
+ address_of_exprt (requires_write_set),
301
+ wrapper_sl));
301
302
302
303
bool check_mode = contract_mode == dfcc_contract_modet::CHECK;
303
304
code_function_callt call = library.write_set_create_call (
304
- address_of_write_set ,
305
+ addr_of_requires_write_set ,
305
306
from_integer (0 , size_type ()),
306
307
from_integer (0 , size_type ()),
307
308
make_boolean_expr (check_mode),
@@ -317,7 +318,7 @@ void dfcc_wrapper_programt::encode_requires_write_set()
317
318
// check for absence of allocation/deallocation in requires clauses
318
319
// ```c
319
320
// DECL __check_no_alloc: bool;
320
- // CALL __check_no_alloc = check_empty_alloc_dealloc(write_set );
321
+ // CALL __check_no_alloc = check_empty_alloc_dealloc(requilres_write_set );
321
322
// ASSERT __check_no_alloc;
322
323
// DEAD __check_no_alloc: bool;
323
324
// ```
@@ -334,7 +335,7 @@ void dfcc_wrapper_programt::encode_requires_write_set()
334
335
335
336
postamble.add (goto_programt::make_function_call (
336
337
library.write_set_check_allocated_deallocated_is_empty_call (
337
- check_var, address_of_write_set , wrapper_sl),
338
+ check_var, addr_of_requires_write_set , wrapper_sl),
338
339
wrapper_sl));
339
340
340
341
source_locationt check_sl (wrapper_sl);
@@ -347,9 +348,9 @@ void dfcc_wrapper_programt::encode_requires_write_set()
347
348
348
349
// generate write set release and DEAD instructions
349
350
postamble.add (goto_programt::make_function_call (
350
- library.write_set_release_call (address_of_write_set , wrapper_sl),
351
+ library.write_set_release_call (addr_of_requires_write_set , wrapper_sl),
351
352
wrapper_sl));
352
- postamble.add (goto_programt::make_dead (write_set , wrapper_sl));
353
+ postamble.add (goto_programt::make_dead (requires_write_set , wrapper_sl));
353
354
}
354
355
355
356
void dfcc_wrapper_programt::encode_ensures_write_set ()
@@ -363,18 +364,18 @@ void dfcc_wrapper_programt::encode_ensures_write_set()
363
364
// assume_ensures_ctx = contract_mode != check,
364
365
// assert_ensures_ctx = contract_mode == check,
365
366
// )
366
- const auto write_set = ensures_write_set;
367
- preamble.add (goto_programt::make_decl (write_set, wrapper_sl));
367
+ preamble.add (goto_programt::make_decl (ensures_write_set, wrapper_sl));
368
368
369
- const auto address_of_write_set = addr_of_ensures_write_set;
370
- preamble.add (goto_programt::make_decl (address_of_write_set, wrapper_sl));
369
+ preamble.add (goto_programt::make_decl (addr_of_ensures_write_set, wrapper_sl));
371
370
preamble.add (goto_programt::make_assignment (
372
- address_of_write_set, address_of_exprt (write_set), wrapper_sl));
371
+ addr_of_ensures_write_set,
372
+ address_of_exprt (ensures_write_set),
373
+ wrapper_sl));
373
374
374
375
bool check_mode = contract_mode == dfcc_contract_modet::CHECK;
375
376
376
377
code_function_callt call = library.write_set_create_call (
377
- address_of_write_set ,
378
+ addr_of_ensures_write_set ,
378
379
from_integer (0 , size_type ()),
379
380
from_integer (0 , size_type ()),
380
381
false_exprt (),
@@ -392,14 +393,14 @@ void dfcc_wrapper_programt::encode_ensures_write_set()
392
393
{
393
394
link_allocated_caller.add (goto_programt::make_function_call (
394
395
library.link_allocated_call (
395
- address_of_write_set , caller_write_set, wrapper_sl),
396
+ addr_of_ensures_write_set , caller_write_set, wrapper_sl),
396
397
wrapper_sl));
397
398
}
398
399
399
400
// check for absence of allocation/deallocation in contract clauses
400
401
// ```c
401
402
// DECL __check_no_alloc: bool;
402
- // CALL __check_no_alloc = check_empty_alloc_dealloc(write_set );
403
+ // CALL __check_no_alloc = check_empty_alloc_dealloc(ensures_write_set );
403
404
// ASSERT __check_no_alloc;
404
405
// DEAD __check_no_alloc: bool;
405
406
// ```
@@ -416,7 +417,7 @@ void dfcc_wrapper_programt::encode_ensures_write_set()
416
417
417
418
postamble.add (goto_programt::make_function_call (
418
419
library.write_set_check_allocated_deallocated_is_empty_call (
419
- check_var, address_of_write_set , wrapper_sl),
420
+ check_var, addr_of_ensures_write_set , wrapper_sl),
420
421
wrapper_sl));
421
422
422
423
source_locationt check_sl (wrapper_sl);
@@ -430,32 +431,33 @@ void dfcc_wrapper_programt::encode_ensures_write_set()
430
431
431
432
// generate write set release
432
433
postamble.add (goto_programt::make_function_call (
433
- library.write_set_release_call (address_of_write_set , wrapper_sl),
434
+ library.write_set_release_call (addr_of_ensures_write_set , wrapper_sl),
434
435
wrapper_sl));
435
436
436
437
// declare write set DEAD
437
- postamble.add (goto_programt::make_dead (write_set , wrapper_sl));
438
+ postamble.add (goto_programt::make_dead (ensures_write_set , wrapper_sl));
438
439
}
439
440
440
441
void dfcc_wrapper_programt::encode_contract_write_set ()
441
442
{
442
- const auto write_set = contract_write_set;
443
- preamble.add (goto_programt::make_decl (write_set, wrapper_sl));
443
+ preamble.add (goto_programt::make_decl (contract_write_set, wrapper_sl));
444
444
445
- const auto address_of_contract_write_set = addr_of_contract_write_set;
446
445
preamble.add (
447
- goto_programt::make_decl (address_of_contract_write_set , wrapper_sl));
446
+ goto_programt::make_decl (addr_of_contract_write_set , wrapper_sl));
448
447
preamble.add (goto_programt::make_assignment (
449
- address_of_contract_write_set, address_of_exprt (write_set), wrapper_sl));
448
+ addr_of_contract_write_set,
449
+ address_of_exprt (contract_write_set),
450
+ wrapper_sl));
450
451
451
452
// We use the empty write set used to check ensures for side effects
452
453
// to check for side effects in the assigns and frees functions as well
453
- const auto address_of_requires_write_set = addr_of_requires_write_set;
454
+ // TODO: I don't know what the above comment means, why was there an empty
455
+ // write set here?
454
456
455
457
// call write_set_create
456
458
{
457
459
code_function_callt call = library.write_set_create_call (
458
- address_of_contract_write_set ,
460
+ addr_of_contract_write_set ,
459
461
from_integer (contract_functions.get_nof_assigns_targets (), size_type ()),
460
462
from_integer (contract_functions.get_nof_frees_targets (), size_type ()),
461
463
false_exprt (),
@@ -489,10 +491,10 @@ void dfcc_wrapper_programt::encode_contract_write_set()
489
491
arguments.push_back (arg);
490
492
491
493
// pass write set to populate
492
- arguments.emplace_back (address_of_contract_write_set );
494
+ arguments.emplace_back (addr_of_contract_write_set );
493
495
494
496
// pass the empty write set to check side effects against
495
- arguments.emplace_back (address_of_requires_write_set );
497
+ arguments.emplace_back (addr_of_requires_write_set );
496
498
497
499
write_set_checks.add (goto_programt::make_function_call (call, wrapper_sl));
498
500
}
@@ -508,56 +510,55 @@ void dfcc_wrapper_programt::encode_contract_write_set()
508
510
arguments.push_back (arg);
509
511
510
512
// pass write set to populate
511
- arguments.emplace_back (address_of_contract_write_set );
513
+ arguments.emplace_back (addr_of_contract_write_set );
512
514
513
515
// pass the empty write set to check side effects against
514
- arguments.emplace_back (address_of_requires_write_set );
516
+ arguments.emplace_back (addr_of_requires_write_set );
515
517
516
518
write_set_checks.add (goto_programt::make_function_call (call, wrapper_sl));
517
519
}
518
520
519
521
// generate write set release and DEAD instructions
520
522
postamble.add (goto_programt::make_function_call (
521
- library.write_set_release_call (address_of_contract_write_set , wrapper_sl),
523
+ library.write_set_release_call (addr_of_contract_write_set , wrapper_sl),
522
524
wrapper_sl));
523
- postamble.add (goto_programt::make_dead (write_set, wrapper_sl));
525
+ postamble.add (
526
+ goto_programt::make_dead (addr_of_contract_write_set, wrapper_sl));
524
527
}
525
528
526
529
void dfcc_wrapper_programt::encode_is_fresh_set ()
527
530
{
528
- const auto object_set = is_fresh_set;
529
- preamble.add (goto_programt::make_decl (object_set, wrapper_sl));
531
+ preamble.add (goto_programt::make_decl (is_fresh_set, wrapper_sl));
530
532
531
- const auto address_of_object_set = addr_of_is_fresh_set;
532
- preamble.add (goto_programt::make_decl (address_of_object_set, wrapper_sl));
533
+ preamble.add (goto_programt::make_decl (addr_of_is_fresh_set, wrapper_sl));
533
534
preamble.add (goto_programt::make_assignment (
534
- address_of_object_set , address_of_exprt (object_set ), wrapper_sl));
535
+ addr_of_is_fresh_set , address_of_exprt (is_fresh_set ), wrapper_sl));
535
536
536
537
// CALL obj_set_create_indexed_by_object_id(is_fresh_set) in preamble
537
538
preamble.add (goto_programt::make_function_call (
538
539
library.obj_set_create_indexed_by_object_id_call (
539
- address_of_object_set , wrapper_sl),
540
+ addr_of_is_fresh_set , wrapper_sl),
540
541
wrapper_sl));
541
542
542
543
// link to requires write set
543
544
link_is_fresh.add (goto_programt::make_function_call (
544
545
library.link_is_fresh_call (
545
- addr_of_requires_write_set, address_of_object_set , wrapper_sl),
546
+ addr_of_requires_write_set, addr_of_is_fresh_set , wrapper_sl),
546
547
wrapper_sl));
547
548
548
549
// link to ensures write set
549
550
link_is_fresh.add (goto_programt::make_function_call (
550
551
library.link_is_fresh_call (
551
- addr_of_ensures_write_set, address_of_object_set , wrapper_sl),
552
+ addr_of_ensures_write_set, addr_of_is_fresh_set , wrapper_sl),
552
553
wrapper_sl));
553
554
554
555
// release call in postamble
555
556
postamble.add (goto_programt::make_function_call (
556
- library.obj_set_release_call (address_of_object_set , wrapper_sl),
557
+ library.obj_set_release_call (addr_of_is_fresh_set , wrapper_sl),
557
558
wrapper_sl));
558
559
559
560
// DEAD instructions in postamble
560
- postamble.add (goto_programt::make_dead (object_set , wrapper_sl));
561
+ postamble.add (goto_programt::make_dead (is_fresh_set , wrapper_sl));
561
562
}
562
563
563
564
void dfcc_wrapper_programt::encode_requires_clauses ()
@@ -594,7 +595,6 @@ void dfcc_wrapper_programt::encode_requires_clauses()
594
595
codet requires_statement (statement_type, {std::move (requires )}, sl);
595
596
converter.goto_convert (requires_statement, requires_program, language_mode);
596
597
}
597
- const auto address_of_requires_write_set = addr_of_requires_write_set;
598
598
599
599
// fix calls to user-defined memory predicates
600
600
memory_predicates.fix_calls (requires_program);
@@ -603,7 +603,7 @@ void dfcc_wrapper_programt::encode_requires_clauses()
603
603
instrument.instrument_goto_program (
604
604
wrapper_id,
605
605
requires_program,
606
- address_of_requires_write_set ,
606
+ addr_of_requires_write_set ,
607
607
function_pointer_contracts);
608
608
609
609
// append resulting program to preconditions section
@@ -626,8 +626,9 @@ void dfcc_wrapper_programt::encode_ensures_clauses()
626
626
// translate each ensures clause
627
627
for (const auto &e : contract_code_type.ensures ())
628
628
{
629
- exprt ensures = to_lambda_expr (e).application (contract_lambda_parameters);
630
- ensures.add_source_location () = e.source_location ();
629
+ exprt ensures = to_lambda_expr (e)
630
+ .application (contract_lambda_parameters)
631
+ .with_source_location <exprt>(e);
631
632
632
633
if (has_subexpr (ensures, ID_exists) || has_subexpr (ensures, ID_forall))
633
634
add_quantified_variable (goto_model.symbol_table , ensures, language_mode);
@@ -652,14 +653,12 @@ void dfcc_wrapper_programt::encode_ensures_clauses()
652
653
converter.goto_convert (ensures_statement, ensures_program, language_mode);
653
654
}
654
655
655
- const auto address_of_ensures_write_set = addr_of_ensures_write_set;
656
-
657
656
// When checking an ensures clause we link the contract write set to the
658
657
// ensures write set to know what was deallocated by the function so that
659
658
// the was_freed predicate can perform its checks
660
659
link_deallocated_contract.add (goto_programt::make_function_call (
661
660
library.link_deallocated_call (
662
- address_of_ensures_write_set , addr_of_contract_write_set, wrapper_sl),
661
+ addr_of_ensures_write_set , addr_of_contract_write_set, wrapper_sl),
663
662
wrapper_sl));
664
663
665
664
// fix calls to user-defined user-defined memory predicates
@@ -669,7 +668,7 @@ void dfcc_wrapper_programt::encode_ensures_clauses()
669
668
instrument.instrument_goto_program (
670
669
wrapper_id,
671
670
ensures_program,
672
- address_of_ensures_write_set ,
671
+ addr_of_ensures_write_set ,
673
672
function_pointer_contracts);
674
673
675
674
// add the snapshot program in the history section
@@ -735,8 +734,6 @@ void dfcc_wrapper_programt::encode_havoced_function_call()
735
734
write_set_arguments.push_back (parameter_symbol.symbol_expr ());
736
735
}
737
736
738
- auto address_of_contract_write_set = addr_of_contract_write_set;
739
-
740
737
// check assigns clause inclusion
741
738
// IF __caller_write_set==NULL GOTO skip_target;
742
739
// DECL check: bool;
@@ -768,7 +765,7 @@ void dfcc_wrapper_programt::encode_havoced_function_call()
768
765
769
766
write_set_checks.add (goto_programt::make_function_call (
770
767
library.write_set_check_assigns_clause_inclusion_call (
771
- check_var, caller_write_set, address_of_contract_write_set , wrapper_sl),
768
+ check_var, caller_write_set, addr_of_contract_write_set , wrapper_sl),
772
769
wrapper_sl));
773
770
774
771
source_locationt check_sl (wrapper_sl);
@@ -796,7 +793,7 @@ void dfcc_wrapper_programt::encode_havoced_function_call()
796
793
797
794
write_set_checks.add (goto_programt::make_function_call (
798
795
library.write_set_check_frees_clause_inclusion_call (
799
- check_var, caller_write_set, address_of_contract_write_set , wrapper_sl),
796
+ check_var, caller_write_set, addr_of_contract_write_set , wrapper_sl),
800
797
wrapper_sl));
801
798
802
799
source_locationt check_sl (wrapper_sl);
@@ -814,7 +811,7 @@ void dfcc_wrapper_programt::encode_havoced_function_call()
814
811
815
812
code_function_callt havoc_call (
816
813
contract_functions.get_spec_assigns_havoc_function_symbol ().symbol_expr (),
817
- {address_of_contract_write_set });
814
+ {addr_of_contract_write_set });
818
815
819
816
function_call.add (goto_programt::make_function_call (havoc_call, wrapper_sl));
820
817
@@ -844,6 +841,6 @@ void dfcc_wrapper_programt::encode_havoced_function_call()
844
841
// set and the caller write set
845
842
function_call.add (goto_programt::make_function_call (
846
843
library.write_set_deallocate_freeable_call (
847
- address_of_contract_write_set , caller_write_set, wrapper_sl),
844
+ addr_of_contract_write_set , caller_write_set, wrapper_sl),
848
845
wrapper_sl));
849
846
}
0 commit comments