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
diff --git a/lldb/source/Host/netbsd/HostInfoNetBSD.cpp b/lldb/source/Host/netbsd/HostInfoNetBSD.cpp
index 11ac115..19afae3 100644
--- a/lldb/source/Host/netbsd/HostInfoNetBSD.cpp
+++ b/lldb/source/Host/netbsd/HostInfoNetBSD.cpp
@@ -21,8 +21,7 @@
using namespace lldb_private;
-bool HostInfoNetBSD::GetOSVersion(uint32_t &major, uint32_t &minor,
- uint32_t &update) {
+llvm::VersionTuple HostInfoNetBSD::GetOSVersion() {
struct utsname un;
::memset(&un, 0, sizeof(un));
@@ -33,18 +32,14 @@
int status = ::sscanf(un.release, "%" PRIu32 ".%" PRIu32 ".%" PRIu32, &major,
&minor, &update);
switch (status) {
- case 0:
- return false;
case 1:
- minor = 0;
- /* FALLTHROUGH */
+ return llvm::VersionTuple(major);
case 2:
- update = 0;
- /* FALLTHROUGH */
+ return llvm::VersionTuple(major, minor);
case 3:
- default:
- return true;
+ return llvm::VersionTuple(major, minor, update);
}
+ return llvm::VersionTuple();
}
bool HostInfoNetBSD::GetOSBuildString(std::string &s) {