diff options
Diffstat (limited to 'source/Utility/UUID.cpp')
-rw-r--r-- | source/Utility/UUID.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/source/Utility/UUID.cpp b/source/Utility/UUID.cpp index b00878792c7e..2a73f9a482ff 100644 --- a/source/Utility/UUID.cpp +++ b/source/Utility/UUID.cpp @@ -1,9 +1,8 @@ //===-- UUID.cpp ------------------------------------------------*- C++ -*-===// // -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// @@ -110,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; +} + |