-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Allow pointers to evaluate to true/false #3656
Conversation
9b27524
to
e7e630a
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.
Overall LGTM! Nice work. Just a few minor changes needed.
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.
lgtm, but please add a few semantic analysis tests and a codegen test (just to get ahead of future regressions)
6361560
to
27f3b70
Compare
For if conditions, tenary conditions and logical expressions we can allow pointers to evaluate to true or false. This change updates the codegen to consistently use the null value for the `lhs` and `rhs`, and allows the appropriate conditions in the semantic analyzer. Runtime tests are added to ensure that the given programs evaluate to the expected outcomes. This fixes bpftrace#1579, but should only update bpftrace#1726. The question of broader expanding logical operators to strings and other types is trickier, but the null value for pointers is fairly well-understood and a very common pattern for C programmers (who will often write these probes). The updates to documentation are minimal, as existing constraints are not documented and it seems that using pointers generally matches user expectations.
For if conditions, tenary expressions and logical expressions we can allow pointers to evaluate to true or false. This change updates the codegen to consistently use the null value for the
lhs
andrhs
, and allows the appropriate conditions in the semantic analyzer. Runtime tests are added to ensure that the given programs evaluate to the expected outcomes.This fixes #1579, but should only update #1726. The question of broader expanding logical operators to strings and other types is trickier, but the null value for pointers is fairly well-understood and a very common pattern for C programmers (who will often write these probes).
Checklist
man/adoc/bpftrace.adoc
CHANGELOG.md