Skip to content

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

Merged
merged 1 commit into from
Jan 12, 2023

Conversation

tautschnig
Copy link
Collaborator

This was set in only one of the three cases; also consistently use the prettiest
name available.

@@ -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());
Copy link
Member

@peterschrammel peterschrammel May 4, 2018

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.

Copy link
Collaborator Author

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?

Copy link
Member

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.

irep_idt function=it->source_location.get_function();

This seems unnecessary because we could take the function from the instruction (same for XML):

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);

...

Copy link
Collaborator Author

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.

@kroening
Copy link
Member

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'.

@kroening
Copy link
Member

The current view is to remove it entirely.

@tautschnig tautschnig mentioned this pull request Feb 13, 2019
1 task
@tautschnig tautschnig changed the title generate-function-body: set function in source_location generate-function-body: set function in source_location [depends-on: #3514] Feb 25, 2019
@tautschnig tautschnig changed the title generate-function-body: set function in source_location [depends-on: #3514] generate-function-body: set function in source_location Oct 13, 2022
kroening added a commit that referenced this pull request Oct 13, 2022
Following #2149, this deprecates source_locationt::get/set_function; the
reason is given as a comment.
@codecov
Copy link

codecov bot commented Oct 13, 2022

Codecov Report

Base: 78.34% // Head: 78.34% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (56fda10) compared to base (a53fa0f).
Patch coverage: 93.75% of modified lines in pull request are covered.

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     
Impacted Files Coverage Δ
jbmc/src/janalyzer/janalyzer_parse_options.cpp 48.58% <ø> (ø)
.../src/java_bytecode/character_refine_preprocess.cpp 54.27% <ø> (ø)
...mc/src/java_bytecode/character_refine_preprocess.h 100.00% <ø> (ø)
jbmc/src/java_bytecode/ci_lazy_methods.h 100.00% <ø> (ø)
jbmc/src/java_bytecode/ci_lazy_methods_needed.cpp 98.41% <ø> (ø)
jbmc/src/java_bytecode/ci_lazy_methods_needed.h 100.00% <ø> (ø)
jbmc/src/java_bytecode/code_with_references.cpp 84.61% <ø> (ø)
jbmc/src/java_bytecode/java_bmc_util.cpp 100.00% <ø> (ø)
...mc/src/java_bytecode/java_bytecode_convert_class.h 0.00% <ø> (ø)
...src/java_bytecode/java_bytecode_convert_method.cpp 97.69% <ø> (ø)
... and 413 more

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.
📢 Do you have feedback about the report comment? Let us know in this issue.

This was set in only one of the three cases.
@peterschrammel peterschrammel removed their assignment Jan 12, 2023
@tautschnig tautschnig merged commit 41a3034 into diffblue:develop Jan 12, 2023
@tautschnig tautschnig deleted the add-function branch January 12, 2023 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants