-
Notifications
You must be signed in to change notification settings - Fork 17
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
Identify sources from panicky ssa.TypeAssert #217
Conversation
…dType is a source then, create a Source.
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.
Good change!
A couple of things to look into before I can approve:
- Could you shorten the title so that it fits entirely in the PR's title field? (e.g. "Identify sources created by
TypeAssert
instructions") The PR title will eventually become part of the auto-generated commit message. Also, it is often useful to be able to view the entire title in e.g. the pull requests page. - Could you explain why we need this change? (I understand why, but for documentation purposes it is helpful to have a bit more detail in the description)
- While the passing test for Leverage type information provided by type assertions #210 is a welcome surprise, I don't think this "fixes" Leverage type information provided by type assertions #210. We'll still need to decide what to do when the
TypeAssert
isCommaOk
. Please remove "Fixes Leverage type information provided by type assertions #210" from the description so that the issue does not get closed.
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.
+1 to all of Michael's comments.
Could you shorten the title so that it fits entirely in the PR's title field? (e.g. "Identify sources created by TypeAssert instructions") The PR title will eventually become part of the auto-generated commit message. Also, it is often useful to be able to view the entire title in e.g. the pull requests page.
Personally, I'd include the panicky
adjective in the commit summary, e.g., Identify sources from panicky ssa.TypeAssert
. As Michael pointed out, we still have several #210 cases that won't be covered by this PR, so it could be good do distinguish in the summary the CommaOK
vs panic
.
dc7e570
to
cee3112
Compare
If a ssa.TypeAssert instruction does not have CommaOk and the AssertedType is a source then, create a Source.
Fixes #190
Why is this change needed?
Today go-flow-levee correctly identifies that a source has reached a sink for the following code:
The SSA for the code above is:
Note that the ssa.TypeAssert is followed by the ssa.Extract. This works because we handle ssa.Extract correctly.
However, go-flow-levee does not report that a source has reached a sink for the function below:
The SSA for this as follow:
Since we were not checking if the type assertion worked as in
s, ok := e.(*core.Source)
case and just panic there is no ssa.Extract instruction, we need to handle the case ssa.TypeAssert with ssa.TypeAssert.CommaOk being false case explicitly and create a source if ssa.TypeAssert.AssertedType is a source type.Thanks to @mlevesquedion for helping me understand this problem and its solution.