22 class validate_goto_modelt
37 void entry_point_exists();
40 void function_pointer_calls_removed();
52 void check_returns_removed();
63 void check_called_functions();
66 const function_mapt &function_map;
69 validate_goto_modelt::validate_goto_modelt(
73 : vm{vm}, function_map{goto_functions.function_map}
75 if(validation_options.entry_point_exists)
82 validation_options.function_pointer_calls_removed ||
83 validation_options.check_returns_removed)
85 function_pointer_calls_removed();
88 if(validation_options.check_returns_removed)
89 check_returns_removed();
91 if(validation_options.check_called_functions)
92 check_called_functions();
95 void validate_goto_modelt::entry_point_exists()
100 "an entry point must exist");
103 void validate_goto_modelt::function_pointer_calls_removed()
105 for(
const auto &fun : function_map)
107 for(
const auto &instr : fun.second.body.instructions)
109 if(instr.is_function_call())
115 "no calls via function pointer should be present");
121 void validate_goto_modelt::check_returns_removed()
123 for(
const auto &fun : function_map)
130 vm, !instr.is_return(),
"no return instructions should be present");
132 if(instr.is_function_call())
134 const auto &function_call = instr.get_function_call();
138 "function call lhs return should be nil");
144 void validate_goto_modelt::check_called_functions()
146 auto test_for_function_address =
147 [
this](
const exprt &expr) {
148 if(expr.id() == ID_address_of)
152 if(pointee.id() == ID_symbol && pointee.type().id() == ID_code)
158 function_map.find(identifier) != function_map.end(),
159 "every function whose address is taken must be in the "
165 for(
const auto &fun : function_map)
167 for(
const auto &instr : fun.second.body.instructions)
170 if(instr.is_function_call())
172 const auto &function_call = instr.get_function_call();
178 function_map.find(identifier) != function_map.end(),
179 "every function call callee must be in the function map");
183 const auto &src =
static_cast<const exprt &
>(instr.get_code());
184 src.
visit_pre(test_for_function_address);
196 validate_goto_modelt{goto_functions, vm, validation_options};