Skip to content

Swift: Generate better declaration names #9619

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 3 commits into from
Jun 20, 2022

Conversation

MathiasVP
Copy link
Contributor

Prior to this PR, the name we generate for the declarations:

func f(x first: Int, y second: Int, _ third: Int) { }
func f(z first: Int, w second: Int, _ third: Int) { }

were both just f. This makes it inconvenient to mark the first function overload as a taint source purely based on the name. In addition, the Swift compiler refers to each overload as f(x:y:_:) and f(z:w:_:) respectively.

With this PR, we generate the expected names (i.e., f(x:y:_:) and f(z:w:_:)) for the function overloads.

Note that as a special case of this, the name of a function f with no parameters:

func f() {  }

is actually f() with parentheses! That's a bit confusing to me since it looks like a function call (even though it's actually a reference to the function). This matches the output of swiftc, though.

This special case required a slight modification to swift/ql/test/library-tests/dataflow/dataflow/DataFlow.ql (which is included in c049988).

@MathiasVP MathiasVP requested a review from a team as a code owner June 20, 2022 14:07
@github-actions github-actions bot added the Swift label Jun 20, 2022
@MathiasVP MathiasVP changed the title Swift: Generate declaration names that matches the Swift: Generate better declaration names Jun 20, 2022
AlexDenisov
AlexDenisov previously approved these changes Jun 20, 2022
Copy link
Contributor

@AlexDenisov AlexDenisov left a comment

Choose a reason for hiding this comment

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

This looks so much better now! ❤️

@MathiasVP MathiasVP merged commit f4363e3 into github:main Jun 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants