-
Notifications
You must be signed in to change notification settings - Fork 274
use a separate message for show_goto_functions() for the console #3165
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
699008b
to
d9ccb11
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.
Code duplication isn't great, and with the further changes in this PR we actually have two bits of code that generate almost, but not exactly the same output anymore.
} | ||
else | ||
{ | ||
goto_functions.output(ns, msg.status()); | ||
msg.status() << messaget::eom; | ||
auto &out = msg.status(); |
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 think this just makes the code harder to read, but if it is used then it should be used consistently below.
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.
ok, fixed
{ | ||
if(fun.second.body_available()) | ||
{ | ||
out << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n"; |
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 don't think it's a good idea to have code duplication - couldn't this also be fixed within goto_functionst::output
? Else, that method should be removed.
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.
It can't be fixed without changing the signature -- contemplating to remove.
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.
Removing might be the best solution. Code that is almost duplicated is the prone to cause trouble.
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
As side note: it might be time to factor out a number of commits into PRs of their own. Both discussion and CI failure will likely just hold up a number of commits that are 1) very useful for follow-up work and 2) are easy to merge. |
#3166 ! |
955959c
to
73558e5
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.
This PR failed Diffblue compatibility checks (cbmc commit: 73558e5).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/87894799
Status will be re-evaluated on next push.
Please contact @peterschrammel, @thk123, or @allredj for support.
Common spurious failures:
- the cbmc commit has disappeared in the mean time (e.g. in a force-push)
- the author is not in the list of contributors (e.g. first-time contributors).
The incompatibility may have been introduced by an earlier PR. In that case merging this
PR should be avoided unless it fixes the current incompatibility.
Rationale: the messages are output into a string buffer, which does not scale well in case there are many functions. Output can be delayed substantially.
73558e5
to
ae313b1
Compare
ae313b1
to
e6c46fa
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.
Some more debate plus the note that an overly long line breaks CI.
{ | ||
out << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n"; | ||
msg.status() << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n"; | ||
|
||
const symbolt &symbol = ns.lookup(fun.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.
Shouldn't this line be removed as it is now redundant?
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.
You mean because of the colouring?
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.
No, because of the refactoring in "consolidate the two variants of show-goto-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.
sorry, the line was unclear -- yes, redundant, yes, removed
@@ -51,9 +53,19 @@ void show_goto_functions( | |||
|
|||
case ui_message_handlert::uit::PLAIN: | |||
{ | |||
// sort alphabetically |
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.
Why is this only done in the PLAIN
output? It might make the most sense for that case, but then at least the commit message should be clear about that.
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.
Ok, will sort all
{ | ||
const symbolt &symbol = ns.lookup(fun.first); | ||
const symbolt &symbol = ns.lookup(f_id); | ||
const auto &fun = *goto_functions.function_map.find(f_id); |
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.
We've had all sorts of debates about performance and sorting: in keeping with this, shouldn't this lookup be avoided by using a vector that includes n iterator, and using a custom comparison operator?
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.
Now in a separate function where this can be tweaked further if need be.
e6c46fa
to
71eb7b2
Compare
|
||
const auto sorted = goto_functions.sorted(); | ||
|
||
for(const auto function_entry : sorted) |
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.
Minor note: here (and also in the XML case) this should likely be a const auto &
. It's just an iterator so not terribly expensive to copy, but it's being done in the PLAIN
case and would thus at bare minimum ensure consistency.
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'd be tempted to remove the & in the PLAIN
case. References to iterators are unusual; copying them is very common.
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 have no strong opinion either way, just consistency is what I'd call for.
21d5d8d
to
a484b8b
Compare
Use show_goto_functions() instead
a484b8b
to
4fcde9a
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.
Passed Diffblue compatibility checks (cbmc commit: 4fcde9a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/88158804
Rationale: the messages are output into a string buffer, which does not
scale well in case there are many functions. Output can be delayed
substantially.