[next] Use new VersionTuple API

The `VersionTuple` API was changed llvm/llvm-project
219672b8dd06c4765185fa3161c98437d49b4a1b to return `VersionTuple`
from `get*Version` rather than pass in major, minor, and subminor output
parameters. Update uses to the new API.

Note that `getMacOSXVersion` is slightly different in that it returns a
boolean while taking a `VersionTuple` output parameter to match its
previous behaviour. There doesn't seem to be any use that actually
checks this value though, so we should either update the API to return
an `Optional` and actually check it *or* remove the "failure" case and
return a `VersionTuple` like all the others.
This commit is contained in:
Ben Barham
2022-04-25 17:00:51 -07:00
parent 68296c9037
commit 114b4d96e4
8 changed files with 71 additions and 85 deletions

View File

@@ -689,14 +689,14 @@ SerializedModuleLoaderBase::findModule(ImportPath::Element moduleID,
static std::pair<StringRef, clang::VersionTuple>
getOSAndVersionForDiagnostics(const llvm::Triple &triple) {
StringRef osName;
unsigned major, minor, micro;
llvm::VersionTuple osVersion;
if (triple.isMacOSX()) {
// macOS triples represent their versions differently, so we have to use the
// special accessor.
triple.getMacOSXVersion(major, minor, micro);
triple.getMacOSXVersion(osVersion);
osName = swift::prettyPlatformString(PlatformKind::macOS);
} else {
triple.getOSVersion(major, minor, micro);
osVersion = triple.getOSVersion();
if (triple.isWatchOS()) {
osName = swift::prettyPlatformString(PlatformKind::watchOS);
} else if (triple.isTvOS()) {
@@ -714,12 +714,7 @@ getOSAndVersionForDiagnostics(const llvm::Triple &triple) {
}
assert(!osName.empty());
clang::VersionTuple version;
if (micro != 0)
version = clang::VersionTuple(major, minor, micro);
else
version = clang::VersionTuple(major, minor);
return {osName, version};
return {osName, osVersion};
}
LoadedFile *SerializedModuleLoaderBase::loadAST(