Skip to content

Commit 9e14d8a

Browse files
author
Remi Delmas
committed
CONTRACTS: pointer predicates now use dfcc_cfg_infot
1 parent 521fa25 commit 9e14d8a

8 files changed

+34
-26
lines changed

src/goto-instrument/contracts/dynamic-frames/dfcc_is_freeable.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Date: August 2022
1212
#include <util/std_expr.h>
1313
#include <util/symbol.h>
1414

15+
#include "dfcc_cfg_info.h"
1516
#include "dfcc_library.h"
1617

1718
dfcc_is_freeablet::dfcc_is_freeablet(
@@ -23,20 +24,20 @@ dfcc_is_freeablet::dfcc_is_freeablet(
2324

2425
void dfcc_is_freeablet::rewrite_calls(
2526
goto_programt &program,
26-
const exprt &write_set)
27+
dfcc_cfg_infot &cfg_info)
2728
{
2829
rewrite_calls(
2930
program,
3031
program.instructions.begin(),
3132
program.instructions.end(),
32-
write_set);
33+
cfg_info);
3334
}
3435

3536
void dfcc_is_freeablet::rewrite_calls(
3637
goto_programt &program,
3738
goto_programt::targett first_instruction,
3839
const goto_programt::targett &last_instruction,
39-
const exprt &write_set)
40+
dfcc_cfg_infot &cfg_info)
4041
{
4142
auto target = first_instruction;
4243
while(target != last_instruction)
@@ -54,15 +55,15 @@ void dfcc_is_freeablet::rewrite_calls(
5455
// redirect call to library implementation
5556
to_symbol_expr(target->call_function())
5657
.set_identifier(library.get_dfcc_fun_name(dfcc_funt::IS_FREEABLE));
57-
target->call_arguments().push_back(write_set);
58+
target->call_arguments().push_back(cfg_info.get_write_set(target));
5859
}
5960
else if(fun_name == CPROVER_PREFIX "was_freed")
6061
{
6162
// insert call to precondition for vacuity checking
6263
auto inst = goto_programt::make_function_call(
6364
library.check_replace_ensures_was_freed_preconditions_call(
6465
target->call_arguments().at(0),
65-
write_set,
66+
cfg_info.get_write_set(target),
6667
target->source_location()),
6768
target->source_location());
6869
program.insert_before_swap(target, inst);
@@ -71,7 +72,7 @@ void dfcc_is_freeablet::rewrite_calls(
7172
// redirect call to library implementation
7273
to_symbol_expr(target->call_function())
7374
.set_identifier(library.get_dfcc_fun_name(dfcc_funt::WAS_FREED));
74-
target->call_arguments().push_back(write_set);
75+
target->call_arguments().push_back(cfg_info.get_write_set(target));
7576
}
7677
}
7778
}

src/goto-instrument/contracts/dynamic-frames/dfcc_is_freeable.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Date: August 2022
2121
class goto_modelt;
2222
class message_handlert;
2323
class dfcc_libraryt;
24+
class dfcc_cfg_infot;
2425
class exprt;
2526

2627
/// Rewrites calls to is_freeable and was_freed predicates in goto programs
@@ -35,7 +36,7 @@ class dfcc_is_freeablet
3536
/// Rewrites calls to is_freeable and was_freed predicates into calls
3637
/// to the library implementation in the given program, passing the
3738
/// given write_set expression as parameter to the library function.
38-
void rewrite_calls(goto_programt &program, const exprt &write_set);
39+
void rewrite_calls(goto_programt &program, dfcc_cfg_infot &cfg_info);
3940

4041
/// Rewrites calls to is_fresh predicates into calls
4142
/// to the library implementation in the given program between
@@ -45,7 +46,7 @@ class dfcc_is_freeablet
4546
goto_programt &program,
4647
goto_programt::targett first_instruction,
4748
const goto_programt::targett &last_instruction, // excluding the last
48-
const exprt &write_set);
49+
dfcc_cfg_infot &cfg_info);
4950

5051
protected:
5152
dfcc_libraryt &library;

src/goto-instrument/contracts/dynamic-frames/dfcc_is_fresh.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Date: August 2022
1313
#include <util/pointer_expr.h>
1414
#include <util/symbol.h>
1515

16+
#include "dfcc_cfg_info.h"
1617
#include "dfcc_library.h"
1718

1819
dfcc_is_fresht::dfcc_is_fresht(
@@ -24,20 +25,20 @@ dfcc_is_fresht::dfcc_is_fresht(
2425

2526
void dfcc_is_fresht::rewrite_calls(
2627
goto_programt &program,
27-
const exprt &write_set)
28+
dfcc_cfg_infot &cfg_info)
2829
{
2930
rewrite_calls(
3031
program,
3132
program.instructions.begin(),
3233
program.instructions.end(),
33-
write_set);
34+
cfg_info);
3435
}
3536

3637
void dfcc_is_fresht::rewrite_calls(
3738
goto_programt &program,
3839
goto_programt::targett first_instruction,
3940
const goto_programt::targett &last_instruction,
40-
const exprt &write_set)
41+
dfcc_cfg_infot &cfg_info)
4142
{
4243
auto &target = first_instruction;
4344
while(target != last_instruction)
@@ -61,7 +62,7 @@ void dfcc_is_fresht::rewrite_calls(
6162
.set_identifier(library.dfcc_fun_symbol[dfcc_funt::IS_FRESH].name);
6263

6364
// pass the write_set
64-
target->call_arguments().push_back(write_set);
65+
target->call_arguments().push_back(cfg_info.get_write_set(target));
6566
}
6667
}
6768
}

src/goto-instrument/contracts/dynamic-frames/dfcc_is_fresh.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Date: August 2022
2121
class goto_modelt;
2222
class message_handlert;
2323
class dfcc_libraryt;
24+
class dfcc_cfg_infot;
2425
class exprt;
2526

2627
/// Rewrites calls to is_fresh predicates into calls
@@ -35,7 +36,7 @@ class dfcc_is_fresht
3536
/// Rewrites calls to is_fresh predicates into calls
3637
/// to the library implementation in the given program, passing the
3738
/// given write_set expression as parameter to the library function.
38-
void rewrite_calls(goto_programt &program, const exprt &write_set);
39+
void rewrite_calls(goto_programt &program, dfcc_cfg_infot &cfg_info);
3940

4041
/// Rewrites calls to is_fresh predicates into calls
4142
/// to the library implementation in the given program between
@@ -45,7 +46,7 @@ class dfcc_is_fresht
4546
goto_programt &program,
4647
goto_programt::targett first_instruction,
4748
const goto_programt::targett &last_instruction,
48-
const exprt &write_set);
49+
dfcc_cfg_infot &cfg_info);
4950

5051
protected:
5152
dfcc_libraryt &library;

src/goto-instrument/contracts/dynamic-frames/dfcc_obeys_contract.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Date: August 2022
1616

1717
#include <langapi/language_util.h>
1818

19+
#include "dfcc_cfg_info.h"
1920
#include "dfcc_library.h"
2021

