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

[WIP] Added -swift-version support for 4.2 #15407

Merged
merged 4 commits into from
Mar 24, 2018

Conversation

tkremenek
Copy link
Member

No description provided.

Further, when ‘4’ is specified on its own for the language
version without a minor component, assume ‘4.1’ as the
language version.
@tkremenek tkremenek requested a review from jrose-apple March 21, 2018 21:41
@tkremenek
Copy link
Member Author

@jrose-apple This is incomplete. I just wanted to make sure this looks on the right track as far as specifying the version mode to "4.1" with --swift-version 4.

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

Looks fine so far. If there are any problems in this whole endeavour I'd expect it to be in the importer.

@@ -326,6 +327,9 @@ Optional<Version> Version::getEffectiveLanguageVersion() const {
case 4:
static_assert(SWIFT_VERSION_MAJOR == 4,
"getCurrentLanguageVersion is no longer correct here");
// Version '4' on its own implies '4.1'.
if (size() == 1)
return Version{4, 1};
return Version::getCurrentLanguageVersion();
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like this should at least check for 4.0 and 4.1.

Copy link
Member Author

Choose a reason for hiding this comment

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

Check in what way? The driver will disallow passing "4.0" and "4.1" explicitly. The only thing the driver will allow is passing "4.2". We could add an assert that, if there is a second component, that it is "2". WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, right, the allowed-language-versions check. Okay, yes, that assert would be good enough for me.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, it shouldn't be 4.1, though. It needs to be higher than any 4.1 point updates we release, right? So 4.1.99 or something.

Copy link
Member Author

Choose a reason for hiding this comment

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

I spoke wrong. The allowed-language-versions check is defined in terms of getEffectiveLanguageVersion.

@tkremenek
Copy link
Member Author

@jrose-apple I added the necessary logic to teach the ClangImporter about 4.2 and to handle minor versions. It's not very pretty. Most of it is OK, except:

  • It feels like a form of DRY violations to special case "4.2" in a couple places.
  • The logic in ImportName.cpp feels especially brittle. The entire implementation of ImportNameVersion assumed major versions were the only thing the importer needed to care about. I came up with a solution that fits in the existing implementation fine, but feels brittle from a maintainability perspective.

@tkremenek
Copy link
Member Author

@swift-ci smoke test

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

Looking good so far!

// We encode the 'rawValue' as just major version numbers with the
// exception of '4.2', which is a special minor version that can impact
// importing of names. We treat that with a rawValue of 5, and treat
// all major values of 5 or higher as being rawValue = majorversion + 1.
Copy link
Contributor

Choose a reason for hiding this comment

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

Since we don't distinguish between Swift 1 and Swift 2, what do you think about moving the raw values down instead of up? It's a trick that will only work once, but even so.

@@ -259,7 +259,7 @@ SwiftVersions:
SwiftName: multiVersionedGlobal45Notes_5
- Name: multiVersionedGlobal45Both
SwiftName: multiVersionedGlobal45Both_5
- Version: 4 # Versions are deliberately ordered as "3, 5, 4" to catch bugs.
- Version: 4 # Versions are deliberately ordered as "3, 5, 4.2, 4" to catch bugs.
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a separate test that shows that "Version: 4.2" with no other versions specified also affects -swift-version 4 and -swift-version 3?, and that "Version: 4" with no other versions does not affect -swift-version 4.2? Or maybe that's in here already; the original 3-4-5 tests did do things like that.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jrose-apple I added this in the latest commit.

@jrose-apple
Copy link
Contributor

I do agree about the 4.2 being repeated. I'll see if I can think of a better way as well.

This tests that a “Version 4.2” change impacts
-swift-version 3 and 4, but not 5.
@tkremenek
Copy link
Member Author

@swift-ci smoke test

@tkremenek
Copy link
Member Author

@jrose-apple what do you think about landing this as is, and further refinements to ImportNameVersion (if any) in follow up?

Copy link
Contributor

@jrose-apple jrose-apple left a comment

Choose a reason for hiding this comment

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

Sure, that sounds reasonable to me.

@tkremenek tkremenek merged commit fe75380 into swiftlang:master Mar 24, 2018
@tkremenek tkremenek deleted the driver-ver-4.2 branch March 24, 2018 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants