-
Notifications
You must be signed in to change notification settings - Fork 285
Avoid shadowing of variables [blocks: #2310] #3607
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
| id2string(vt_symb_type.name) + "@"+ id2string(symbol.name); | ||
| vt_symb_var.base_name= | ||
| id2string(vt_symb_type.base_name) + "@" + id2string(symbol.base_name); | ||
| vt_symb_var.mode=ID_cpp; |
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.
Unrelated change?
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.
Hmm, yes, I'll remove it.
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.
Hmm, looking at my commit message that's actually explained:
Do not shadow "mode" in cpp front-end
Also pick up a previously set mode from a symbol rather than hard-coding ID_cpp
where possible. The symbol's mode could be ID_C or ID_cpp, depending on the
linkage specification.
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'm a little uncomfortable with either the commit message, or the commit - the headline of the message 'Do not shadow "mode" in cpp front-end' sounds like a simple refactoring, yet the commit also has a functional change in there too (which admittedly is mentioned in the body of the message) - i.e. the handling of previously set modes. Might it be better to either split that change out in to a separate commit, or change the wording of this commit so that the headline is more along the lines of 'Improve handling of "mode" in cpp frontend' ?
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 taken the route of amending the commit message as suggested.
ea510d6 to
cceb8f4
Compare
allredj
left a comment
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: cceb8f4).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/95450432
cceb8f4 to
20d3381
Compare
20d3381 to
a94836e
Compare
allredj
left a comment
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: a94836e).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/95509779
a94836e to
e32dc1a
Compare
allredj
left a comment
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: e32dc1a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/95526623
e32dc1a to
d077960
Compare
d077960 to
2208e45
Compare
allredj
left a comment
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: 2208e45).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/95541818
allredj
left a comment
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: d077960).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/95543217
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.
Avoid shadowing in directory jbmc/unit [blocks: #3607]
44d29c8 to
2da216c
Compare
allredj
left a comment
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: 2da216c).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/96499375
| { | ||
| dependencies.clean_cache(); | ||
| const decision_proceduret::resultt res=supert::dec_solve(); | ||
| res = supert::dec_solve(); |
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'm not a big fan of this change - makes it hard to see that this is constant throughout the loop and not dependent on it's outside loop state. A nice fix would of course be to introduce some functions or something, but perhaps an easier immediate fix for the shadowing would be call this loop_res and the other one initial_res
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.
Renaming done as suggested (using initial_result, refined_result).
| { | ||
| PRECONDITION(f.arguments().size() == 1); | ||
| string_constraintst constraints; | ||
| string_constraintst hash_constraints; |
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 probably rename the member variable to global_constraints or all_constraints
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.
Please forgive me for not intending to act on this one: from reading the code I got the impression that the two cases touched here affect methods that should likely be deprecated or removed. @romainbrenguier Any insights maybe?
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 problem - all of these comments are optional, I'm not overly familiar with the code being modified here anyway.
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 hash code and intern should be implemented via models rather than internally in the solver (they are very language dependent), so this should disappear.
| conversion_factor_table.copy_to_operands(constant_float(f, float_spec)); | ||
| for(const auto &f : two_power_e_over_ten_power_d_table) | ||
| conversion_factor_table.copy_to_operands(constant_float(f, float_spec)); | ||
| for(const auto &neg : two_power_e_over_ten_power_d_table_negatives) |
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.
⛏️ Don't use abbreviations negative, position - though obviously a massive improvement on what was there before.
⛏️ Rename the param f to float_expr?
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, and a separate commit doing the renaming of f is being prepared.
There is a class member of the same name, use "symbols_in_constraint" instead.
There is a class member named "result", rename the local variable to "eval_result."
Rename both instances, the first to "initial_result" and the second to "refined_result."
Rename the first use to "initial_instances"
There is no need to pass a class member as an argument.
Rename the method-local ones "intern_constraints" and "hash_constraints."
Rename container elements to "positive" and "negative."
A single-character name is not very descriptive, longer symbol names bear no runtime overhead.
6e271c3 to
adde39e
Compare
allredj
left a comment
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: 6e271c3).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/96602029
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.
allredj
left a comment
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: adde39e).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/96604752
Please review commit by commit - each of them solves a variable shadowing problem in some subset of classes/files.