-
Notifications
You must be signed in to change notification settings - Fork 273
Use remove-function-pointers code for restricted function pointers #6376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
e4bf3fb
to
0cdc654
Compare
{ | ||
std::stringstream comment; | ||
|
||
comment << "dereferenced function pointer at must be "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs location after at
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, thanks! (Well, I actually removed the location.)
} | ||
else if(candidates.empty()) | ||
{ | ||
comment.str("no candidates for dereferenced function pointer"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Location here too would be great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My rationale for omitting this is that the location will be provided anyway, I don't think we need to repeat it.
0cdc654
to
bec1d91
Compare
d6fa9bd
to
74bc2fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. There seem to be a number of different but overlapping changes in this PR. There is a little formatting, threading the logging infrastructure through the functions, converting the generation code, catching up on the changed output, etc. I realise that in this case it is not really easy to separate these but in future, if possible, separate commits would make this easier to review.
@@ -131,9 +101,10 @@ remove_function_pointerst::remove_function_pointerst( | |||
} | |||
} | |||
|
|||
bool remove_function_pointerst::arg_is_type_compatible( | |||
static bool arg_is_type_compatible( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for preferring static functions over private member functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I made remove_function_pointer
a global function, I had to have a way to use these functions.
goto_programt &goto_program, | ||
const irep_idt &function_id, | ||
goto_programt::targett target, | ||
const std::unordered_set<symbol_exprt, irep_hash> &functions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the key line right? It gives a way of passing a map to function pointer removal and this splitting the process into "generate function maps" and "convert code using the maps"?
Codecov Report
@@ Coverage Diff @@
## develop #6376 +/- ##
========================================
Coverage 76.04% 76.04%
========================================
Files 1546 1546
Lines 165541 165536 -5
========================================
+ Hits 125882 125888 +6
+ Misses 39659 39648 -11
Continue to review full report at Codecov.
|
You're absolutely right that I should have tried to factor this into multiple commits. I had kept this in mind even when making the changes, but struggled to make it happen. And, upon a second look, I still struggle. So unless I'm really forced to, I'd rather keep it as is. |
We had two instances of code generating an if-else sequence of function calls for function pointers. The code used with --restrict-function-pointer, however, was not able to cope with type mismatches. Make the code from remove_function_pointers re-usable in both contexts, enabling support for additional type casts. Fixes: diffblue#6368
74bc2fe
to
d825d04
Compare
We had two instances of code generating an if-else sequence of function
calls for function pointers. The code used with
--restrict-function-pointer, however, was not able to cope with type
mismatches. Make the code from remove_function_pointers re-usable in
both contexts, enabling support for additional type casts.
Fixes: #6368