-
Notifications
You must be signed in to change notification settings - Fork 2k
Swift: add SetContent for data flow #13838
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
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
de0ec3e
Swift: WIP SetContent for dataflow
b301092
Swift: model updates for Set
0142309
Swift: add summary read steps in dataflow
024c5cf
Swift: add MaD print support for EnumElement
6f38769
Swift: rename SetContent to CollectionContent
ccc3094
Swift: autoformat
10bbf44
Swift: QLDoc for Set.qll
3ebbb80
Swift: Change note for CollectionContent
146c500
Finish CollectionContent rename
rdmarsh2 07650af
Swift: accept test for CollectionContent rename
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| category: majorAnalysis | ||
| --- | ||
| * Added `DataFlow::CollectionContent`, which will enable more accurate flow through collections. |
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
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
20 changes: 20 additions & 0 deletions
20
swift/ql/lib/codeql/swift/frameworks/StandardLibrary/Set.qll
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 |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /** | ||
| * Provides models for `Set` and related Swift classes. | ||
| */ | ||
|
|
||
| private import codeql.swift.dataflow.ExternalFlow | ||
|
|
||
| /** | ||
| * A model for `Set` and related class members that permit data flow. | ||
| */ | ||
| private class SetSummaries extends SummaryModelCsv { | ||
| override predicate row(string row) { | ||
| row = | ||
| [ | ||
| ";Set;true;insert(_:);;;Argument[-1].CollectionElement;ReturnValue.TupleElement[1];value", | ||
| ";Set;true;insert(_:);;;Argument[0];Argument[-1].CollectionElement;value", | ||
| ";Set;true;insert(_:);;;Argument[0];ReturnValue.TupleElement[1];value", | ||
| ";Set;true;init(_:);;;Argument[0].ArrayElement;ReturnValue.CollectionElement;value" | ||
| ] | ||
| } | ||
| } |
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 |
|---|---|---|
|
|
@@ -692,4 +692,17 @@ func testArray() { | |
| var arr6 = [1,2,3] | ||
| arr6.insert(source(), at: 2) | ||
| sink(arg: arr6[0]) // $ flow=693 | ||
|
|
||
| var arr7 = [source()] | ||
| sink(arg: arr7.randomElement()!) // $ flow=696 | ||
| } | ||
|
|
||
| func testSetCollections() { | ||
| var set1: Set = [1,2,3] | ||
| sink(arg: set1.randomElement()!) | ||
| set1.insert(source()) | ||
| sink(arg: set1.randomElement()!) // $flow=703 | ||
|
|
||
| let set2 = Set([source()]) | ||
| sink(arg: set2.randomElement()!) // $ flow=706 | ||
|
Contributor
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. 🎉 |
||
| } | ||
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.
Thanks for adding this, I missed it in #13795 .