CBMC
dfcc_contract_handler.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Dynamic frame condition checking for function contracts
4 
5 Author: Remi Delmas, delmasrd@amazon.com
6 Date: August 2022
7 
8 \*******************************************************************/
9 
12 
13 #ifndef CPROVER_GOTO_INSTRUMENT_CONTRACTS_DYNAMIC_FRAMES_DFCC_CONTRACT_HANDLER_H
14 #define CPROVER_GOTO_INSTRUMENT_CONTRACTS_DYNAMIC_FRAMES_DFCC_CONTRACT_HANDLER_H
15 
17 
18 #include <util/message.h>
19 #include <util/namespace.h>
20 #include <util/std_expr.h>
21 
23 
24 #include <set>
25 
26 class goto_modelt;
27 class message_handlert;
28 class dfcc_libraryt;
29 class dfcc_instrumentt;
35 
65 {
66 public:
75 
91  const dfcc_contract_modet contract_mode,
92  const irep_idt &wrapper_id,
93  const irep_idt &wrapped_id,
94  const irep_idt &contract_id,
95  const symbolt &wrapper_write_set_symbol,
96  goto_programt &dest,
97  std::set<irep_idt> &function_pointer_contracts);
98 
100  const std::size_t get_assigns_clause_size(const irep_idt &contract_id);
101 
112  const irep_idt &contract_id,
113  const std::optional<irep_idt> function_id_opt = {});
114 
115 protected:
125 
126  // Caches the functions generated from contracts
127  static std::map<irep_idt, dfcc_contract_functionst> contract_cache;
128 
132  get_contract_functions(const irep_idt &contract_id);
133 
140  const irep_idt &contract_id,
141  const code_typet &contract_type,
142  const irep_idt &pure_contract_id,
143  const code_typet &pure_contract_type);
144 };
145 
146 #endif
Base type of functions.
Definition: std_types.h:583
A class for an expression that represents a conditional target or a list of targets sharing a common ...
Definition: c_expr.h:232
Translates assigns and frees clauses of a function contract or loop contract into GOTO programs that ...
Generates GOTO functions modelling a contract assigns and frees clauses.
A contract is represented by a function declaration or definition with contract clauses attached to i...
void check_signature_compat(const irep_idt &contract_id, const code_typet &contract_type, const irep_idt &pure_contract_id, const code_typet &pure_contract_type)
Throws an error if the type signatures are not compatible.
dfcc_spec_functionst & spec_functions
const symbolt & get_pure_contract_symbol(const irep_idt &contract_id, const std::optional< irep_idt > function_id_opt={})
Searches for a symbol named "contract::contract_id" in the symbol table.
static std::map< irep_idt, dfcc_contract_functionst > contract_cache
dfcc_lift_memory_predicatest & memory_predicates
message_handlert & message_handler
dfcc_contract_clauses_codegent & contract_clauses_codegen
const std::size_t get_assigns_clause_size(const irep_idt &contract_id)
Returns the size assigns clause of the given contract in number of targets.
void add_contract_instructions(const dfcc_contract_modet contract_mode, const irep_idt &wrapper_id, const irep_idt &wrapped_id, const irep_idt &contract_id, const symbolt &wrapper_write_set_symbol, goto_programt &dest, std::set< irep_idt > &function_pointer_contracts)
Adds instructions in dest modeling contract checking, assuming that ret_t wrapper_id(params) is the f...
dfcc_instrumentt & instrument
dfcc_contract_handlert(goto_modelt &goto_model, message_handlert &message_handler, dfcc_libraryt &library, dfcc_instrumentt &instrument, dfcc_lift_memory_predicatest &memory_predicates, dfcc_spec_functionst &spec_functions, dfcc_contract_clauses_codegent &contract_clauses_codegen)
const dfcc_contract_functionst & get_contract_functions(const irep_idt &contract_id)
Returns the dfcc_contract_functionst object for the given contract from the cache,...
This class instruments GOTO functions or instruction sequences for frame condition checking and loop ...
Class interface to library types and functions defined in cprover_contracts.c.
Definition: dfcc_library.h:154
This class rewrites GOTO functions that use the built-ins:
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
A generic container class for the GOTO intermediate representation of one function.
Definition: goto_program.h:73
Class that provides messages with a built-in verbosity 'level'.
Definition: message.h:155
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:94
Symbol table entry.
Definition: symbol.h:28
Translates assigns and frees clauses of a function contract into goto functions that allow to build a...
dfcc_contract_modet
Enum type representing the contract checking and replacement modes.
Program Transformation.
API to expression classes.