File tree Expand file tree Collapse file tree 5 files changed +131
-0
lines changed
Expand file tree Collapse file tree 5 files changed +131
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ SRC = accelerate/accelerate.cpp \
1919 contracts/contracts.cpp \
2020 contracts/dynamic-frames/dfcc_utils.cpp \
2121 contracts/dynamic-frames/dfcc_loop_nesting_graph.cpp \
22+ contracts/dynamic-frames/dfcc_contract_mode.cpp \
23+ contracts/dynamic-frames/dfcc_loop_contract_mode.cpp \
2224 contracts/dynamic-frames/dfcc_library.cpp \
2325 contracts/dynamic-frames/dfcc_is_cprover_symbol.cpp \
2426 contracts/dynamic-frames/dfcc_is_fresh.cpp \
Original file line number Diff line number Diff line change 1+ /* ******************************************************************\
2+
3+ Module: Dynamic frame condition checking for function contracts
4+
5+ Author: Remi Delmas, delmasrd@amazon.com
6+
7+ Date: March 2023
8+
9+ \*******************************************************************/
10+
11+ #include " dfcc_contract_mode.h"
12+
13+ #include < util/invariant.h>
14+
15+ std::string dfcc_contract_mode_to_string (const dfcc_contract_modet mode)
16+ {
17+ switch (mode)
18+ {
19+ case dfcc_contract_modet::CHECK:
20+ return " dfcc_contract_modet::CHECK" ;
21+ case dfcc_contract_modet::REPLACE:
22+ return " dfcc_contract_modet::REPLACE" ;
23+ }
24+ UNREACHABLE;
25+ }
26+
27+ std::ostream &operator <<(std::ostream &os, const dfcc_contract_modet mode)
28+ {
29+ os << dfcc_contract_mode_to_string (mode);
30+ return os;
31+ }
Original file line number Diff line number Diff line change @@ -13,11 +13,17 @@ Date: August 2022
1313#ifndef CPROVER_GOTO_INSTRUMENT_CONTRACTS_DYNAMIC_FRAMES_DFCC_CONTRACT_MODE_H
1414#define CPROVER_GOTO_INSTRUMENT_CONTRACTS_DYNAMIC_FRAMES_DFCC_CONTRACT_MODE_H
1515
16+ #include < string>
17+
1618// / Enum type representing the contract checking and replacement modes.
1719enum class dfcc_contract_modet
1820{
1921 CHECK,
2022 REPLACE
2123};
2224
25+ std::string dfcc_contract_mode_to_string (const dfcc_contract_modet mode);
26+
27+ std::ostream &operator <<(std::ostream &os, const dfcc_contract_modet mode);
28+
2329#endif
Original file line number Diff line number Diff line change 1+ /* ******************************************************************\
2+
3+ Module: Dynamic frame condition checking for function contracts
4+
5+ Author: Remi Delmas, delmasrd@amazon.com
6+
7+ Date: March 2023
8+
9+ \*******************************************************************/
10+
11+ #include " dfcc_loop_contract_mode.h"
12+
13+ #include < util/invariant.h>
14+
15+ dfcc_loop_contract_modet dfcc_loop_contract_mode_from_bools (
16+ bool apply_loop_contracts,
17+ bool unwind_transformed_loops)
18+ {
19+ if (apply_loop_contracts)
20+ {
21+ if (unwind_transformed_loops)
22+ {
23+ return dfcc_loop_contract_modet::APPLY_UNWIND;
24+ }
25+ else
26+ {
27+ return dfcc_loop_contract_modet::APPLY;
28+ }
29+ }
30+ else
31+ {
32+ return dfcc_loop_contract_modet::NONE;
33+ }
34+ }
35+
36+ std::string
37+ dfcc_loop_contract_mode_to_string (const dfcc_loop_contract_modet mode)
38+ {
39+ switch (mode)
40+ {
41+ case dfcc_loop_contract_modet::NONE:
42+ return " dfcc_loop_contract_modet::NONE" ;
43+ case dfcc_loop_contract_modet::APPLY:
44+ return " dfcc_loop_contract_modet::APPLY" ;
45+ case dfcc_loop_contract_modet::APPLY_UNWIND:
46+ return " dfcc_loop_contract_modet::APPLY_UNWIND" ;
47+ }
48+ UNREACHABLE;
49+ }
50+
51+ std::ostream &operator <<(std::ostream &os, const dfcc_loop_contract_modet mode)
52+ {
53+ os << dfcc_loop_contract_mode_to_string (mode);
54+ return os;
55+ }
Original file line number Diff line number Diff line change 1+ /* ******************************************************************\
2+
3+ Module: Dynamic frame condition checking for function contracts
4+
5+ Author: Remi Delmas, delmasrd@amazon.com
6+
7+ \*******************************************************************/
8+
9+ // / \file
10+ // / Enumeration representing the instrumentation mode for loop contracts.
11+
12+ #ifndef CPROVER_GOTO_INSTRUMENT_CONTRACTS_DYNAMIC_FRAMES_DFCC_LOOP_CONTRACT_MODE_H
13+ #define CPROVER_GOTO_INSTRUMENT_CONTRACTS_DYNAMIC_FRAMES_DFCC_LOOP_CONTRACT_MODE_H
14+
15+ #include < string>
16+
17+ // / Enumeration representing the instrumentation mode for loop contracts.
18+ enum class dfcc_loop_contract_modet
19+ {
20+ // / Do not apply loop contracts
21+ NONE,
22+ // / Apply loop contracts
23+ APPLY,
24+ // / Apply loop contracts and unwind the resulting base + step encoding
25+ APPLY_UNWIND
26+ };
27+
28+ // / Generates an enum value from boolean flags for application and unwinding.
29+ dfcc_loop_contract_modet dfcc_loop_contract_mode_from_bools (
30+ bool apply_loop_contracts,
31+ bool unwind_transformed_loops);
32+
33+ std::string dfcc_loop_contract_mode_to_string (dfcc_loop_contract_modet mode);
34+
35+ std::ostream &operator <<(std::ostream &os, const dfcc_loop_contract_modet mode);
36+
37+ #endif
You can’t perform that action at this time.
0 commit comments