Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the C++ data-flow parameter-mapping fix.
No open issues 🎉
What changed in this PR
Fixes C++ data-flow parameterNode so reference parameters map to the indirect nodes returned by Node.asParameter.
Changes:
- Widens the return type to
ParameterNodeand usesasParameter()for the mapping. - Extends the test query to check parameter mappings and node counts.
- Adds regression cases for value, pointer, and reference parameters.
| File | Description |
|---|---|
cpp/​ql/​test/​library-tests/​dataflow/​asExpr/​test.ql |
Adds checks for asParameter and parameterNode. |
cpp/​ql/​test/​library-tests/​dataflow/​asExpr/​test.cpp |
Adds expected mappings for several parameter types. |
cpp/​ql/​lib/​semmle/​code/​cpp/​ir/​dataflow/​internal/​DataFlowNodes.qll |
Corrects the return type and mapping of parameterNode. |
Review effort: Balanced (adaptive)
This branch has not been deployed
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.
Given a reference parameter
int& rwe have two parameter nodes:rpoints to (i.e., "the indirection of the pointer")Very early on when we introduced indirections into dataflow "someone" decided that it would make porting queries easier if we modified the behavior of
Node.asParameterso that the indirect parameter node was the node for whichNode.asParametergave back the indirection.No one has really complained about this, and it did reduce the amount of rewrites we had to do in queries so it was probably the right thing to do. However, we never updated the return type of the inverse predicate
parameterNodewhich maps aParameterto its dataflow node. So for references this predicate would sometimes not have a result.This PR fixes that. It's a one-line fix, but most of the work involves adding tests around the fix so we can actually observe the effects of the change.