summaryrefslogtreecommitdiffstats
path: root/lldb/source/API/SBModule.cpp
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2018-06-18 15:02:23 +0000
committerPavel Labath <labath@google.com>2018-06-18 15:02:23 +0000
commit2272c4811f8d2c56612d483c2546f053e7ea61cc (patch)
treec591a7a541563c323f1b4f8697a8cd7b8ea53f8c /lldb/source/API/SBModule.cpp
parent13684d840019282ed720cd52a9a0e6c3485d3a76 (diff)
downloadbcm5719-llvm-2272c4811f8d2c56612d483c2546f053e7ea61cc.tar.gz
bcm5719-llvm-2272c4811f8d2c56612d483c2546f053e7ea61cc.zip
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
Diffstat (limited to 'lldb/source/API/SBModule.cpp')
-rw-r--r--lldb/source/API/SBModule.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/lldb/source/API/SBModule.cpp b/lldb/source/API/SBModule.cpp
index 1de1e547e50..8866cf448a3 100644
--- a/lldb/source/API/SBModule.cpp
+++ b/lldb/source/API/SBModule.cpp
@@ -531,16 +531,29 @@ uint32_t SBModule::GetAddressByteSize() {
}
uint32_t SBModule::GetVersion(uint32_t *versions, uint32_t num_versions) {
- ModuleSP module_sp(GetSP());
- if (module_sp)
- return module_sp->GetVersion(versions, num_versions);
- else {
- if (versions && num_versions) {
- for (uint32_t i = 0; i < num_versions; ++i)
- versions[i] = UINT32_MAX;
- }
- return 0;
- }
+ llvm::VersionTuple version;
+ if (ModuleSP module_sp = GetSP())
+ version = module_sp->GetVersion();
+ uint32_t result = 0;
+ if (!version.empty())
+ ++result;
+ if (version.getMinor())
+ ++result;
+ if(version.getSubminor())
+ ++result;
+
+ if (!versions)
+ return result;
+
+ if (num_versions > 0)
+ versions[0] = version.empty() ? UINT32_MAX : version.getMajor();
+ if (num_versions > 1)
+ versions[1] = version.getMinor().getValueOr(UINT32_MAX);
+ if (num_versions > 2)
+ versions[2] = version.getSubminor().getValueOr(UINT32_MAX);
+ for (uint32_t i = 3; i < num_versions; ++i)
+ versions[i] = UINT32_MAX;
+ return result;
}
lldb::SBFileSpec SBModule::GetSymbolFileSpec() const {
OpenPOWER on IntegriCloud