Rust: Handle closures/lambdas in data flow#18160
Merged
Merged
Conversation
hvitved
reviewed
Dec 3, 2024
| predicate lambdaCreation(Node creation, LambdaCallKind kind, DataFlowCallable c) { none() } | ||
| predicate lambdaCreation(Node creation, LambdaCallKind kind, DataFlowCallable c) { | ||
| exists(Expr cl | cl = creation.asExpr().getExpr() and cl = c.asCfgScope() | | ||
| cl instanceof ClosureExpr or cl instanceof AsyncBlockExpr |
Contributor
There was a problem hiding this comment.
I don't think we should include AsyncBlockExpr here, otherwise I guess we would want to have different LambdaCallKind for closures and async blocks?
Contributor
Author
There was a problem hiding this comment.
I think it makes sense to treat them as lambdas (they capture variables, are "called" by .await). But you're right that we should also have a lambda kind for them. That's what I was alluding to in the PR description, that the async block handling is half baked. I can take AsyncBlockExpr for now and leave it until we implement proper support?
hvitved
requested changes
Dec 4, 2024
Co-authored-by: Tom Hvitved <hvitved@github.com>
hvitved
approved these changes
Dec 4, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implements
lambdaCreationandlambdaCall, enabling data flow through lambdas.Note that if we extend the QL variables implementation to handle local function definitions then we need to adapt
lambdaCall.Also, this doesn't handle
.awaitcalling async blocks, but I think that is of less importance.