-
Notifications
You must be signed in to change notification settings - Fork 165
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
Add const_expr_visitor, use it when compiling/cloning/stringing #837
Conversation
In some cases, we want to ensure that a visitor does *not* change the ast. This includes cases where the ast pointer used by the visitor is read-only. To support these use cases, add a const_expr_visitor interface where all the visit() methods take a const argument. Also add variants of accept() that take const_expr_visitor arguments and call the const_expr_visitors visit() method. Compiling, cloning, and stringifying asts are all cases that should not change the underlying ast, so switch those to use const_expr_visitor instead of expr_visitor. A couple of compile private methods had to be changed to take const arguments. They already didn't modify those arguments, so it was a safe change. Signed-off-by: Mark Stemm <[email protected]>
29cedf0
to
16db068
Compare
I did also build falco with this branch and the changes didn't cause any problems. The falco build itself did fail, but I suspect that's because other libs changes (looks like removing |
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.
Lovely! I was thinking to add the same changes somewhere in the future, thanks for the effort.
/approve
LGTM label has been added. Git tree hash: a968d2ea9e5db8968bffd02c0518447c6b3f4e2a
|
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.
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Andreagit97, jasondellaluce, mstemm The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Following on the changes in #837, add a const variant of base_expr_visitor. This allows definining subclasses that want to traverse an ast read-only without implementng all the methods. Signed-off-by: Mark Stemm <[email protected]>
Following on the changes in #837, add a const variant of base_expr_visitor. This allows definining subclasses that want to traverse an ast read-only without implementng all the methods. Signed-off-by: Mark Stemm <[email protected]>
Following on the changes in falcosecurity#837, add a const variant of base_expr_visitor. This allows definining subclasses that want to traverse an ast read-only without implementng all the methods. Signed-off-by: Mark Stemm <[email protected]>
What type of PR is this?
/kind feature
Any specific area of the project related to this PR?
/area libsinsp
Does this PR require a change in the driver versions?
What this PR does / why we need it:
In some cases, we want to ensure that a visitor does not change the ast. This includes cases where the ast pointer used by the visitor is read-only.
To support these use cases, add a const_expr_visitor interface where all the visit() methods take a const argument.
Also add variants of accept() that take const_expr_visitor arguments and call the const_expr_visitors visit() method.
Compiling, cloning, and stringifying asts are all cases that should not change the underlying ast, so switch those to use const_expr_visitor instead of expr_visitor.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: