Skip to content
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

Swift: add SetContent for data flow #13838

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

rdmarsh2
Copy link
Contributor

No description provided.

@MathiasVP
Copy link
Contributor

Also small nitpick: How about just calling this CollectionContent? There's no reason why this Content can't be extended for non-Set things in a future PR.

@geoffw0
Copy link
Contributor

geoffw0 commented Jul 31, 2023

How about just calling this CollectionContent?

I like this idea.

@rdmarsh2 rdmarsh2 marked this pull request as ready for review August 3, 2023 21:10
@rdmarsh2 rdmarsh2 requested a review from a team as a code owner August 3, 2023 21:10
cs.isSingleton(c) and
result = "EnumElement[" + c.getSignature() + "]"
)
or
Copy link
Contributor

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 .


let set2 = Set([source()])
sink(arg: set2.randomElement()!) // $ MISSING: flow=703
sink(arg: set2.randomElement()!) // $ flow=706
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@MathiasVP
Copy link
Contributor

Do you mind rebasing this on the latest main so that we get a smaller diff @rdmarsh2?

@@ -255,7 +255,8 @@ private module Cached {
TFieldContent(FieldDecl f) or
TTupleContent(int index) { exists(any(TupleExpr te).getElement(index)) } or
TEnumContent(ParamDecl f) { exists(EnumElementDecl d | d.getAParam() = f) } or
TArrayContent()
TArrayContent() or
TSetContent()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think we should call this CollectionContent (see #13838 (comment))


/** An element of a set */
class CollectionContent extends Content, TCollectionContent {
override string toString() { result = "Set element" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
override string toString() { result = "Set element" }
override string toString() { result = "Collection element" }

@@ -492,6 +492,9 @@ predicate parseContent(AccessPathToken component, Content content) {
or
component.getName() = "ArrayElement" and
content instanceof Content::ArrayContent
or
component.getName() = "SetElement" and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be CollectionElement as well?

Suggested change
component.getName() = "SetElement" and
component.getName() = "CollectionElement" and

@@ -224,6 +224,11 @@ module Content {
class ArrayContent extends Content, TArrayContent {
override string toString() { result = "Array element" }
}

/** An element of a set */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/** An element of a set */
/** An element of a collection. */

or
exists(Content::CollectionContent c |
cs.isSingleton(c) and
result = "SetElement"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result = "SetElement"
result = "CollectionElement"

@@ -26,6 +26,8 @@ private class CollectionSummaries extends SummaryModelCsv {
";Collection;true;split(separator:maxSplits:omittingEmptySubsequences:);;;Argument[-1];ReturnValue;taint",
";Collection;true;removeFirst();;;Argument[-1];ReturnValue;taint",
";Collection;true;popFirst();;;Argument[-1];ReturnValue;taint",
";Collection;true;randomElement();;;Argument[-1].SetElement;ReturnValue.OptionalSome;value",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
";Collection;true;randomElement();;;Argument[-1].SetElement;ReturnValue.OptionalSome;value",
";Collection;true;randomElement();;;Argument[-1].CollectionElement;ReturnValue.OptionalSome;value",

Comment on lines +14 to +17
";Set;true;insert(_:);;;Argument[-1].SetElement;ReturnValue.TupleElement[1];value",
";Set;true;insert(_:);;;Argument[0];Argument[-1].SetElement;value",
";Set;true;insert(_:);;;Argument[0];ReturnValue.TupleElement[1];value",
";Set;true;init(_:);;;Argument[0].ArrayElement;ReturnValue.SetElement;value"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
";Set;true;insert(_:);;;Argument[-1].SetElement;ReturnValue.TupleElement[1];value",
";Set;true;insert(_:);;;Argument[0];Argument[-1].SetElement;value",
";Set;true;insert(_:);;;Argument[0];ReturnValue.TupleElement[1];value",
";Set;true;init(_:);;;Argument[0].ArrayElement;ReturnValue.SetElement;value"
";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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants