@@ -35,7 +35,7 @@ void for_each_function_call(GotoFunctionT &&goto_function, Handler handler)
35
35
handler);
36
36
}
37
37
38
- static void restrict_function_pointer (
38
+ [[nodiscard]] static bool restrict_function_pointer (
39
39
message_handlert &message_handler,
40
40
symbol_tablet &symbol_table,
41
41
goto_programt &goto_program,
@@ -54,7 +54,7 @@ static void restrict_function_pointer(
54
54
const auto &original_function = location->call_function ();
55
55
56
56
if (!can_cast_expr<dereference_exprt>(original_function))
57
- return ;
57
+ return false ;
58
58
59
59
// because we run the label function pointer calls transformation pass before
60
60
// this stage a dereference can only dereference a symbol expression
@@ -66,7 +66,7 @@ static void restrict_function_pointer(
66
66
restrictions.restrictions .find (pointer_symbol.get_identifier ());
67
67
68
68
if (restriction_iterator == restrictions.restrictions .end ())
69
- return ;
69
+ return false ;
70
70
71
71
const namespacet ns (symbol_table);
72
72
std::unordered_set<symbol_exprt, irep_hash> candidates;
@@ -80,6 +80,8 @@ static void restrict_function_pointer(
80
80
function_id,
81
81
location,
82
82
candidates);
83
+
84
+ return true ;
83
85
}
84
86
} // namespace
85
87
@@ -180,15 +182,19 @@ void restrict_function_pointers(
180
182
{
181
183
goto_functiont &goto_function = function_item.second ;
182
184
185
+ bool did_something = false ;
183
186
for_each_function_call (goto_function, [&](const goto_programt::targett it) {
184
- restrict_function_pointer (
187
+ did_something |= restrict_function_pointer (
185
188
message_handler,
186
189
goto_model.symbol_table ,
187
190
goto_function.body ,
188
191
function_item.first ,
189
192
restrictions,
190
193
it);
191
194
});
195
+
196
+ if (did_something)
197
+ goto_function.body .update ();
192
198
}
193
199
}
194
200
0 commit comments