Simplify ObjectFile::GetUUID
instead of returning the UUID through by-ref argument and a boolean
value indicating success, we can just return it directly. Since the UUID
class already has an invalid state, it can be used to denote the failure
without the additional bool.
llvm-svn: 353714
diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
index b4c320f..4046082 100644
--- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
+++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
@@ -916,7 +916,7 @@
spec.GetArchitecture() = GetArchitecture(header, data, data_offset);
if (spec.GetArchitecture().IsValid()) {
- GetUUID(header, data, data_offset, spec.GetUUID());
+ spec.GetUUID() = GetUUID(header, data, data_offset);
specs.Append(spec);
}
}
@@ -4845,10 +4845,9 @@
}
}
-bool ObjectFileMachO::GetUUID(const llvm::MachO::mach_header &header,
+UUID ObjectFileMachO::GetUUID(const llvm::MachO::mach_header &header,
const lldb_private::DataExtractor &data,
- lldb::offset_t lc_offset,
- lldb_private::UUID &uuid) {
+ lldb::offset_t lc_offset) {
uint32_t i;
struct uuid_command load_cmd;
@@ -4870,16 +4869,15 @@
0xbb, 0x14, 0xf0, 0x0d};
if (!memcmp(uuid_bytes, opencl_uuid, 16))
- return false;
+ return UUID();
- uuid = UUID::fromOptionalData(uuid_bytes, 16);
- return true;
+ return UUID::fromOptionalData(uuid_bytes, 16);
}
- return false;
+ return UUID();
}
offset = cmd_offset + load_cmd.cmdsize;
}
- return false;
+ return UUID();
}
static llvm::StringRef GetOSName(uint32_t cmd) {
@@ -5066,14 +5064,14 @@
return arch;
}
-bool ObjectFileMachO::GetUUID(lldb_private::UUID *uuid) {
+UUID ObjectFileMachO::GetUUID() {
ModuleSP module_sp(GetModule());
if (module_sp) {
std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
lldb::offset_t offset = MachHeaderSizeFromMagic(m_header.magic);
- return GetUUID(m_header, m_data, offset, *uuid);
+ return GetUUID(m_header, m_data, offset);
}
- return false;
+ return UUID();
}
uint32_t ObjectFileMachO::GetDependentModules(FileSpecList &files) {
@@ -5553,8 +5551,7 @@
if (GetAddressByteSize() == 4) {
// 32 bit kexts are just object files, but they do have a valid
// UUID load command.
- UUID uuid;
- if (GetUUID(&uuid)) {
+ if (GetUUID()) {
// this checking for the UUID load command is not enough we could
// eventually look for the symbol named "OSKextGetCurrentIdentifier" as
// this is required of kexts
@@ -5597,8 +5594,7 @@
{
// 32 bit kexts are just object files, but they do have a valid
// UUID load command.
- UUID uuid;
- if (GetUUID(&uuid)) {
+ if (GetUUID()) {
// this checking for the UUID load command is not enough we could
// eventually look for the symbol named "OSKextGetCurrentIdentifier" as
// this is required of kexts