21 class validate_goto_modelt
36 void entry_point_exists();
39 void function_pointer_calls_removed();
51 void check_returns_removed();
62 void check_called_functions();
65 const function_mapt &function_map;
68 validate_goto_modelt::validate_goto_modelt(
72 : vm{vm}, function_map{goto_functions.function_map}
84 function_pointer_calls_removed();
88 check_returns_removed();
91 check_called_functions();
94 void validate_goto_modelt::entry_point_exists()
99 "an entry point must exist");
102 void validate_goto_modelt::function_pointer_calls_removed()
104 for(
const auto &fun : function_map)
106 for(
const auto &instr : fun.second.body.instructions)
108 if(instr.is_function_call())
112 instr.call_function().id() == ID_symbol,
113 "no calls via function pointer should be present");
119 void validate_goto_modelt::check_returns_removed()
121 for(
const auto &fun : function_map)
129 !instr.is_set_return_value(),
130 "no SET_RETURN_VALUE instructions should be present");
132 if(instr.is_function_call())
137 "function call lhs return should be nil");
143 void validate_goto_modelt::check_called_functions()
145 auto test_for_function_address =
146 [
this](
const exprt &expr) {
147 if(expr.id() == ID_address_of)
151 if(pointee.id() == ID_symbol && pointee.type().id() == ID_code)
157 function_map.find(identifier) != function_map.end(),
158 "every function whose address is taken must be in the "
164 for(
const auto &fun : function_map)
166 for(
const auto &instr : fun.second.body.instructions)
169 if(instr.is_function_call())
176 function_map.find(identifier) != function_map.end(),
177 "every function call callee must be in the function map");
181 const auto &src =
static_cast<const exprt &
>(instr.get_code());
182 src.
visit_pre(test_for_function_address);
194 validate_goto_modelt{goto_functions, vm, validation_options};
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
void visit_pre(std::function< void(exprt &)>)
A collection of goto functions.
std::map< irep_idt, goto_functiont > function_mapt
static irep_idt entry_point()
Get the identifier of the entry point to a goto model.
A goto function, consisting of function body (see body) and parameter identifiers (see parameter_iden...
bool check_called_functions
bool function_pointer_calls_removed
bool check_returns_removed
instructionst instructions
The list of instructions in the goto program.
const irep_idt & get_identifier() const
Goto Programs with Functions.
API to expression classes for Pointers.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
bool does_function_call_return(const goto_programt::instructiont &function_call)
Check if the function_call returns anything.
Replace function returns by assignments to global variables.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
#define DATA_CHECK(vm, condition, message)
This macro takes a condition which denotes a well-formedness criterion on goto programs,...
void validate_goto_model(const goto_functionst &goto_functions, const validation_modet vm, const goto_model_validation_optionst validation_options)