-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Ruby: Add post-update nodes for compound arguments #10444
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
9d4c1be
to
c356173
Compare
c356173
to
24b41ef
Compare
Fascinating, and a bit horrifying. I wonder, though, could this be handled at the level of AST desugaring? |
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.
Python changes look, well, harmless to me. 🙂
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.
C++ 👍. I just realized that I forgot to update identical-files.json
when I added a couple of copies of the dataflow library into experimental last week. So if #10487 gets merged before this you might need to pull in main and update the identical files in C++'s experimental directory. Sorry!
Yes, we could in principle desugar |
For this case, definitely. I was just thinking more generally if it would be less surprising for users to have |
So, desugar |
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.
Java looks harmless too 👍
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.
C# LGTM
017e8de
a36c3f5
to
017e8de
Compare
Rebased to resolve merge conflicts. |
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.
C# still looks good to me.
07f8b35
017e8de
to
07f8b35
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.
Looks good to me.
* Gets a node that may execute last in `n`, and which, when it executes last, | ||
* will be the value of `n`. | ||
*/ | ||
private CfgNodes::ExprCfgNode getALastEvalNode(CfgNodes::ExprCfgNode 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.
When reading the comment explaining this predicate , I had expected it to be recursive. I see you take the transitive closure later.
Post-update nodes
Post-update nodes are used to enable flow out through arguments:
There is flow from "taint" to the field
field
on post-update node fory
in the call totaint_field
, written(post) y [field]
, and from(post) y [field]
in the call totaint_field
toy [field]
in the call tosink
, and finally toy.field
in the call tosink
.Compound arguments
However, when the argument is a compound expression, such as
we fail to track flow, since there is no connection between
(post) if b then x else y
and the access toy
insink(y.field)
.This PR fixes that, by also adding post-update nodes for
x
andy
inif b then x else y
, and let those nodes have two pre-update nodes:if b then x else y
; andx
andy
, respectively.This ensures that we get flow out of the call into both leafs (1), while still maintaining the invariant that the underlying expression is a pre-update node (2). Of course, compound expression can be nested,
if b then x else if c then y else z
, so we also need to handle that.Common in Ruby (?)
While compound arguments such as
if b then x else y
may not be that common, it is easy to write an argument that is:In the former call,
x
is just a normal argument, but in the latter the argument is a parenthesized expression with just one child expression,x
.