-
Notifications
You must be signed in to change notification settings - Fork 273
generate-function-body: set function in source_location #2149
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
@@ -125,7 +126,7 @@ class assert_false_then_assume_false_generate_function_bodiest | |||
auto instruction = function.body.add_instruction(); | |||
instruction->function = function_name; | |||
instruction->source_location = function_symbol.location; | |||
instruction->source_location.set_function(function_name); | |||
instruction->source_location.set_function(function_symbol.display_name()); |
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.
Using display_name
is a good idea, in principle, but using it only here will result in inconsistent output. More importantly, there are many usages of source_location.get_function()
that expect it to return a symbol identifier. These would need to be fixed first.
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.
That's scary - would you be able to point me to any of those get_function()
uses so that I have a starting point?
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.
Most of the occurrences use the function for uniqueness of names, e.g.
cbmc/src/goto-programs/set_properties.cpp
Line 58 in 706e391
irep_idt function=it->source_location.get_function(); |
This seems unnecessary because we could take the function from the instruction (same for XML):
cbmc/src/goto-programs/json_goto_trace.cpp
Line 191 in 7f3ba30
if(ns.lookup(source_location.get_function(), function_name)) |
I doubt this would guarantee uniqueness of property names even at the moment unless pretty names are as unique as identifiers (this code is probably duplicated in many places):
? id2string(step.pc->source_location.get_function()) + ".unwind." + |
There are a couple of this sort that I am to blame for:
type, id2string(loc.get_function()), prefix, loc, ID_C, symbol_table); |
...
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.
I am now refraining from using the display_name
. The PR is now all about just setting the function name.
The idea to use the result of source_locationt::get_function() as an identifier has a key problem that the linker doesn't know about these -- i.e., on symbol collision, you'll have the wrong identifier. I am thus currently biased towards saying that source_locationt::get_function() is meant to be human-readable. There could also be a case for removing it entirely, as the information is often available elsewhere; it's also not strictly a 'source location'. |
The current view is to remove it entirely. |
30cfa8f
to
0623219
Compare
Following #2149, this deprecates source_locationt::get/set_function; the reason is given as a comment.
Codecov ReportBase: 78.34% // Head: 78.34% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## develop #2149 +/- ##
========================================
Coverage 78.34% 78.34%
========================================
Files 1644 1645 +1
Lines 190313 190357 +44
========================================
+ Hits 149097 149132 +35
- Misses 41216 41225 +9
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
0623219
to
1b7504a
Compare
This was set in only one of the three cases.
1b7504a
to
56fda10
Compare
This was set in only one of the three cases; also consistently use the prettiest
name available.