Add UUID::SetFromOptionalStringRef, use it in DynamicLoaderDarwin

We use UUID::fromOptionalData to read UUID's from the Mach-O files, so UUID's
of all 0's are invalid UUID's.
We also get uuid's from debugserver, which need to match the file UUID's.  So
we need an API that treats "000000000" as invalid as well.  Added that and use it.

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

llvm-svn: 352122
This commit is contained in:
Jim Ingham
2019-01-24 22:43:44 +00:00
parent 8367b0750f
commit f3ecbfc164
4 changed files with 25 additions and 1 deletions

View File

@@ -109,3 +109,15 @@ size_t UUID::SetFromStringRef(llvm::StringRef str, uint32_t num_uuid_bytes) {
// Else return zero to indicate we were not able to parse a UUID value
return 0;
}
size_t UUID::SetFromOptionalStringRef(llvm::StringRef str,
uint32_t num_uuid_bytes) {
size_t num_chars_consumed = SetFromStringRef(str, num_uuid_bytes);
if (num_chars_consumed) {
if (llvm::all_of(m_bytes, [](uint8_t b) { return b == 0; }))
Clear();
}
return num_chars_consumed;
}