Use llvm::VersionTuple instead of manual version marshalling

Summary:
This has multiple advantages:
- we need only one function argument/instance variable instead of three
- no need to default initialize variables
- no custom parsing code
- VersionTuple has comparison operators, which makes version comparisons much
  simpler

Reviewers: zturner, friss, clayborg, jingham

Subscribers: emaste, lldb-commits

Differential Revision: https://reviews.llvm.org/D47889

llvm-svn: 334950
This commit is contained in:
Pavel Labath
2018-06-18 15:02:23 +00:00
parent 13684d8400
commit 2272c4811f
41 changed files with 256 additions and 564 deletions

View File

@@ -330,27 +330,24 @@ const char *SBPlatform::GetHostname() {
}
uint32_t SBPlatform::GetOSMajorVersion() {
uint32_t major, minor, update;
PlatformSP platform_sp(GetSP());
if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
return major;
return UINT32_MAX;
llvm::VersionTuple version;
if (PlatformSP platform_sp = GetSP())
version = platform_sp->GetOSVersion();
return version.empty() ? UINT32_MAX : version.getMajor();
}
uint32_t SBPlatform::GetOSMinorVersion() {
uint32_t major, minor, update;
PlatformSP platform_sp(GetSP());
if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
return minor;
return UINT32_MAX;
llvm::VersionTuple version;
if (PlatformSP platform_sp = GetSP())
version = platform_sp->GetOSVersion();
return version.getMinor().getValueOr(UINT32_MAX);
}
uint32_t SBPlatform::GetOSUpdateVersion() {
uint32_t major, minor, update;
PlatformSP platform_sp(GetSP());
if (platform_sp && platform_sp->GetOSVersion(major, minor, update))
return update;
return UINT32_MAX;
llvm::VersionTuple version;
if (PlatformSP platform_sp = GetSP())
version = platform_sp->GetOSVersion();
return version.getSubminor().getValueOr(UINT32_MAX);
}
SBError SBPlatform::Get(SBFileSpec &src, SBFileSpec &dst) {