-
Notifications
You must be signed in to change notification settings - Fork 1.9k
C++: Map operand nodes that are only used once onto the related instruction node #12004
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
Merged
jketema
merged 2 commits into
github:mathiasvp/replace-ast-with-ir-use-usedataflow
from
jketema:single-use
Feb 9, 2023
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,30 @@ | ||
| edges | ||
| | test1.c:7:26:7:29 | argv | test1.c:9:9:9:9 | i | | ||
| | test1.c:7:26:7:29 | argv | test1.c:11:9:11:9 | i | | ||
| | test1.c:7:26:7:29 | argv | test1.c:12:9:12:9 | i | | ||
| | test1.c:7:26:7:29 | argv | test1.c:13:9:13:9 | i | | ||
| | test1.c:7:26:7:29 | argv indirection | test1.c:9:9:9:9 | i | | ||
| | test1.c:7:26:7:29 | argv indirection | test1.c:9:9:9:9 | i | | ||
| | test1.c:7:26:7:29 | argv indirection | test1.c:11:9:11:9 | i | | ||
| | test1.c:7:26:7:29 | argv indirection | test1.c:11:9:11:9 | i | | ||
| | test1.c:7:26:7:29 | argv indirection | test1.c:12:9:12:9 | i | | ||
| | test1.c:7:26:7:29 | argv indirection | test1.c:12:9:12:9 | i | | ||
| | test1.c:7:26:7:29 | argv indirection | test1.c:13:9:13:9 | i | | ||
| | test1.c:7:26:7:29 | argv indirection | test1.c:13:9:13:9 | i | | ||
| | test1.c:9:9:9:9 | i | test1.c:16:16:16:16 | i | | ||
| | test1.c:11:9:11:9 | i | test1.c:32:16:32:16 | i | | ||
| | test1.c:12:9:12:9 | i | test1.c:40:16:40:16 | i | | ||
| | test1.c:13:9:13:9 | i | test1.c:48:16:48:16 | i | | ||
| | test1.c:16:16:16:16 | i | test1.c:18:16:18:16 | i | | ||
| | test1.c:32:16:32:16 | i | test1.c:33:11:33:11 | i | | ||
| | test1.c:40:16:40:16 | i | test1.c:41:11:41:11 | i | | ||
| | test1.c:48:16:48:16 | i | test1.c:53:15:53:15 | j | | ||
| nodes | ||
| | test1.c:7:26:7:29 | argv | semmle.label | argv | | ||
| | test1.c:7:26:7:29 | argv indirection | semmle.label | argv indirection | | ||
| | test1.c:7:26:7:29 | argv indirection | semmle.label | argv indirection | | ||
| | test1.c:9:9:9:9 | i | semmle.label | i | | ||
| | test1.c:11:9:11:9 | i | semmle.label | i | | ||
| | test1.c:12:9:12:9 | i | semmle.label | i | | ||
| | test1.c:13:9:13:9 | i | semmle.label | i | | ||
| | test1.c:16:16:16:16 | i | semmle.label | i | | ||
| | test1.c:18:16:18:16 | i | semmle.label | i | | ||
| | test1.c:32:16:32:16 | i | semmle.label | i | | ||
| | test1.c:33:11:33:11 | i | semmle.label | i | | ||
| | test1.c:40:16:40:16 | i | semmle.label | i | | ||
| | test1.c:41:11:41:11 | i | semmle.label | i | | ||
| | test1.c:48:16:48:16 | i | semmle.label | i | | ||
| | test1.c:53:15:53:15 | j | semmle.label | j | | ||
| subpaths | ||
|
|
@@ -43,9 +35,6 @@ subpaths | |
| | test1.c:33:11:33:11 | i | test1.c:7:26:7:29 | argv | test1.c:33:11:33:11 | i | An array indexing expression depends on $@ that might be outside the bounds of the array. | test1.c:7:26:7:29 | argv | a command-line argument | | ||
| | test1.c:33:11:33:11 | i | test1.c:7:26:7:29 | argv indirection | test1.c:33:11:33:11 | i | An array indexing expression depends on $@ that might be outside the bounds of the array. | test1.c:7:26:7:29 | argv indirection | a command-line argument | | ||
| | test1.c:33:11:33:11 | i | test1.c:7:26:7:29 | argv indirection | test1.c:33:11:33:11 | i | An array indexing expression depends on $@ that might be outside the bounds of the array. | test1.c:7:26:7:29 | argv indirection | a command-line argument | | ||
| | test1.c:41:11:41:11 | i | test1.c:7:26:7:29 | argv | test1.c:41:11:41:11 | i | An array indexing expression depends on $@ that might be outside the bounds of the array. | test1.c:7:26:7:29 | argv | a command-line argument | | ||
| | test1.c:41:11:41:11 | i | test1.c:7:26:7:29 | argv indirection | test1.c:41:11:41:11 | i | An array indexing expression depends on $@ that might be outside the bounds of the array. | test1.c:7:26:7:29 | argv indirection | a command-line argument | | ||
| | test1.c:41:11:41:11 | i | test1.c:7:26:7:29 | argv indirection | test1.c:41:11:41:11 | i | An array indexing expression depends on $@ that might be outside the bounds of the array. | test1.c:7:26:7:29 | argv indirection | a command-line argument | | ||
|
Comment on lines
-46
to
-48
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically this is a regression. However, this is also an FN on |
||
| | test1.c:53:15:53:15 | j | test1.c:7:26:7:29 | argv | test1.c:53:15:53:15 | j | An array indexing expression depends on $@ that might be outside the bounds of the array. | test1.c:7:26:7:29 | argv | a command-line argument | | ||
| | test1.c:53:15:53:15 | j | test1.c:7:26:7:29 | argv indirection | test1.c:53:15:53:15 | j | An array indexing expression depends on $@ that might be outside the bounds of the array. | test1.c:7:26:7:29 | argv indirection | a command-line argument | | ||
| | test1.c:53:15:53:15 | j | test1.c:7:26:7:29 | argv indirection | test1.c:53:15:53:15 | j | An array indexing expression depends on $@ that might be outside the bounds of the array. | test1.c:7:26:7:29 | argv indirection | a command-line argument | | ||
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
6 changes: 0 additions & 6 deletions
6
cpp/ql/test/query-tests/Security/CWE/CWE-326/InsufficientKeySize.expected
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
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.
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 just remembered that, while
getAUseis probably not wrong to use here, we might actually be able to reduce the number of nodes even more if we replaceresult.getAUse()withgetAUse(result)(which is a predicate that only finds the uses that are not ignored for dataflow purposes). This will likely result in more unique operands 🎉.We don't need to do that in this PR (since this PR is already doing wonderful usability improvements as-is), and I think a similar fix could be applied in the indirection case (where I think I made the exact same mistake).
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'll try to do a follow-up PR.
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.
Interestingly enough trying this gives me consistency errors in the dataflow tests.
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.
Oh, that's weird. Which ones are failing?
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.
dataflow tests:
Fields tests:
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.
They all seem to be related to constructors.
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.
Multiple
toStrings does sound like something we'd be able to fix, though 😄. That's probably also the reason for the newlocalFlowIsLocalinconsistencies (since multipletoStrings probably means that a inconsistency is reported multiple times).Multiple
toStrings often happens because a node belongs to several QL classes that each define atoString. Based on this, I think the way forward would be to usegetAQlClassto determine the overlapping node classes for some particular entity that belong to multiple classes that both define atoString. We can then figure out if we can merge those two classes in certain cases, or exclude thetoStringresult when they overlap.If this turns out to be too complicated, feel free to create an issue for it and leave it as future work.
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.
Definitely seems fixable, and yeah need to determine what the overlapping classes are.
I'll think I create an issue for it in any case, as this in not the top priority item and not needed to get the feature branch merged. Will revisit once I've re-worked the feature branch to be opt-in.