summaryrefslogtreecommitdiff
path: root/source/Utility/Status.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-06-10 13:44:58 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-06-10 13:44:58 +0000
commitf1d04915a666728c241bedb36bd99aafee3ea444 (patch)
treed63378f567f214209764be264c47c8b0814e1665 /source/Utility/Status.cpp
parent60bb8ce74a67345b14fd540dd739254f562c605b (diff)
Notes
Diffstat (limited to 'source/Utility/Status.cpp')
-rw-r--r--source/Utility/Status.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/source/Utility/Status.cpp b/source/Utility/Status.cpp
index ba87d3e5144f..6ecc7717620b 100644
--- a/source/Utility/Status.cpp
+++ b/source/Utility/Status.cpp
@@ -11,10 +11,11 @@
#include "lldb/Utility/Status.h"
#include "lldb/Utility/VASPrintf.h"
-#include "lldb/lldb-defines.h" // for LLDB_GENERIC_ERROR
-#include "lldb/lldb-enumerations.h" // for ErrorType, ErrorType::eErr...
-#include "llvm/ADT/SmallString.h" // for SmallString
-#include "llvm/ADT/StringRef.h" // for StringRef
+#include "lldb/lldb-defines.h" // for LLDB_GENERIC_ERROR
+#include "lldb/lldb-enumerations.h" // for ErrorType, ErrorType::eErr...
+#include "llvm/ADT/SmallString.h" // for SmallString
+#include "llvm/ADT/StringRef.h" // for StringRef
+#include "llvm/Support/Errno.h"
#include "llvm/Support/FormatProviders.h" // for format_provider
#include <cerrno>
@@ -27,7 +28,6 @@
#endif
#include <stdint.h> // for uint32_t
-#include <string.h> // for strerror
namespace llvm {
class raw_ostream;
@@ -121,23 +121,21 @@ const char *Status::AsCString(const char *default_error_str) const {
return nullptr;
if (m_string.empty()) {
- const char *s = nullptr;
switch (m_type) {
case eErrorTypeMachKernel:
#if defined(__APPLE__)
- s = ::mach_error_string(m_code);
+ if (const char *s = ::mach_error_string(m_code))
+ m_string.assign(s);
#endif
break;
case eErrorTypePOSIX:
- s = ::strerror(m_code);
+ m_string = llvm::sys::StrError(m_code);
break;
default:
break;
}
- if (s != nullptr)
- m_string.assign(s);
}
if (m_string.empty()) {
if (default_error_str)