diff options
Diffstat (limited to 'source/Utility/Status.cpp')
-rw-r--r-- | source/Utility/Status.cpp | 37 |
1 files changed, 4 insertions, 33 deletions
diff --git a/source/Utility/Status.cpp b/source/Utility/Status.cpp index 062bd261ea8b..3d64fb810abf 100644 --- a/source/Utility/Status.cpp +++ b/source/Utility/Status.cpp @@ -1,10 +1,9 @@ //===-- Status.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 // //===----------------------------------------------------------------------===// @@ -48,8 +47,6 @@ Status::Status(std::error_code EC) : m_code(EC.value()), m_type(ErrorType::eErrorTypeGeneric), m_string(EC.message()) {} -Status::Status(const Status &rhs) = default; - Status::Status(const char *format, ...) : m_code(0), m_type(eErrorTypeInvalid), m_string() { va_list args; @@ -96,9 +93,7 @@ llvm::Error Status::ToError() const { llvm::inconvertibleErrorCode()); } -//---------------------------------------------------------------------- // Assignment operator -//---------------------------------------------------------------------- const Status &Status::operator=(const Status &rhs) { if (this != &rhs) { m_code = rhs.m_code; @@ -127,11 +122,9 @@ static std::string RetrieveWin32ErrorString(uint32_t error_code) { } #endif -//---------------------------------------------------------------------- // Get the error value as a NULL C string. The error string will be fetched and // cached on demand. The cached error string value will remain until the error // value is changed or cleared. -//---------------------------------------------------------------------- const char *Status::AsCString(const char *default_error_str) const { if (Success()) return nullptr; @@ -168,35 +161,25 @@ const char *Status::AsCString(const char *default_error_str) const { return m_string.c_str(); } -//---------------------------------------------------------------------- // Clear the error and any cached error string that it might contain. -//---------------------------------------------------------------------- void Status::Clear() { m_code = 0; m_type = eErrorTypeInvalid; m_string.clear(); } -//---------------------------------------------------------------------- // Access the error value. -//---------------------------------------------------------------------- Status::ValueType Status::GetError() const { return m_code; } -//---------------------------------------------------------------------- // Access the error type. -//---------------------------------------------------------------------- ErrorType Status::GetType() const { return m_type; } -//---------------------------------------------------------------------- // Returns true if this object contains a value that describes an error or // otherwise non-success result. -//---------------------------------------------------------------------- bool Status::Fail() const { return m_code != 0; } -//---------------------------------------------------------------------- // Set accessor for the error value to "err" and the type to // "eErrorTypeMachKernel" -//---------------------------------------------------------------------- void Status::SetMachError(uint32_t err) { m_code = err; m_type = eErrorTypeMachKernel; @@ -227,40 +210,32 @@ int Status::SetExpressionErrorWithFormat(lldb::ExpressionResults result, return length; } -//---------------------------------------------------------------------- // Set accessor for the error value and type. -//---------------------------------------------------------------------- void Status::SetError(ValueType err, ErrorType type) { m_code = err; m_type = type; m_string.clear(); } -//---------------------------------------------------------------------- // Update the error value to be "errno" and update the type to be "POSIX". -//---------------------------------------------------------------------- void Status::SetErrorToErrno() { m_code = errno; m_type = eErrorTypePOSIX; m_string.clear(); } -//---------------------------------------------------------------------- // Update the error value to be LLDB_GENERIC_ERROR and update the type to be // "Generic". -//---------------------------------------------------------------------- void Status::SetErrorToGenericError() { m_code = LLDB_GENERIC_ERROR; m_type = eErrorTypeGeneric; m_string.clear(); } -//---------------------------------------------------------------------- // Set accessor for the error string value for a specific error. This allows // any string to be supplied as an error explanation. The error string value // will remain until the error value is cleared or a new error value/type is // assigned. -//---------------------------------------------------------------------- void Status::SetErrorString(llvm::StringRef err_str) { if (!err_str.empty()) { // If we have an error string, we should always at least have an error set @@ -271,12 +246,10 @@ void Status::SetErrorString(llvm::StringRef err_str) { m_string = err_str; } -//------------------------------------------------------------------ /// Set the current error string to a formatted error string. /// -/// @param format +/// \param format /// A printf style format string -//------------------------------------------------------------------ int Status::SetErrorStringWithFormat(const char *format, ...) { if (format != nullptr && format[0]) { va_list args; @@ -307,10 +280,8 @@ int Status::SetErrorStringWithVarArg(const char *format, va_list args) { return 0; } -//---------------------------------------------------------------------- // Returns true if the error code in this object is considered a successful // return value. -//---------------------------------------------------------------------- bool Status::Success() const { return m_code == 0; } bool Status::WasInterrupted() const { |