"-swift-version 3" means Swift 3.1, not 3.0. (#7883)

Put in a general mechanism for mapping user-specified "compatibility
versions" to proper "effective versions" (what #if and @available
checking should respect). This may still be different from the
intrinsic "language version"; right now master is considered a "3.1"
compiler with a "Swift 4 mode", and we plan to ship a "4.0" compiler
with a "Swift 3 mode" that will have a version number of something
like "3.2".

rdar://problem/29884401 / SR-3791
This commit is contained in:
Jordan Rose
2017-03-03 13:28:01 -08:00
committed by GitHub
parent bc6ea5b00f
commit 3456d04925
7 changed files with 130 additions and 42 deletions

View File

@@ -3491,15 +3491,19 @@ static int prepareForDump(const char *Main,
options::ModuleCachePath;
if (!options::SwiftVersion.empty()) {
if (auto Version = version::Version::
parseVersionString(options::SwiftVersion, SourceLoc(), nullptr)) {
if (Version.getValue().isValidEffectiveLanguageVersion())
InitInvok.getLangOptions().EffectiveLanguageVersion = Version.getValue();
else {
llvm::errs() << "Unsupported Swift Version.\n";
return 1;
using version::Version;
bool isValid = false;
if (auto Version = Version::parseVersionString(options::SwiftVersion,
SourceLoc(), nullptr)) {
if (auto Effective = Version.getValue().getEffectiveLanguageVersion()) {
InitInvok.getLangOptions().EffectiveLanguageVersion = *Effective;
isValid = true;
}
}
if (!isValid) {
llvm::errs() << "Unsupported Swift Version.\n";
return 1;
}
}
if (!options::ResourceDir.empty()) {