-
Notifications
You must be signed in to change notification settings - Fork 1.8k
C++: Clarify the docs on DataFlow::Node::asExpr #4032
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
Ping @johnlugton @adityasharad |
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, thanks!
A minor suggestion for readability, but overall I trust your judgement on the most accurate way to describe these nodes.
cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowUtil.qll
Outdated
Show resolved
Hide resolved
/** | ||
* Gets the `Node` corresponding to a definition by reference of the variable | ||
* that is passed as unconverted `argument` of a call. | ||
*/ | ||
DefinitionByReferenceNode definitionByReferenceNodeFromArgument(Expr argument) { | ||
result.getArgument() = argument | ||
} | ||
|
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.
The body of definitionByReferenceNodeFromArgument
is identical to definitionByReferenceNode
on line 479. Is there supposed to be a distinction, or is it just a duplicated predicate?
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 catch. I've deprecated definitionByReferenceNode
since it was IR-only and updated its callers.
* This predicate only has a result on nodes that represent the value of | ||
* evaluating the expression. For data flowing _out of_ an expression, like | ||
* when an argument is passed by reference, use `asDefiningArgument` instead | ||
* of `asExpr`. |
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.
Should this be its own paragraph?
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.
I kept it as one paragraph in the hope that the reader would be less likely to skip the sentences after the first one. Ideally we'd find a way to qualify the first sentence so it contains a forward reference to the explanation about its restrictions, similar to how the word "non-conversion" is a forward reference to the final paragraph.
I had a branch retarget accident with this PR. Sorry for the spam, language teams. |
For IR data flow I also added a `definitionByReferenceNodeFromArgument` predicate to improve compatibility with AST data flow.
Co-authored-by: Aditya Sharad <[email protected]>
This predicate name was only used in IR data flow, not in AST data flow.
I've retargeted this to |
@rdmarsh2 I think you can safely ignore the failing checks. They are transient failures in tests that shouldn't have run in the first place but were triggered during my retargeting accident and are no longer re-triggered. |
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
For IR data flow I also added a
definitionByReferenceNodeFromArgument
predicate to improve compatibility with AST data flow.