-
Notifications
You must be signed in to change notification settings - Fork 273
pre/post traversal expression transformers #4891
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
base: develop
Are you sure you want to change the base?
Conversation
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: eda58d0).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/118808656
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.
Can't find it right now as on a phone, but I implemented a similar visitor for renamed expressions recently in symex and tried to retain sharing whenever possible, perhaps use that as a starting point?
src/util/expr.cpp
Outdated
exprt tmp = *this; | ||
bool op_changed = false; | ||
|
||
for(auto &op : tmp.operands()) // this breaks sharing |
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.
Surely breaking sharing before you know if that's necessary will negate the benefit of this
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, but note it's done on a copy.
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.
So what? Make a copy then immediately break sharing and you've copied the input expression
You mean |
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 needs unit tests.
@@ -287,6 +287,65 @@ void exprt::visit_post(std::function<void(const exprt &)> visitor) const | |||
visit_post_template(visitor, this); |
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.
Commit message: "Transformers for expressions that offer an interface similar to that offered
by the goto-program API." There isn't enough context available to understand why what looks like a comparison of apples and oranges is useful to the reader.
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.
Fixed
src/util/expr.cpp
Outdated
if(visitor_result.has_value()) | ||
tmp = visitor_result.value(); | ||
else | ||
tmp = *this; |
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.
How about exprt tmp = visitor_result.value_or(*this);
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.
sure
Transformers for expressions that offer an interface similar to that offered by void goto_programt::transform(std::function<optionalt<exprt>(exprt)>); on goto programs. Both pre- and post-traversal options are available. The key benefit over the non-const visit method is that sharing is only broken up when required.
eda58d0
to
884d002
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: 884d002).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/119023646
Codecov Report
@@ Coverage Diff @@
## develop #4891 +/- ##
===========================================
- Coverage 69.2% 69.19% -0.02%
===========================================
Files 1306 1306
Lines 107949 107968 +19
===========================================
Hits 74704 74704
- Misses 33245 33264 +19
Continue to review full report at Codecov.
|
Indeed -- Line 88 in 1ea4a76
|
Transformers for expressions that offer an interface similar to that offered
by the goto-program API. Both pre- and post-traversal options are available.
The key benefit over the non-const
visit
method is that sharing is onlybroken up when required.