mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Teach ClangImporter to handle effective Swift version with minor release.
Needed to support Swift 4.2.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "clang/Basic/CharInfo.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "swift/AST/DiagnosticsParse.h"
|
||||
#include "swift/Basic/LLVM.h"
|
||||
#include "swift/Basic/Version.h"
|
||||
@@ -302,8 +303,13 @@ Optional<Version> Version::getEffectiveLanguageVersion() const {
|
||||
case 0:
|
||||
return None;
|
||||
case 1:
|
||||
case 2:
|
||||
break;
|
||||
case 2:
|
||||
// The only valid explicit language version with a minor
|
||||
// component is 4.2.
|
||||
if (Components[0] == 4 && Components[1] == 2)
|
||||
break;
|
||||
return None;
|
||||
default:
|
||||
// We do not want to permit users requesting more precise effective language
|
||||
// versions since accepting such an argument promises more than we're able
|
||||
@@ -327,9 +333,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'.
|
||||
// Version '4' on its own implies '4.1.50'.
|
||||
if (size() == 1)
|
||||
return Version{4, 1};
|
||||
return Version{4, 1, 50};
|
||||
return Version::getCurrentLanguageVersion();
|
||||
case 5:
|
||||
return Version{5, 0};
|
||||
@@ -346,6 +352,16 @@ Version Version::asMajorVersion() const {
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string Version::asAPINotesVersionString() const {
|
||||
// Other than for "4.2.x", map the Swift major version into
|
||||
// the API notes version for Swift. This has the effect of allowing
|
||||
// API notes to effect changes only on Swift major versions,
|
||||
// not minor versions.
|
||||
if (size() >= 2 && Components[0] == 4 && Components[1] == 2)
|
||||
return "4.2";
|
||||
return llvm::itostr(Components[0]);
|
||||
}
|
||||
|
||||
bool operator>=(const class Version &lhs,
|
||||
const class Version &rhs) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user