786 changes: 10 additions & 776 deletions llvm/include/llvm/Support/system_error.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion llvm/lib/Object/Error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ std::string _object_error_category::message(int EV) const {
error_condition _object_error_category::default_error_condition(int EV) const {
if (static_cast<object_error>(EV) == object_error::success)
return error_condition();
return errc::invalid_argument;
return std::errc::invalid_argument;
}

const error_category &object::object_category() {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/ProfileData/InstrProf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class InstrProfErrorCategoryType : public error_category {
error_condition default_error_condition(int EV) const LLVM_NOEXCEPT override {
if (static_cast<instrprof_error>(EV) == instrprof_error::success)
return error_condition();
return errc::invalid_argument;
return std::errc::invalid_argument;
}
};
}
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ add_llvm_library(LLVMSupport
RWMutex.cpp
SearchForAddressOfSpecialSymbol.cpp
Signals.cpp
system_error.cpp
TargetRegistry.cpp
ThreadLocal.cpp
Threading.cpp
TimeValue.cpp
Valgrind.cpp
Watchdog.cpp
WindowsError.cpp

ADDITIONAL_HEADERS
Unix/Host.inc
Expand All @@ -100,7 +100,6 @@ add_llvm_library(LLVMSupport
Unix/Program.inc
Unix/RWMutex.inc
Unix/Signals.inc
Unix/system_error.inc
Unix/ThreadLocal.inc
Unix/TimeValue.inc
Unix/Watchdog.inc
Expand All @@ -113,7 +112,6 @@ add_llvm_library(LLVMSupport
Windows/Program.inc
Windows/RWMutex.inc
Windows/Signals.inc
Windows/system_error.inc
Windows/ThreadLocal.inc
Windows/TimeValue.inc
Windows/Watchdog.inc
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Support/FileOutputBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ error_code FileOutputBuffer::create(StringRef FilePath,
if (EC)
return EC;
else
return make_error_code(errc::operation_not_permitted);
return make_error_code(std::errc::operation_not_permitted);
}

// Delete target file.
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Support/LockFileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ LockFileManager::LockFileManager(StringRef FileName)
if (Out.has_error()) {
// We failed to write out PID, so make up an excuse, remove the
// unique lock file, and fail.
Error = make_error_code(errc::no_space_on_device);
Error = make_error_code(std::errc::no_space_on_device);
sys::fs::remove(UniqueLockFileName.c_str());
return;
}
Expand All @@ -127,7 +127,7 @@ LockFileManager::LockFileManager(StringRef FileName)
if (!EC)
return;

if (EC != errc::file_exists) {
if (EC != std::errc::file_exists) {
Error = EC;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Support/MemoryBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ static error_code getOpenFileImpl(int FD, const char *Filename,
if (!Buf) {
// Failed to create a buffer. The only way it can fail is if
// new(std::nothrow) returns 0.
return make_error_code(errc::not_enough_memory);
return make_error_code(std::errc::not_enough_memory);
}

std::unique_ptr<MemoryBuffer> SB(Buf);
Expand Down
10 changes: 5 additions & 5 deletions llvm/lib/Support/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ static error_code createUniqueEntity(const Twine &Model, int &ResultFD,
if (error_code EC =
sys::fs::openFileForWrite(Twine(ResultPath.begin()), ResultFD,
sys::fs::F_RW | sys::fs::F_Excl, Mode)) {
if (EC == errc::file_exists)
if (EC == std::errc::file_exists)
goto retry_random_path;
return EC;
}
Expand All @@ -224,7 +224,7 @@ static error_code createUniqueEntity(const Twine &Model, int &ResultFD,

case FS_Dir: {
if (error_code EC = sys::fs::create_directory(ResultPath.begin(), false)) {
if (EC == errc::file_exists)
if (EC == std::errc::file_exists)
goto retry_random_path;
return EC;
}
Expand Down Expand Up @@ -829,7 +829,7 @@ error_code create_directories(const Twine &Path, bool IgnoreExisting) {
error_code EC = create_directory(P, IgnoreExisting);
// If we succeeded, or had any error other than the parent not existing, just
// return it.
if (EC != errc::no_such_file_or_directory)
if (EC != std::errc::no_such_file_or_directory)
return EC;

// We failed because of a no_such_file_or_directory, try to create the
Expand Down Expand Up @@ -896,7 +896,7 @@ error_code has_magic(const Twine &path, const Twine &magic, bool &result) {
SmallString<32> Buffer;

if (error_code ec = get_magic(path, Magic.size(), Buffer)) {
if (ec == errc::value_too_large) {
if (ec == std::errc::value_too_large) {
// Magic.size() > file_size(Path).
result = false;
return error_code();
Expand Down Expand Up @@ -1043,7 +1043,7 @@ error_code has_magic(const Twine &path, const Twine &magic, bool &result) {
error_code identify_magic(const Twine &path, file_magic &result) {
SmallString<32> Magic;
error_code ec = get_magic(path, Magic.capacity(), Magic);
if (ec && ec != errc::value_too_large)
if (ec && ec != std::errc::value_too_large)
return ec;

result = identify_magic(Magic);
Expand Down
12 changes: 6 additions & 6 deletions llvm/lib/Support/Unix/Path.inc
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ error_code remove(const Twine &path, bool IgnoreNonExisting) {
// effectively prevents LLVM from erasing things like /dev/null, any block
// special file, or other things that aren't "regular" files.
if (!S_ISREG(buf.st_mode) && !S_ISDIR(buf.st_mode) && !S_ISLNK(buf.st_mode))
return make_error_code(errc::operation_not_permitted);
return make_error_code(std::errc::operation_not_permitted);

if (::remove(p.begin()) == -1) {
if (errno != ENOENT || !IgnoreNonExisting)
Expand Down Expand Up @@ -402,7 +402,7 @@ static error_code fillStatus(int StatRet, const struct stat &Status,
file_status &Result) {
if (StatRet != 0) {
error_code ec(errno, generic_category());
if (ec == errc::no_such_file_or_directory)
if (ec == std::errc::no_such_file_or_directory)
Result = file_status(file_type::file_not_found);
else
Result = file_status(file_type::status_error);
Expand Down Expand Up @@ -466,7 +466,7 @@ error_code setLastModificationAndAccessTime(int FD, TimeValue Time) {
return error_code();
#else
#warning Missing futimes() and futimens()
return make_error_code(errc::not_supported);
return make_error_code(std::errc::not_supported);
#endif
}

Expand Down Expand Up @@ -510,7 +510,7 @@ mapped_file_region::mapped_file_region(const Twine &path,
, Mapping() {
// Make sure that the requested size fits within SIZE_T.
if (length > std::numeric_limits<size_t>::max()) {
ec = make_error_code(errc::invalid_argument);
ec = make_error_code(std::errc::invalid_argument);
return;
}

Expand Down Expand Up @@ -539,7 +539,7 @@ mapped_file_region::mapped_file_region(int fd,
, Mapping() {
// Make sure that the requested size fits within SIZE_T.
if (length > std::numeric_limits<size_t>::max()) {
ec = make_error_code(errc::invalid_argument);
ec = make_error_code(std::errc::invalid_argument);
return;
}

Expand Down Expand Up @@ -645,7 +645,7 @@ error_code get_magic(const Twine &path, uint32_t len,
if (std::feof(file) != 0) {
std::fclose(file);
result.set_size(size);
return make_error_code(errc::value_too_large);
return make_error_code(std::errc::value_too_large);
}
}
std::fclose(file);
Expand Down
34 changes: 0 additions & 34 deletions llvm/lib/Support/Unix/system_error.inc

This file was deleted.

17 changes: 9 additions & 8 deletions llvm/lib/Support/Windows/Path.inc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//===----------------------------------------------------------------------===//

#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/WindowsError.h"
#include <fcntl.h>
#include <io.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -45,7 +46,7 @@ using llvm::sys::windows::UTF8ToUTF16;
using llvm::sys::windows::UTF16ToUTF8;

static error_code windows_error(DWORD E) {
return error_code(E, system_category());
return mapWindowsError(E);
}

static error_code TempDir(SmallVectorImpl<char> &Result) {
Expand Down Expand Up @@ -193,7 +194,7 @@ error_code remove(const Twine &path, bool IgnoreNonExisting) {

file_status ST;
if (error_code EC = status(path, ST)) {
if (EC != errc::no_such_file_or_directory || !IgnoreNonExisting)
if (EC != std::errc::no_such_file_or_directory || !IgnoreNonExisting)
return EC;
return error_code();
}
Expand All @@ -205,14 +206,14 @@ error_code remove(const Twine &path, bool IgnoreNonExisting) {
if (ST.type() == file_type::directory_file) {
if (!::RemoveDirectoryW(c_str(path_utf16))) {
error_code EC = windows_error(::GetLastError());
if (EC != errc::no_such_file_or_directory || !IgnoreNonExisting)
if (EC != std::errc::no_such_file_or_directory || !IgnoreNonExisting)
return EC;
}
return error_code();
}
if (!::DeleteFileW(c_str(path_utf16))) {
error_code EC = windows_error(::GetLastError());
if (EC != errc::no_such_file_or_directory || !IgnoreNonExisting)
if (EC != std::errc::no_such_file_or_directory || !IgnoreNonExisting)
return EC;
}
return error_code();
Expand Down Expand Up @@ -516,7 +517,7 @@ error_code mapped_file_region::init(int FD, bool CloseFD, uint64_t Offset) {
_close(FileDescriptor);
} else
::CloseHandle(FileHandle);
return make_error_code(errc::invalid_argument);
return make_error_code(std::errc::invalid_argument);
}

DWORD flprotect;
Expand Down Expand Up @@ -652,7 +653,7 @@ mapped_file_region::mapped_file_region(int fd,
if (closefd)
_close(FileDescriptor);
FileDescriptor = 0;
ec = make_error_code(errc::bad_file_descriptor);
ec = make_error_code(std::errc::bad_file_descriptor);
return;
}

Expand Down Expand Up @@ -815,7 +816,7 @@ error_code openFileForRead(const Twine &Name, int &ResultFD) {
if (LastError != ERROR_ACCESS_DENIED)
return EC;
if (is_directory(Name))
return make_error_code(errc::is_a_directory);
return make_error_code(std::errc::is_a_directory);
return EC;
}

Expand Down Expand Up @@ -867,7 +868,7 @@ error_code openFileForWrite(const Twine &Name, int &ResultFD,
if (LastError != ERROR_ACCESS_DENIED)
return EC;
if (is_directory(Name))
return make_error_code(errc::is_a_directory);
return make_error_code(std::errc::is_a_directory);
return EC;
}

Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Support/Windows/Process.inc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#include "llvm/Support/Allocator.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/WindowsError.h"
#include <malloc.h>

// The Windows.h header must be after LLVM and standard headers.
Expand Down Expand Up @@ -180,7 +181,7 @@ Optional<std::string> Process::GetEnv(StringRef Name) {
}

static error_code windows_error(DWORD E) {
return error_code(E, system_category());
return mapWindowsError(E);
}

error_code
Expand Down
141 changes: 0 additions & 141 deletions llvm/lib/Support/Windows/system_error.inc

This file was deleted.

115 changes: 115 additions & 0 deletions llvm/lib/Support/WindowsError.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
//===-- WindowsError.cpp - Support for mapping windows errors to posix-----===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements a mapping from windows errors to posix ones.
// The standard doesn't define what the equivalence is from system
// errors to generic ones. The one implemented in msvc is too conservative
// for llvm, so we do an extra mapping when constructing an error_code
// from an windows error. This allows the rest of llvm to simple checks
// like "EC == std::errc::file_exists" and have it work on both posix and
// windows.
//
//===----------------------------------------------------------------------===//

#ifdef _MSC_VER

#include <winerror.h>

#include "llvm/Support/WindowsError.h"

// I'd rather not double the line count of the following.
#define MAP_ERR_TO_COND(x, y) \
case x: \
return std::make_error_code(std::errc::y)

std::error_code llvm::mapWindowsError(unsigned EV) {
switch (EV) {
MAP_ERR_TO_COND(ERROR_ACCESS_DENIED, permission_denied);
MAP_ERR_TO_COND(ERROR_ALREADY_EXISTS, file_exists);
MAP_ERR_TO_COND(ERROR_BAD_UNIT, no_such_device);
MAP_ERR_TO_COND(ERROR_BUFFER_OVERFLOW, filename_too_long);
MAP_ERR_TO_COND(ERROR_BUSY, device_or_resource_busy);
MAP_ERR_TO_COND(ERROR_BUSY_DRIVE, device_or_resource_busy);
MAP_ERR_TO_COND(ERROR_CANNOT_MAKE, permission_denied);
MAP_ERR_TO_COND(ERROR_CANTOPEN, io_error);
MAP_ERR_TO_COND(ERROR_CANTREAD, io_error);
MAP_ERR_TO_COND(ERROR_CANTWRITE, io_error);
MAP_ERR_TO_COND(ERROR_CURRENT_DIRECTORY, permission_denied);
MAP_ERR_TO_COND(ERROR_DEV_NOT_EXIST, no_such_device);
MAP_ERR_TO_COND(ERROR_DEVICE_IN_USE, device_or_resource_busy);
MAP_ERR_TO_COND(ERROR_DIR_NOT_EMPTY, directory_not_empty);
MAP_ERR_TO_COND(ERROR_DIRECTORY, invalid_argument);
MAP_ERR_TO_COND(ERROR_DISK_FULL, no_space_on_device);
MAP_ERR_TO_COND(ERROR_FILE_EXISTS, file_exists);
MAP_ERR_TO_COND(ERROR_FILE_NOT_FOUND, no_such_file_or_directory);
MAP_ERR_TO_COND(ERROR_HANDLE_DISK_FULL, no_space_on_device);
MAP_ERR_TO_COND(ERROR_HANDLE_EOF, value_too_large);
MAP_ERR_TO_COND(ERROR_INVALID_ACCESS, permission_denied);
MAP_ERR_TO_COND(ERROR_INVALID_DRIVE, no_such_device);
MAP_ERR_TO_COND(ERROR_INVALID_FUNCTION, function_not_supported);
MAP_ERR_TO_COND(ERROR_INVALID_HANDLE, invalid_argument);
MAP_ERR_TO_COND(ERROR_INVALID_NAME, invalid_argument);
MAP_ERR_TO_COND(ERROR_LOCK_VIOLATION, no_lock_available);
MAP_ERR_TO_COND(ERROR_LOCKED, no_lock_available);
MAP_ERR_TO_COND(ERROR_NEGATIVE_SEEK, invalid_argument);
MAP_ERR_TO_COND(ERROR_NOACCESS, permission_denied);
MAP_ERR_TO_COND(ERROR_NOT_ENOUGH_MEMORY, not_enough_memory);
MAP_ERR_TO_COND(ERROR_NOT_READY, resource_unavailable_try_again);
MAP_ERR_TO_COND(ERROR_NOT_SAME_DEVICE, cross_device_link);
MAP_ERR_TO_COND(ERROR_OPEN_FAILED, io_error);
MAP_ERR_TO_COND(ERROR_OPEN_FILES, device_or_resource_busy);
MAP_ERR_TO_COND(ERROR_OPERATION_ABORTED, operation_canceled);
MAP_ERR_TO_COND(ERROR_OUTOFMEMORY, not_enough_memory);
MAP_ERR_TO_COND(ERROR_PATH_NOT_FOUND, no_such_file_or_directory);
MAP_ERR_TO_COND(ERROR_BAD_NETPATH, no_such_file_or_directory);
MAP_ERR_TO_COND(ERROR_READ_FAULT, io_error);
MAP_ERR_TO_COND(ERROR_RETRY, resource_unavailable_try_again);
MAP_ERR_TO_COND(ERROR_SEEK, io_error);
MAP_ERR_TO_COND(ERROR_SHARING_VIOLATION, permission_denied);
MAP_ERR_TO_COND(ERROR_TOO_MANY_OPEN_FILES, too_many_files_open);
MAP_ERR_TO_COND(ERROR_WRITE_FAULT, io_error);
MAP_ERR_TO_COND(ERROR_WRITE_PROTECT, permission_denied);
MAP_ERR_TO_COND(ERROR_SEM_TIMEOUT, timed_out);
MAP_ERR_TO_COND(WSAEACCES, permission_denied);
MAP_ERR_TO_COND(WSAEADDRINUSE, address_in_use);
MAP_ERR_TO_COND(WSAEADDRNOTAVAIL, address_not_available);
MAP_ERR_TO_COND(WSAEAFNOSUPPORT, address_family_not_supported);
MAP_ERR_TO_COND(WSAEALREADY, connection_already_in_progress);
MAP_ERR_TO_COND(WSAEBADF, bad_file_descriptor);
MAP_ERR_TO_COND(WSAECONNABORTED, connection_aborted);
MAP_ERR_TO_COND(WSAECONNREFUSED, connection_refused);
MAP_ERR_TO_COND(WSAECONNRESET, connection_reset);
MAP_ERR_TO_COND(WSAEDESTADDRREQ, destination_address_required);
MAP_ERR_TO_COND(WSAEFAULT, bad_address);
MAP_ERR_TO_COND(WSAEHOSTUNREACH, host_unreachable);
MAP_ERR_TO_COND(WSAEINPROGRESS, operation_in_progress);
MAP_ERR_TO_COND(WSAEINTR, interrupted);
MAP_ERR_TO_COND(WSAEINVAL, invalid_argument);
MAP_ERR_TO_COND(WSAEISCONN, already_connected);
MAP_ERR_TO_COND(WSAEMFILE, too_many_files_open);
MAP_ERR_TO_COND(WSAEMSGSIZE, message_size);
MAP_ERR_TO_COND(WSAENAMETOOLONG, filename_too_long);
MAP_ERR_TO_COND(WSAENETDOWN, network_down);
MAP_ERR_TO_COND(WSAENETRESET, network_reset);
MAP_ERR_TO_COND(WSAENETUNREACH, network_unreachable);
MAP_ERR_TO_COND(WSAENOBUFS, no_buffer_space);
MAP_ERR_TO_COND(WSAENOPROTOOPT, no_protocol_option);
MAP_ERR_TO_COND(WSAENOTCONN, not_connected);
MAP_ERR_TO_COND(WSAENOTSOCK, not_a_socket);
MAP_ERR_TO_COND(WSAEOPNOTSUPP, operation_not_supported);
MAP_ERR_TO_COND(WSAEPROTONOSUPPORT, protocol_not_supported);
MAP_ERR_TO_COND(WSAEPROTOTYPE, wrong_protocol_type);
MAP_ERR_TO_COND(WSAETIMEDOUT, timed_out);
MAP_ERR_TO_COND(WSAEWOULDBLOCK, operation_would_block);
default:
return std::error_code(EV, std::system_category());
}
}

#endif
6 changes: 3 additions & 3 deletions llvm/lib/Support/YAMLTraits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ bool Input::setCurrentDocument() {
Node *N = DocIterator->getRoot();
if (!N) {
assert(Strm->failed() && "Root is NULL iff parsing failed");
EC = make_error_code(errc::invalid_argument);
EC = make_error_code(std::errc::invalid_argument);
return false;
}

Expand Down Expand Up @@ -124,7 +124,7 @@ bool Input::preflightKey(const char *Key, bool Required, bool, bool &UseDefault,
// nodes are present.
if (!CurrentNode) {
if (Required)
EC = make_error_code(errc::invalid_argument);
EC = make_error_code(std::errc::invalid_argument);
return false;
}

Expand Down Expand Up @@ -300,7 +300,7 @@ void Input::setError(HNode *hnode, const Twine &message) {

void Input::setError(Node *node, const Twine &message) {
Strm->printError(node, message);
EC = make_error_code(errc::invalid_argument);
EC = make_error_code(std::errc::invalid_argument);
}

Input::HNode *Input::createHNodes(Node *N) {
Expand Down
121 changes: 0 additions & 121 deletions llvm/lib/Support/system_error.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion llvm/test/Object/directory.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;RUN: rm -f %T/test.a
;RUN: not llvm-ar r %T/test.a . 2>&1 | FileCheck %s
;CHECK: .: Is a directory
;CHECK: .: {{I|i}}s a directory

;RUN: rm -f %T/test.a
;RUN: touch %T/a-very-long-file-name
Expand Down
6 changes: 3 additions & 3 deletions llvm/tools/llvm-ar/llvm-ar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ int NewArchiveIterator::getFD() const {
// Linux cannot open directories with open(2), although
// cygwin and *bsd can.
if (NewStatus.type() == sys::fs::file_type::directory_file)
failIfError(make_error_code(errc::is_a_directory), NewFilename);
failIfError(make_error_code(std::errc::is_a_directory), NewFilename);

return NewFD;
}
Expand Down Expand Up @@ -939,7 +939,7 @@ static int performOperation(ArchiveOperation Operation) {
// Create or open the archive object.
std::unique_ptr<MemoryBuffer> Buf;
error_code EC = MemoryBuffer::getFile(ArchiveName, Buf, -1, false);
if (EC && EC != llvm::errc::no_such_file_or_directory) {
if (EC && EC != std::errc::no_such_file_or_directory) {
errs() << ToolName << ": error opening '" << ArchiveName
<< "': " << EC.message() << "!\n";
return 1;
Expand All @@ -957,7 +957,7 @@ static int performOperation(ArchiveOperation Operation) {
return 0;
}

assert(EC == llvm::errc::no_such_file_or_directory);
assert(EC == std::errc::no_such_file_or_directory);

if (!shouldCreateArchive(Operation)) {
failIfError(EC, Twine("error loading '") + ArchiveName + "'");
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-cov/llvm-cov.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ int main(int argc, char **argv) {

std::unique_ptr<MemoryBuffer> GCDA_Buff;
if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCDA, GCDA_Buff)) {
if (ec != errc::no_such_file_or_directory) {
if (ec != std::errc::no_such_file_or_directory) {
errs() << InputGCDA << ": " << ec.message() << "\n";
return 1;
}
Expand Down
1 change: 0 additions & 1 deletion llvm/tools/llvm-objdump/llvm-objdump.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ namespace object {
class ObjectFile;
class RelocationRef;
}
class error_code;

extern cl::opt<std::string> TripleName;
extern cl::opt<std::string> ArchName;
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-readobj/Error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ std::string _readobj_error_category::message(int EV) const {
error_condition _readobj_error_category::default_error_condition(int EV) const {
if (static_cast<readobj_error>(EV) == readobj_error::success)
return error_condition();
return errc::invalid_argument;
return std::errc::invalid_argument;
}

namespace llvm {
Expand Down
6 changes: 4 additions & 2 deletions llvm/tools/llvm-readobj/Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ inline error_code make_error_code(readobj_error e) {
return error_code(static_cast<int>(e), readobj_category());
}

template <> struct is_error_code_enum<readobj_error> : std::true_type { };

} // namespace llvm

namespace std {
template <> struct is_error_code_enum<llvm::readobj_error> : std::true_type {};
}

#endif
4 changes: 2 additions & 2 deletions llvm/tools/llvm-readobj/ObjDumper.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#ifndef LLVM_READOBJ_OBJDUMPER_H
#define LLVM_READOBJ_OBJDUMPER_H

#include "llvm/Support/system_error.h"

#include <memory>

namespace llvm {
Expand All @@ -18,8 +20,6 @@ namespace object {
class ObjectFile;
}

class error_code;

class StreamWriter;

class ObjDumper {
Expand Down
2 changes: 0 additions & 2 deletions llvm/tools/llvm-readobj/llvm-readobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ namespace llvm {
class RelocationRef;
}

class error_code;

// Various helper functions.
bool error(error_code ec);
bool relocAddressLess(object::RelocationRef A,
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-symbolizer/LLVMSymbolize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ LLVMSymbolizer::getOrCreateBinary(const std::string &Path) {
getDarwinDWARFResourceForPath(Path);
BinaryOrErr = createBinary(ResourcePath);
error_code EC = BinaryOrErr.getError();
if (EC != errc::no_such_file_or_directory && !error(EC)) {
if (EC != std::errc::no_such_file_or_directory && !error(EC)) {
DbgBin = BinaryOrErr.get();
ParsedBinariesAndObjects.push_back(std::unique_ptr<Binary>(DbgBin));
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/obj2yaml/Error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ error_condition
_obj2yaml_error_category::default_error_condition(int ev) const {
if (static_cast<obj2yaml_error>(ev) == obj2yaml_error::success)
return error_condition();
return errc::invalid_argument;
return std::errc::invalid_argument;
}

namespace llvm {
Expand Down
6 changes: 4 additions & 2 deletions llvm/tools/obj2yaml/Error.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ inline error_code make_error_code(obj2yaml_error e) {
return error_code(static_cast<int>(e), obj2yaml_category());
}

template <> struct is_error_code_enum<obj2yaml_error> : std::true_type { };

} // namespace llvm

namespace std {
template <> struct is_error_code_enum<llvm::obj2yaml_error> : std::true_type {};
}

#endif
4 changes: 2 additions & 2 deletions llvm/unittests/Support/ErrorOrTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ using namespace llvm;
namespace {

ErrorOr<int> t1() {return 1;}
ErrorOr<int> t2() { return errc::invalid_argument; }
ErrorOr<int> t2() { return std::errc::invalid_argument; }

TEST(ErrorOr, SimpleValue) {
ErrorOr<int> a = t1();
Expand All @@ -30,7 +30,7 @@ TEST(ErrorOr, SimpleValue) {

a = t2();
EXPECT_FALSE(a);
EXPECT_EQ(errc::invalid_argument, a.getError());
EXPECT_EQ(std::errc::invalid_argument, a.getError());
#ifdef EXPECT_DEBUG_DEATH
EXPECT_DEBUG_DEATH(*a, "Cannot get value when an error exists");
#endif
Expand Down
8 changes: 4 additions & 4 deletions llvm/unittests/Support/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,10 @@ TEST_F(FileSystemTest, TempFiles) {
ASSERT_NO_ERROR(fs::remove(Twine(TempPath2)));
ASSERT_NO_ERROR(fs::remove(Twine(TempPath2)));
ASSERT_EQ(fs::remove(Twine(TempPath2), false),
errc::no_such_file_or_directory);
std::errc::no_such_file_or_directory);

error_code EC = fs::status(TempPath2.c_str(), B);
EXPECT_EQ(EC, errc::no_such_file_or_directory);
EXPECT_EQ(EC, std::errc::no_such_file_or_directory);
EXPECT_EQ(B.type(), fs::file_type::file_not_found);

// Make sure Temp2 doesn't exist.
Expand Down Expand Up @@ -397,15 +397,15 @@ TEST_F(FileSystemTest, TempFiles) {
"abcdefghijklmnopqrstuvwxyz3abcdefghijklmnopqrstuvwxyz2"
"abcdefghijklmnopqrstuvwxyz1abcdefghijklmnopqrstuvwxyz0";
EXPECT_EQ(fs::createUniqueFile(Twine(Path270), FileDescriptor, TempPath),
error_code(ERROR_PATH_NOT_FOUND, system_category()));
std::errc::no_such_file_or_directory);
#endif
}

TEST_F(FileSystemTest, CreateDir) {
ASSERT_NO_ERROR(fs::create_directory(Twine(TestDirectory) + "foo"));
ASSERT_NO_ERROR(fs::create_directory(Twine(TestDirectory) + "foo"));
ASSERT_EQ(fs::create_directory(Twine(TestDirectory) + "foo", false),
errc::file_exists);
std::errc::file_exists);
ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "foo"));
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Transforms/DebugIR/DebugIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ bool removeIfExists(StringRef Path) {
// This is an approximation, on error we don't know in general if the file
// existed or not.
llvm::error_code EC = sys::fs::remove(Path, false);
return EC != llvm::errc::no_such_file_or_directory;
return EC != std::errc::no_such_file_or_directory;
}

char * current_dir() {
Expand Down
7 changes: 3 additions & 4 deletions llvm/utils/KillTheDoctor/KillTheDoctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/system_error.h"
#include "llvm/Support/type_traits.h"
#include "llvm/Support/WindowsError.h"
#include <algorithm>
#include <cerrno>
#include <cstdlib>
Expand Down Expand Up @@ -169,9 +170,7 @@ namespace {
typedef ScopedHandle<FileHandle> FileScopedHandle;
}

static error_code windows_error(unsigned E) {
return error_code(E, system_category());
}
static error_code windows_error(DWORD E) { return mapWindowsError(E); }

static error_code GetFileNameFromHandle(HANDLE FileHandle,
std::string& Name) {
Expand Down Expand Up @@ -426,7 +425,7 @@ int main(int argc, char **argv) {
if (!success) {
ec = windows_error(::GetLastError());

if (ec == errc::timed_out) {
if (ec == std::errc::timed_out) {
errs() << ToolName << ": Process timed out.\n";
::TerminateProcess(ProcessInfo.hProcess, -1);
// Otherwise other stuff starts failing...
Expand Down