2122
dfcc_obeys_contractt::dfcc_obeys_contractt(
@@ -27,14 +28,14 @@ dfcc_obeys_contractt::dfcc_obeys_contractt(
2728

2829
void dfcc_obeys_contractt::rewrite_calls(
2930
goto_programt &program,
30-
const exprt &write_set,
31+
dfcc_cfg_infot &cfg_info,
3132
std::set<irep_idt> &function_pointer_contracts)
3233
{
3334
rewrite_calls(
3435
program,
3536
program.instructions.begin(),
3637
program.instructions.end(),
37-
write_set,
38+
cfg_info,
3839
function_pointer_contracts);
3940
}
4041

@@ -62,7 +63,7 @@ void dfcc_obeys_contractt::rewrite_calls(
6263
goto_programt &program,
6364
goto_programt::targett first_instruction,
6465
const goto_programt::targett &last_instruction,
65-
const exprt &write_set,
66+
dfcc_cfg_infot &cfg_info,
6667
std::set<irep_idt> &function_pointer_contracts)
6768
{
6869
for(auto &target = first_instruction; target != last_instruction; target++)
@@ -87,7 +88,7 @@ void dfcc_obeys_contractt::rewrite_calls(
8788
library.dfcc_fun_symbol[dfcc_funt::OBEYS_CONTRACT].name);
8889

8990
// pass the write_set
90-
target->call_arguments().push_back(write_set);
91+
target->call_arguments().push_back(cfg_info.get_write_set(target));
9192

9293
// record discovered function contract
9394
get_contract_name(

src/goto-instrument/contracts/dynamic-frames/dfcc_obeys_contract.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Date: August 2022
2121
class goto_modelt;
2222
class message_handlert;
2323
class dfcc_libraryt;
24+
class dfcc_cfg_infot;
2425
class exprt;
2526

2627
/// Rewrites calls to obeys_contract predicates into calls
@@ -39,7 +40,7 @@ class dfcc_obeys_contractt
3940
/// given write_set expression as parameter to the library function.
4041
void rewrite_calls(
4142
goto_programt &program,
42-
const exprt &write_set,
43+
dfcc_cfg_infot &cfg_info,
4344
std::set<irep_idt> &function_pointer_contracts);
4445

4546
/// Rewrites calls to obeys_contract predicates into calls
@@ -50,7 +51,7 @@ class dfcc_obeys_contractt
5051
goto_programt &program,
5152
goto_programt::targett first_instruction,
5253
const goto_programt::targett &last_instruction,
53-
const exprt &write_set,
54+
dfcc_cfg_infot &cfg_info,
5455
std::set<irep_idt> &function_pointer_contracts);
5556

5657
protected:

src/goto-instrument/contracts/dynamic-frames/dfcc_pointer_in_range.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Date: August 2022
1515
#include <util/std_code.h>
1616
#include <util/symbol.h>
1717

18+
#include "dfcc_cfg_info.h"
1819
#include "dfcc_library.h"
1920

2021
dfcc_pointer_in_ranget::dfcc_pointer_in_ranget(
@@ -26,20 +27,20 @@ dfcc_pointer_in_ranget::dfcc_pointer_in_ranget(
2627

2728
void dfcc_pointer_in_ranget::rewrite_calls(
2829
goto_programt &program,
29-
const exprt &write_set)
30+
dfcc_cfg_infot cfg_info)
3031
{
3132
rewrite_calls(
3233
program,
3334
program.instructions.begin(),
3435
program.instructions.end(),
35-
write_set);
36+
cfg_info);
3637
}
3738

3839
void dfcc_pointer_in_ranget::rewrite_calls(
3940
goto_programt &program,
4041
goto_programt::targett first_instruction,
4142
const goto_programt::targett &last_instruction,
42-
const exprt &write_set)
43+
dfcc_cfg_infot cfg_info)
4344
{
4445
auto &target = first_instruction;
4546
while(target != last_instruction)
@@ -64,7 +65,7 @@ void dfcc_pointer_in_ranget::rewrite_calls(
6465
library.dfcc_fun_symbol[dfcc_funt::POINTER_IN_RANGE_DFCC].name);
6566

6667
// pass the write_set
67-
target->call_arguments().push_back(write_set);
68+
target->call_arguments().push_back(cfg_info.get_write_set(target));
6869
}
6970
}
7071
}

src/goto-instrument/contracts/dynamic-frames/dfcc_pointer_in_range.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Date: August 2022
2121
class goto_modelt;
2222
class message_handlert;
2323
class dfcc_libraryt;
24+
class dfcc_cfg_infot;
2425
class exprt;
2526

2627
/// Rewrites calls to pointer_in_range predicates into calls
@@ -37,7 +38,7 @@ class dfcc_pointer_in_ranget
3738
/// Rewrites calls to pointer_in_range predicates into calls
3839
/// to the library implementation in the given program, passing the
3940
/// given write_set expression as parameter to the library function.
40-
void rewrite_calls(goto_programt &program, const exprt &write_set);
41+
void rewrite_calls(goto_programt &program, dfcc_cfg_infot cfg_info);
4142

4243
/// Rewrites calls to pointer_in_range predicates into calls
4344
/// to the library implementation in the given program between
@@ -47,7 +48,7 @@ class dfcc_pointer_in_ranget
4748
goto_programt &program,
4849
goto_programt::targett first_instruction,
4950
const goto_programt::targett &last_instruction,
50-
const exprt &write_set);
51+
dfcc_cfg_infot cfg_info);
5152

5253
protected:
5354
dfcc_libraryt &library;

0 commit comments

Comments
 (0)