[llvm] r210687 - Use std::error_code instead of llvm::error_code.
Rafael Espindola
rafael.espindola at gmail.com
Wed Jun 11 12:05:51 PDT 2014
Author: rafael
Date: Wed Jun 11 14:05:50 2014
New Revision: 210687
URL: http://llvm.org/viewvc/llvm-project?rev=210687&view=rev
Log:
Use std::error_code instead of llvm::error_code.
The idea of this patch is to turn llvm/Support/system_error.h into a
transitional header that just brings in the erorr_code api to the llvm
namespace. I will remove it shortly afterwards.
The cases where the general idea needed some tweaking:
* std::errc is a namespace in msvc, so we cannot use "using std::errc". I could
add an #ifdef, but there were not that many uses, so I just added std:: to
them in this patch.
* Template specialization had to be moved to the std namespace in this
patch set already.
* The msvc implementation of default_error_condition doesn't seem to
provide the same transformations as we need. Not too surprising since
the standard doesn't actually say what "equivalent" means. I fixed the
problem by keeping our old mapping and using it at error_code
construction time.
Despite these shortcomings I think this is still a good thing. Some reasons:
* The different implementations of system_error might improve over time.
* It removes 925 lines of code from llvm already.
* It removes 6313 bytes from the text segment of the clang binary when
it is built with gcc and 2816 bytes when building with clang and
libstdc++.
Added:
llvm/trunk/include/llvm/Support/WindowsError.h
llvm/trunk/lib/Support/WindowsError.cpp
Removed:
llvm/trunk/lib/Support/Unix/system_error.inc
llvm/trunk/lib/Support/Windows/system_error.inc
llvm/trunk/lib/Support/system_error.cpp
Modified:
llvm/trunk/include/llvm/Object/Error.h
llvm/trunk/include/llvm/ProfileData/InstrProf.h
llvm/trunk/include/llvm/Support/FileOutputBuffer.h
llvm/trunk/include/llvm/Support/MemoryBuffer.h
llvm/trunk/include/llvm/Support/Program.h
llvm/trunk/include/llvm/Support/system_error.h
llvm/trunk/lib/Object/Error.cpp
llvm/trunk/lib/ProfileData/InstrProf.cpp
llvm/trunk/lib/Support/CMakeLists.txt
llvm/trunk/lib/Support/FileOutputBuffer.cpp
llvm/trunk/lib/Support/LockFileManager.cpp
llvm/trunk/lib/Support/MemoryBuffer.cpp
llvm/trunk/lib/Support/Path.cpp
llvm/trunk/lib/Support/Unix/Path.inc
llvm/trunk/lib/Support/Windows/Path.inc
llvm/trunk/lib/Support/Windows/Process.inc
llvm/trunk/lib/Support/YAMLTraits.cpp
llvm/trunk/test/Object/directory.ll
llvm/trunk/tools/llvm-ar/llvm-ar.cpp
llvm/trunk/tools/llvm-cov/llvm-cov.cpp
llvm/trunk/tools/llvm-objdump/llvm-objdump.h
llvm/trunk/tools/llvm-readobj/Error.cpp
llvm/trunk/tools/llvm-readobj/Error.h
llvm/trunk/tools/llvm-readobj/ObjDumper.h
llvm/trunk/tools/llvm-readobj/llvm-readobj.h
llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
llvm/trunk/tools/obj2yaml/Error.cpp
llvm/trunk/tools/obj2yaml/Error.h
llvm/trunk/unittests/Support/ErrorOrTest.cpp
llvm/trunk/unittests/Support/Path.cpp
llvm/trunk/unittests/Transforms/DebugIR/DebugIR.cpp
llvm/trunk/utils/KillTheDoctor/KillTheDoctor.cpp
Modified: llvm/trunk/include/llvm/Object/Error.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Error.h?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/Error.h (original)
+++ llvm/trunk/include/llvm/Object/Error.h Wed Jun 11 14:05:50 2014
@@ -35,8 +35,11 @@ inline error_code make_error_code(object
} // end namespace object.
-template <> struct is_error_code_enum<object::object_error> : std::true_type {};
-
} // end namespace llvm.
+namespace std {
+template <>
+struct is_error_code_enum<llvm::object::object_error> : std::true_type {};
+}
+
#endif
Modified: llvm/trunk/include/llvm/ProfileData/InstrProf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProf.h?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/InstrProf.h (original)
+++ llvm/trunk/include/llvm/ProfileData/InstrProf.h Wed Jun 11 14:05:50 2014
@@ -42,8 +42,11 @@ inline error_code make_error_code(instrp
return error_code(static_cast<int>(E), instrprof_category());
}
-template <> struct is_error_code_enum<instrprof_error> : std::true_type {};
-
} // end namespace llvm
+namespace std {
+template <>
+struct is_error_code_enum<llvm::instrprof_error> : std::true_type {};
+}
+
#endif // LLVM_PROFILEDATA_INSTRPROF_H_
Modified: llvm/trunk/include/llvm/Support/FileOutputBuffer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/FileOutputBuffer.h?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/FileOutputBuffer.h (original)
+++ llvm/trunk/include/llvm/Support/FileOutputBuffer.h Wed Jun 11 14:05:50 2014
@@ -20,8 +20,6 @@
#include "llvm/Support/FileSystem.h"
namespace llvm {
-class error_code;
-
/// FileOutputBuffer - This interface provides simple way to create an in-memory
/// buffer which will be written to a file. During the lifetime of these
/// objects, the content or existence of the specified file is undefined. That
Modified: llvm/trunk/include/llvm/Support/MemoryBuffer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MemoryBuffer.h?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/MemoryBuffer.h (original)
+++ llvm/trunk/include/llvm/Support/MemoryBuffer.h Wed Jun 11 14:05:50 2014
@@ -19,12 +19,10 @@
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/DataTypes.h"
+#include "llvm/Support/system_error.h"
#include <memory>
namespace llvm {
-
-class error_code;
-
/// MemoryBuffer - This interface provides simple read-only access to a block
/// of memory, and provides simple methods for reading files and standard input
/// into a memory buffer. In addition to basic access to the characters in the
Modified: llvm/trunk/include/llvm/Support/Program.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Program.h?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/Program.h (original)
+++ llvm/trunk/include/llvm/Support/Program.h Wed Jun 11 14:05:50 2014
@@ -19,7 +19,6 @@
#include "llvm/Support/system_error.h"
namespace llvm {
-class error_code;
namespace sys {
/// This is the OS-specific separator for PATH like environment variables:
Added: llvm/trunk/include/llvm/Support/WindowsError.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/WindowsError.h?rev=210687&view=auto
==============================================================================
--- llvm/trunk/include/llvm/Support/WindowsError.h (added)
+++ llvm/trunk/include/llvm/Support/WindowsError.h Wed Jun 11 14:05:50 2014
@@ -0,0 +1,21 @@
+//===-- WindowsError.h - 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.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_WINDOWS_ERROR_H
+#define LLVM_SUPPORT_WINDOWS_ERROR_H
+
+#ifdef _MSC_VER
+#include <system_error>
+
+namespace llvm {
+std::error_code mapWindowsError(unsigned EV);
+}
+#endif
+
+#endif
Modified: llvm/trunk/include/llvm/Support/system_error.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/system_error.h?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/system_error.h (original)
+++ llvm/trunk/include/llvm/Support/system_error.h Wed Jun 11 14:05:50 2014
@@ -7,790 +7,24 @@
//
//===----------------------------------------------------------------------===//
//
-// This was lifted from libc++ and modified for C++03. This is called
-// system_error even though it does not define that class because that's what
-// it's called in C++0x. We don't define system_error because it is only used
-// for exception handling, which we don't use in LLVM.
+// This is a temporary file to help with the transition to std::error_code.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_SYSTEM_ERROR_H
#define LLVM_SUPPORT_SYSTEM_ERROR_H
-#include "llvm/Support/Compiler.h"
-
-/*
- system_error synopsis
-
-namespace std
-{
-
-class error_category
-{
-public:
- virtual ~error_category();
-
- error_category(const error_category&) = delete;
- error_category& operator=(const error_category&) = delete;
-
- virtual const char* name() const = 0;
- virtual error_condition default_error_condition(int ev) const;
- virtual bool equivalent(int code, const error_condition& condition) const;
- virtual bool equivalent(const error_code& code, int condition) const;
- virtual std::string message(int ev) const = 0;
-
- bool operator==(const error_category& rhs) const;
- bool operator!=(const error_category& rhs) const;
- bool operator<(const error_category& rhs) const;
-};
-
-const error_category& generic_category();
-const error_category& system_category();
-
-template <class T> struct is_error_code_enum
- : public std::false_type {};
-
-template <class T> struct is_error_condition_enum
- : public std::false_type {};
-
-class error_code
-{
-public:
- // constructors:
- error_code();
- error_code(int val, const error_category& cat);
- template <class ErrorCodeEnum>
- error_code(ErrorCodeEnum e);
-
- // modifiers:
- void assign(int val, const error_category& cat);
- template <class ErrorCodeEnum>
- error_code& operator=(ErrorCodeEnum e);
- void clear();
-
- // observers:
- int value() const;
- const error_category& category() const;
- error_condition default_error_condition() const;
- std::string message() const;
- explicit operator bool() const;
-};
-
-// non-member functions:
-bool operator<(const error_code& lhs, const error_code& rhs);
-template <class charT, class traits>
- basic_ostream<charT,traits>&
- operator<<(basic_ostream<charT,traits>& os, const error_code& ec);
-
-class error_condition
-{
-public:
- // constructors:
- error_condition();
- error_condition(int val, const error_category& cat);
- template <class ErrorConditionEnum>
- error_condition(ErrorConditionEnum e);
-
- // modifiers:
- void assign(int val, const error_category& cat);
- template <class ErrorConditionEnum>
- error_condition& operator=(ErrorConditionEnum e);
- void clear();
-
- // observers:
- int value() const;
- const error_category& category() const;
- std::string message() const;
- explicit operator bool() const;
-};
-
-bool operator<(const error_condition& lhs, const error_condition& rhs);
-
-class system_error
- : public runtime_error
-{
-public:
- system_error(error_code ec, const std::string& what_arg);
- system_error(error_code ec, const char* what_arg);
- system_error(error_code ec);
- system_error(int ev, const error_category& ecat, const std::string& what_arg);
- system_error(int ev, const error_category& ecat, const char* what_arg);
- system_error(int ev, const error_category& ecat);
-
- const error_code& code() const throw();
- const char* what() const throw();
-};
-
-enum class errc
-{
- address_family_not_supported, // EAFNOSUPPORT
- address_in_use, // EADDRINUSE
- address_not_available, // EADDRNOTAVAIL
- already_connected, // EISCONN
- argument_list_too_long, // E2BIG
- argument_out_of_domain, // EDOM
- bad_address, // EFAULT
- bad_file_descriptor, // EBADF
- bad_message, // EBADMSG
- broken_pipe, // EPIPE
- connection_aborted, // ECONNABORTED
- connection_already_in_progress, // EALREADY
- connection_refused, // ECONNREFUSED
- connection_reset, // ECONNRESET
- cross_device_link, // EXDEV
- destination_address_required, // EDESTADDRREQ
- device_or_resource_busy, // EBUSY
- directory_not_empty, // ENOTEMPTY
- executable_format_error, // ENOEXEC
- file_exists, // EEXIST
- file_too_large, // EFBIG
- filename_too_long, // ENAMETOOLONG
- function_not_supported, // ENOSYS
- host_unreachable, // EHOSTUNREACH
- identifier_removed, // EIDRM
- illegal_byte_sequence, // EILSEQ
- inappropriate_io_control_operation, // ENOTTY
- interrupted, // EINTR
- invalid_argument, // EINVAL
- invalid_seek, // ESPIPE
- io_error, // EIO
- is_a_directory, // EISDIR
- message_size, // EMSGSIZE
- network_down, // ENETDOWN
- network_reset, // ENETRESET
- network_unreachable, // ENETUNREACH
- no_buffer_space, // ENOBUFS
- no_child_process, // ECHILD
- no_link, // ENOLINK
- no_lock_available, // ENOLCK
- no_message_available, // ENODATA
- no_message, // ENOMSG
- no_protocol_option, // ENOPROTOOPT
- no_space_on_device, // ENOSPC
- no_stream_resources, // ENOSR
- no_such_device_or_address, // ENXIO
- no_such_device, // ENODEV
- no_such_file_or_directory, // ENOENT
- no_such_process, // ESRCH
- not_a_directory, // ENOTDIR
- not_a_socket, // ENOTSOCK
- not_a_stream, // ENOSTR
- not_connected, // ENOTCONN
- not_enough_memory, // ENOMEM
- not_supported, // ENOTSUP
- operation_canceled, // ECANCELED
- operation_in_progress, // EINPROGRESS
- operation_not_permitted, // EPERM
- operation_not_supported, // EOPNOTSUPP
- operation_would_block, // EWOULDBLOCK
- owner_dead, // EOWNERDEAD
- permission_denied, // EACCES
- protocol_error, // EPROTO
- protocol_not_supported, // EPROTONOSUPPORT
- read_only_file_system, // EROFS
- resource_deadlock_would_occur, // EDEADLK
- resource_unavailable_try_again, // EAGAIN
- result_out_of_range, // ERANGE
- state_not_recoverable, // ENOTRECOVERABLE
- stream_timeout, // ETIME
- text_file_busy, // ETXTBSY
- timed_out, // ETIMEDOUT
- too_many_files_open_in_system, // ENFILE
- too_many_files_open, // EMFILE
- too_many_links, // EMLINK
- too_many_symbolic_link_levels, // ELOOP
- value_too_large, // EOVERFLOW
- wrong_protocol_type // EPROTOTYPE
-};
-
-template <> struct is_error_condition_enum<errc> : std::true_type { }
-
-error_code make_error_code(errc e);
-error_condition make_error_condition(errc e);
-
-// Comparison operators:
-bool operator==(const error_code& lhs, const error_code& rhs);
-bool operator==(const error_code& lhs, const error_condition& rhs);
-bool operator==(const error_condition& lhs, const error_code& rhs);
-bool operator==(const error_condition& lhs, const error_condition& rhs);
-bool operator!=(const error_code& lhs, const error_code& rhs);
-bool operator!=(const error_code& lhs, const error_condition& rhs);
-bool operator!=(const error_condition& lhs, const error_code& rhs);
-bool operator!=(const error_condition& lhs, const error_condition& rhs);
-
-template <> struct hash<std::error_code>;
-
-} // std
-
-*/
-
-#include "llvm/Config/llvm-config.h"
-#include <cerrno>
-#include <string>
-
-// This must be here instead of a .inc file because it is used in the definition
-// of the enum values below.
-#ifdef LLVM_ON_WIN32
-
- // The following numbers were taken from VS2010.
-# ifndef EAFNOSUPPORT
-# define EAFNOSUPPORT 102
-# endif
-# ifndef EADDRINUSE
-# define EADDRINUSE 100
-# endif
-# ifndef EADDRNOTAVAIL
-# define EADDRNOTAVAIL 101
-# endif
-# ifndef EISCONN
-# define EISCONN 113
-# endif
-# ifndef E2BIG
-# define E2BIG 7
-# endif
-# ifndef EDOM
-# define EDOM 33
-# endif
-# ifndef EFAULT
-# define EFAULT 14
-# endif
-# ifndef EBADF
-# define EBADF 9
-# endif
-# ifndef EBADMSG
-# define EBADMSG 104
-# endif
-# ifndef EPIPE
-# define EPIPE 32
-# endif
-# ifndef ECONNABORTED
-# define ECONNABORTED 106
-# endif
-# ifndef EALREADY
-# define EALREADY 103
-# endif
-# ifndef ECONNREFUSED
-# define ECONNREFUSED 107
-# endif
-# ifndef ECONNRESET
-# define ECONNRESET 108
-# endif
-# ifndef EXDEV
-# define EXDEV 18
-# endif
-# ifndef EDESTADDRREQ
-# define EDESTADDRREQ 109
-# endif
-# ifndef EBUSY
-# define EBUSY 16
-# endif
-# ifndef ENOTEMPTY
-# define ENOTEMPTY 41
-# endif
-# ifndef ENOEXEC
-# define ENOEXEC 8
-# endif
-# ifndef EEXIST
-# define EEXIST 17
-# endif
-# ifndef EFBIG
-# define EFBIG 27
-# endif
-# ifndef ENAMETOOLONG
-# define ENAMETOOLONG 38
-# endif
-# ifndef ENOSYS
-# define ENOSYS 40
-# endif
-# ifndef EHOSTUNREACH
-# define EHOSTUNREACH 110
-# endif
-# ifndef EIDRM
-# define EIDRM 111
-# endif
-# ifndef EILSEQ
-# define EILSEQ 42
-# endif
-# ifndef ENOTTY
-# define ENOTTY 25
-# endif
-# ifndef EINTR
-# define EINTR 4
-# endif
-# ifndef EINVAL
-# define EINVAL 22
-# endif
-# ifndef ESPIPE
-# define ESPIPE 29
-# endif
-# ifndef EIO
-# define EIO 5
-# endif
-# ifndef EISDIR
-# define EISDIR 21
-# endif
-# ifndef EMSGSIZE
-# define EMSGSIZE 115
-# endif
-# ifndef ENETDOWN
-# define ENETDOWN 116
-# endif
-# ifndef ENETRESET
-# define ENETRESET 117
-# endif
-# ifndef ENETUNREACH
-# define ENETUNREACH 118
-# endif
-# ifndef ENOBUFS
-# define ENOBUFS 119
-# endif
-# ifndef ECHILD
-# define ECHILD 10
-# endif
-# ifndef ENOLINK
-# define ENOLINK 121
-# endif
-# ifndef ENOLCK
-# define ENOLCK 39
-# endif
-# ifndef ENODATA
-# define ENODATA 120
-# endif
-# ifndef ENOMSG
-# define ENOMSG 122
-# endif
-# ifndef ENOPROTOOPT
-# define ENOPROTOOPT 123
-# endif
-# ifndef ENOSPC
-# define ENOSPC 28
-# endif
-# ifndef ENOSR
-# define ENOSR 124
-# endif
-# ifndef ENXIO
-# define ENXIO 6
-# endif
-# ifndef ENODEV
-# define ENODEV 19
-# endif
-# ifndef ENOENT
-# define ENOENT 2
-# endif
-# ifndef ESRCH
-# define ESRCH 3
-# endif
-# ifndef ENOTDIR
-# define ENOTDIR 20
-# endif
-# ifndef ENOTSOCK
-# define ENOTSOCK 128
-# endif
-# ifndef ENOSTR
-# define ENOSTR 125
-# endif
-# ifndef ENOTCONN
-# define ENOTCONN 126
-# endif
-# ifndef ENOMEM
-# define ENOMEM 12
-# endif
-# ifndef ENOTSUP
-# define ENOTSUP 129
-# endif
-# ifndef ECANCELED
-# define ECANCELED 105
-# endif
-# ifndef EINPROGRESS
-# define EINPROGRESS 112
-# endif
-# ifndef EPERM
-# define EPERM 1
-# endif
-# ifndef EOPNOTSUPP
-# define EOPNOTSUPP 130
-# endif
-# ifndef EWOULDBLOCK
-# define EWOULDBLOCK 140
-# endif
-# ifndef EOWNERDEAD
-# define EOWNERDEAD 133
-# endif
-# ifndef EACCES
-# define EACCES 13
-# endif
-# ifndef EPROTO
-# define EPROTO 134
-# endif
-# ifndef EPROTONOSUPPORT
-# define EPROTONOSUPPORT 135
-# endif
-# ifndef EROFS
-# define EROFS 30
-# endif
-# ifndef EDEADLK
-# define EDEADLK 36
-# endif
-# ifndef EAGAIN
-# define EAGAIN 11
-# endif
-# ifndef ERANGE
-# define ERANGE 34
-# endif
-# ifndef ENOTRECOVERABLE
-# define ENOTRECOVERABLE 127
-# endif
-# ifndef ETIME
-# define ETIME 137
-# endif
-# ifndef ETXTBSY
-# define ETXTBSY 139
-# endif
-# ifndef ETIMEDOUT
-# define ETIMEDOUT 138
-# endif
-# ifndef ENFILE
-# define ENFILE 23
-# endif
-# ifndef EMFILE
-# define EMFILE 24
-# endif
-# ifndef EMLINK
-# define EMLINK 31
-# endif
-# ifndef ELOOP
-# define ELOOP 114
-# endif
-# ifndef EOVERFLOW
-# define EOVERFLOW 132
-# endif
-# ifndef EPROTOTYPE
-# define EPROTOTYPE 136
-# endif
-#endif
+#include <system_error>
namespace llvm {
-
-// is_error_code_enum
-
-template <class Tp> struct is_error_code_enum : public std::false_type {};
-
-// is_error_condition_enum
-
-template <class Tp> struct is_error_condition_enum : public std::false_type {};
-
-// Some error codes are not present on all platforms, so we provide equivalents
-// for them:
-
-enum class errc {
- address_family_not_supported = EAFNOSUPPORT,
- address_in_use = EADDRINUSE,
- address_not_available = EADDRNOTAVAIL,
- already_connected = EISCONN,
- argument_list_too_long = E2BIG,
- argument_out_of_domain = EDOM,
- bad_address = EFAULT,
- bad_file_descriptor = EBADF,
-#ifdef EBADMSG
- bad_message = EBADMSG,
-#else
- bad_message = EINVAL,
-#endif
- broken_pipe = EPIPE,
- connection_aborted = ECONNABORTED,
- connection_already_in_progress = EALREADY,
- connection_refused = ECONNREFUSED,
- connection_reset = ECONNRESET,
- cross_device_link = EXDEV,
- destination_address_required = EDESTADDRREQ,
- device_or_resource_busy = EBUSY,
- directory_not_empty = ENOTEMPTY,
- executable_format_error = ENOEXEC,
- file_exists = EEXIST,
- file_too_large = EFBIG,
- filename_too_long = ENAMETOOLONG,
- function_not_supported = ENOSYS,
- host_unreachable = EHOSTUNREACH,
- identifier_removed = EIDRM,
- illegal_byte_sequence = EILSEQ,
- inappropriate_io_control_operation = ENOTTY,
- interrupted = EINTR,
- invalid_argument = EINVAL,
- invalid_seek = ESPIPE,
- io_error = EIO,
- is_a_directory = EISDIR,
- message_size = EMSGSIZE,
- network_down = ENETDOWN,
- network_reset = ENETRESET,
- network_unreachable = ENETUNREACH,
- no_buffer_space = ENOBUFS,
- no_child_process = ECHILD,
-#ifdef ENOLINK
- no_link = ENOLINK,
-#else
- no_link = EINVAL,
-#endif
- no_lock_available = ENOLCK,
-#ifdef ENODATA
- no_message_available = ENODATA,
-#else
- no_message_available = ENOMSG,
-#endif
- no_message = ENOMSG,
- no_protocol_option = ENOPROTOOPT,
- no_space_on_device = ENOSPC,
-#ifdef ENOSR
- no_stream_resources = ENOSR,
-#else
- no_stream_resources = ENOMEM,
-#endif
- no_such_device_or_address = ENXIO,
- no_such_device = ENODEV,
- no_such_file_or_directory = ENOENT,
- no_such_process = ESRCH,
- not_a_directory = ENOTDIR,
- not_a_socket = ENOTSOCK,
-#ifdef ENOSTR
- not_a_stream = ENOSTR,
-#else
- not_a_stream = EINVAL,
-#endif
- not_connected = ENOTCONN,
- not_enough_memory = ENOMEM,
- not_supported = ENOTSUP,
-#ifdef ECANCELED
- operation_canceled = ECANCELED,
-#else
- operation_canceled = EINVAL,
-#endif
- operation_in_progress = EINPROGRESS,
- operation_not_permitted = EPERM,
- operation_not_supported = EOPNOTSUPP,
- operation_would_block = EWOULDBLOCK,
-#ifdef EOWNERDEAD
- owner_dead = EOWNERDEAD,
-#else
- owner_dead = EINVAL,
-#endif
- permission_denied = EACCES,
-#ifdef EPROTO
- protocol_error = EPROTO,
-#else
- protocol_error = EINVAL,
-#endif
- protocol_not_supported = EPROTONOSUPPORT,
- read_only_file_system = EROFS,
- resource_deadlock_would_occur = EDEADLK,
- resource_unavailable_try_again = EAGAIN,
- result_out_of_range = ERANGE,
-#ifdef ENOTRECOVERABLE
- state_not_recoverable = ENOTRECOVERABLE,
-#else
- state_not_recoverable = EINVAL,
-#endif
-#ifdef ETIME
- stream_timeout = ETIME,
-#else
- stream_timeout = ETIMEDOUT,
-#endif
- text_file_busy = ETXTBSY,
- timed_out = ETIMEDOUT,
- too_many_files_open_in_system = ENFILE,
- too_many_files_open = EMFILE,
- too_many_links = EMLINK,
- too_many_symbolic_link_levels = ELOOP,
- value_too_large = EOVERFLOW,
- wrong_protocol_type = EPROTOTYPE
-};
-
-
-template <> struct is_error_condition_enum<errc> : std::true_type { };
-
-class error_condition;
-class error_code;
-
-// class error_category
-
-class _do_message;
-
-class error_category
-{
-public:
- virtual ~error_category();
-
- error_category();
-private:
- error_category(const error_category&) LLVM_DELETED_FUNCTION;
- error_category& operator=(const error_category&) LLVM_DELETED_FUNCTION;
-
-public:
- virtual const char* name() const LLVM_NOEXCEPT = 0;
- virtual error_condition default_error_condition(int _ev) const LLVM_NOEXCEPT;
- virtual bool
- equivalent(int _code, const error_condition &_condition) const LLVM_NOEXCEPT;
- virtual bool equivalent(const error_code &_code,
- int _condition) const LLVM_NOEXCEPT;
- virtual std::string message(int _ev) const = 0;
-
- bool operator==(const error_category& _rhs) const {return this == &_rhs;}
-
- bool operator!=(const error_category& _rhs) const {return !(*this == _rhs);}
-
- bool operator< (const error_category& _rhs) const {return this < &_rhs;}
-
- friend class _do_message;
-};
-
-class _do_message : public error_category
-{
-public:
- std::string message(int ev) const override;
-};
-
-const error_category& generic_category();
-const error_category& system_category();
-
-class error_condition
-{
- int _val_;
- const error_category* _cat_;
-public:
- error_condition() : _val_(0), _cat_(&generic_category()) {}
-
- error_condition(int _val, const error_category& _cat)
- : _val_(_val), _cat_(&_cat) {}
-
- template <class E>
- error_condition(E _e, typename std::enable_if<
- is_error_condition_enum<E>::value
- >::type* = 0)
- {*this = make_error_condition(_e);}
-
- void assign(int _val, const error_category& _cat) {
- _val_ = _val;
- _cat_ = &_cat;
- }
-
- template <class E>
- typename std::enable_if<is_error_condition_enum<E>::value,
- error_condition &>::type
- operator=(E _e) {
- *this = make_error_condition(_e);
- return *this;
- }
-
- void clear() {
- _val_ = 0;
- _cat_ = &generic_category();
- }
-
- int value() const {return _val_;}
-
- const error_category& category() const {return *_cat_;}
- std::string message() const;
-
- LLVM_EXPLICIT operator bool() const { return _val_ != 0; }
-};
-
-inline error_condition make_error_condition(errc _e) {
- return error_condition(static_cast<int>(_e), generic_category());
-}
-
-inline bool operator<(const error_condition& _x, const error_condition& _y) {
- return _x.category() < _y.category()
- || (_x.category() == _y.category() && _x.value() < _y.value());
-}
-
-// error_code
-
-class error_code {
- int _val_;
- const error_category* _cat_;
-public:
- error_code() : _val_(0), _cat_(&system_category()) {}
-
- error_code(int _val, const error_category& _cat)
- : _val_(_val), _cat_(&_cat) {}
-
- template <class E>
- error_code(E _e, typename std::enable_if<
- is_error_code_enum<E>::value
- >::type* = 0) {
- *this = make_error_code(_e);
- }
-
- void assign(int _val, const error_category& _cat) {
- _val_ = _val;
- _cat_ = &_cat;
- }
-
- template <class E>
- typename std::enable_if<is_error_code_enum<E>::value, error_code &>::type
- operator=(E _e) {
- *this = make_error_code(_e);
- return *this;
- }
-
- void clear() {
- _val_ = 0;
- _cat_ = &system_category();
- }
-
- int value() const {return _val_;}
-
- const error_category& category() const {return *_cat_;}
-
- error_condition default_error_condition() const
- {return _cat_->default_error_condition(_val_);}
-
- std::string message() const;
-
- LLVM_EXPLICIT operator bool() const {
- return _val_ != 0;
- }
-};
-
-inline error_code make_error_code(errc _e) {
- return error_code(static_cast<int>(_e), generic_category());
-}
-
-inline bool operator<(const error_code& _x, const error_code& _y) {
- return _x.category() < _y.category()
- || (_x.category() == _y.category() && _x.value() < _y.value());
-}
-
-inline bool operator==(const error_code& _x, const error_code& _y) {
- return _x.category() == _y.category() && _x.value() == _y.value();
-}
-
-inline bool operator==(const error_code& _x, const error_condition& _y) {
- return _x.category().equivalent(_x.value(), _y)
- || _y.category().equivalent(_x, _y.value());
-}
-
-inline bool operator==(const error_condition& _x, const error_code& _y) {
- return _y == _x;
-}
-
-inline bool operator==(const error_condition& _x, const error_condition& _y) {
- return _x.category() == _y.category() && _x.value() == _y.value();
-}
-
-inline bool operator!=(const error_code& _x, const error_code& _y) {
- return !(_x == _y);
-}
-
-inline bool operator!=(const error_code& _x, const error_condition& _y) {
- return !(_x == _y);
-}
-
-inline bool operator!=(const error_condition& _x, const error_code& _y) {
- return !(_x == _y);
-}
-
-inline bool operator!=(const error_condition& _x, const error_condition& _y) {
- return !(_x == _y);
+using std::error_code;
+using std::is_error_condition_enum;
+using std::is_error_code_enum;
+using std::system_category;
+using std::generic_category;
+using std::error_category;
+using std::make_error_code;
+using std::error_condition;
}
-} // end namespace llvm
#endif
Modified: llvm/trunk/lib/Object/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Error.cpp?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Error.cpp (original)
+++ llvm/trunk/lib/Object/Error.cpp Wed Jun 11 14:05:50 2014
@@ -50,7 +50,7 @@ std::string _object_error_category::mess
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() {
Modified: llvm/trunk/lib/ProfileData/InstrProf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProf.cpp?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProf.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProf.cpp Wed Jun 11 14:05:50 2014
@@ -55,7 +55,7 @@ class InstrProfErrorCategoryType : publi
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;
}
};
}
Modified: llvm/trunk/lib/Support/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CMakeLists.txt?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CMakeLists.txt (original)
+++ llvm/trunk/lib/Support/CMakeLists.txt Wed Jun 11 14:05:50 2014
@@ -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
@@ -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
@@ -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
Modified: llvm/trunk/lib/Support/FileOutputBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FileOutputBuffer.cpp?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/lib/Support/FileOutputBuffer.cpp (original)
+++ llvm/trunk/lib/Support/FileOutputBuffer.cpp Wed Jun 11 14:05:50 2014
@@ -51,7 +51,7 @@ error_code FileOutputBuffer::create(Stri
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.
Modified: llvm/trunk/lib/Support/LockFileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/LockFileManager.cpp?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/lib/Support/LockFileManager.cpp (original)
+++ llvm/trunk/lib/Support/LockFileManager.cpp Wed Jun 11 14:05:50 2014
@@ -114,7 +114,7 @@ LockFileManager::LockFileManager(StringR
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;
}
@@ -127,7 +127,7 @@ LockFileManager::LockFileManager(StringR
if (!EC)
return;
- if (EC != errc::file_exists) {
+ if (EC != std::errc::file_exists) {
Error = EC;
return;
}
Modified: llvm/trunk/lib/Support/MemoryBuffer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/MemoryBuffer.cpp?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)
+++ llvm/trunk/lib/Support/MemoryBuffer.cpp Wed Jun 11 14:05:50 2014
@@ -361,7 +361,7 @@ static error_code getOpenFileImpl(int FD
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);
Modified: llvm/trunk/lib/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Path.cpp?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Path.cpp (original)
+++ llvm/trunk/lib/Support/Path.cpp Wed Jun 11 14:05:50 2014
@@ -204,7 +204,7 @@ retry_random_path:
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;
}
@@ -224,7 +224,7 @@ retry_random_path:
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;
}
@@ -829,7 +829,7 @@ error_code create_directories(const Twin
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
@@ -896,7 +896,7 @@ error_code has_magic(const Twine &path,
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();
@@ -1043,7 +1043,7 @@ error_code has_magic(const Twine &path,
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);
Modified: llvm/trunk/lib/Support/Unix/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/Path.inc?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Unix/Path.inc (original)
+++ llvm/trunk/lib/Support/Unix/Path.inc Wed Jun 11 14:05:50 2014
@@ -317,7 +317,7 @@ error_code remove(const Twine &path, boo
// 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)
@@ -402,7 +402,7 @@ static error_code fillStatus(int StatRet
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);
@@ -466,7 +466,7 @@ error_code setLastModificationAndAccessT
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
}
@@ -510,7 +510,7 @@ mapped_file_region::mapped_file_region(c
, 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;
}
@@ -539,7 +539,7 @@ mapped_file_region::mapped_file_region(i
, 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;
}
@@ -645,7 +645,7 @@ error_code get_magic(const Twine &path,
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);
Removed: llvm/trunk/lib/Support/Unix/system_error.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Unix/system_error.inc?rev=210686&view=auto
==============================================================================
--- llvm/trunk/lib/Support/Unix/system_error.inc (original)
+++ llvm/trunk/lib/Support/Unix/system_error.inc (removed)
@@ -1,34 +0,0 @@
-//===- llvm/Support/Unix/system_error.inc - Unix error_code ------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file provides the Unix specific implementation of the error_code
-// and error_condition classes.
-//
-//===----------------------------------------------------------------------===//
-
-//===----------------------------------------------------------------------===//
-//=== WARNING: Implementation here must contain only generic UNIX code that
-//=== is guaranteed to work on *all* UNIX variants.
-//===----------------------------------------------------------------------===//
-
-using namespace llvm;
-
-std::string
-_system_error_category::message(int ev) const {
- return _do_message::message(ev);
-}
-
-error_condition
-_system_error_category::default_error_condition(int ev) const {
-#ifdef ELAST
- if (ev > ELAST)
- return error_condition(ev, system_category());
-#endif // ELAST
- return error_condition(ev, generic_category());
-}
Modified: llvm/trunk/lib/Support/Windows/Path.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Path.inc?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Path.inc (original)
+++ llvm/trunk/lib/Support/Windows/Path.inc Wed Jun 11 14:05:50 2014
@@ -17,6 +17,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/WindowsError.h"
#include <fcntl.h>
#include <io.h>
#include <sys/stat.h>
@@ -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) {
@@ -193,7 +194,7 @@ error_code remove(const Twine &path, boo
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();
}
@@ -205,14 +206,14 @@ error_code remove(const Twine &path, boo
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();
@@ -516,7 +517,7 @@ error_code mapped_file_region::init(int
_close(FileDescriptor);
} else
::CloseHandle(FileHandle);
- return make_error_code(errc::invalid_argument);
+ return make_error_code(std::errc::invalid_argument);
}
DWORD flprotect;
@@ -652,7 +653,7 @@ mapped_file_region::mapped_file_region(i
if (closefd)
_close(FileDescriptor);
FileDescriptor = 0;
- ec = make_error_code(errc::bad_file_descriptor);
+ ec = make_error_code(std::errc::bad_file_descriptor);
return;
}
@@ -815,7 +816,7 @@ error_code openFileForRead(const Twine &
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;
}
@@ -867,7 +868,7 @@ error_code openFileForWrite(const Twine
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;
}
Modified: llvm/trunk/lib/Support/Windows/Process.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/Process.inc?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Windows/Process.inc (original)
+++ llvm/trunk/lib/Support/Windows/Process.inc Wed Jun 11 14:05:50 2014
@@ -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.
@@ -180,7 +181,7 @@ Optional<std::string> Process::GetEnv(St
}
static error_code windows_error(DWORD E) {
- return error_code(E, system_category());
+ return mapWindowsError(E);
}
error_code
Removed: llvm/trunk/lib/Support/Windows/system_error.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Windows/system_error.inc?rev=210686&view=auto
==============================================================================
--- llvm/trunk/lib/Support/Windows/system_error.inc (original)
+++ llvm/trunk/lib/Support/Windows/system_error.inc (removed)
@@ -1,141 +0,0 @@
-//===- llvm/Support/Win32/system_error.inc - Windows error_code --*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file provides the Windows specific implementation of the error_code
-// and error_condition classes.
-//
-//===----------------------------------------------------------------------===//
-
-//===----------------------------------------------------------------------===//
-//=== WARNING: Implementation here must contain only generic Windows code that
-//=== is guaranteed to work on *all* Windows variants.
-//===----------------------------------------------------------------------===//
-
-#include <windows.h>
-#include <winerror.h>
-
-using namespace llvm;
-
-std::string
-_system_error_category::message(int ev) const {
- LPVOID lpMsgBuf = 0;
- DWORD retval = ::FormatMessageA(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- ev,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPSTR) &lpMsgBuf,
- 0,
- NULL);
- if (retval == 0) {
- ::LocalFree(lpMsgBuf);
- return std::string("Unknown error");
- }
-
- std::string str( static_cast<LPCSTR>(lpMsgBuf) );
- ::LocalFree(lpMsgBuf);
-
- while (str.size()
- && (str[str.size()-1] == '\n' || str[str.size()-1] == '\r'))
- str.erase( str.size()-1 );
- if (str.size() && str[str.size()-1] == '.')
- str.erase( str.size()-1 );
- return str;
-}
-
-// I'd rather not double the line count of the following.
-#define MAP_ERR_TO_COND(x, y) case x: return make_error_condition(errc::y)
-
-error_condition
-_system_error_category::default_error_condition(int ev) const {
- switch (ev) {
- // Windows system -> posix_errno decode table ---------------------------//
- // see WinError.h comments for descriptions of errors
- 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 error_condition(ev, system_category());
- }
-}
Added: llvm/trunk/lib/Support/WindowsError.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/WindowsError.cpp?rev=210687&view=auto
==============================================================================
--- llvm/trunk/lib/Support/WindowsError.cpp (added)
+++ llvm/trunk/lib/Support/WindowsError.cpp Wed Jun 11 14:05:50 2014
@@ -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
Modified: llvm/trunk/lib/Support/YAMLTraits.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/YAMLTraits.cpp?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/lib/Support/YAMLTraits.cpp (original)
+++ llvm/trunk/lib/Support/YAMLTraits.cpp Wed Jun 11 14:05:50 2014
@@ -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;
}
@@ -124,7 +124,7 @@ bool Input::preflightKey(const char *Key
// nodes are present.
if (!CurrentNode) {
if (Required)
- EC = make_error_code(errc::invalid_argument);
+ EC = make_error_code(std::errc::invalid_argument);
return false;
}
@@ -300,7 +300,7 @@ void Input::setError(HNode *hnode, const
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) {
Removed: llvm/trunk/lib/Support/system_error.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/system_error.cpp?rev=210686&view=auto
==============================================================================
--- llvm/trunk/lib/Support/system_error.cpp (original)
+++ llvm/trunk/lib/Support/system_error.cpp (removed)
@@ -1,121 +0,0 @@
-//===---------------------- system_error.cpp ------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This was lifted from libc++ and modified for C++03.
-//
-//===----------------------------------------------------------------------===//
-
-#include "llvm/Support/system_error.h"
-#include "llvm/Support/Errno.h"
-#include <cstring>
-#include <string>
-
-namespace llvm {
-
-// class error_category
-
-error_category::error_category() {
-}
-
-error_category::~error_category() {
-}
-
-error_condition
-error_category::default_error_condition(int ev) const {
- return error_condition(ev, *this);
-}
-
-bool
-error_category::equivalent(int code, const error_condition& condition) const {
- return default_error_condition(code) == condition;
-}
-
-bool
-error_category::equivalent(const error_code& code, int condition) const {
- return *this == code.category() && code.value() == condition;
-}
-
-std::string
-_do_message::message(int ev) const {
- return std::string(sys::StrError(ev));
-}
-
-class _generic_error_category : public _do_message {
-public:
- const char* name() const LLVM_NOEXCEPT override;
- std::string message(int ev) const override;
-};
-
-const char*
-_generic_error_category::name() const {
- return "generic";
-}
-
-std::string
-_generic_error_category::message(int ev) const {
-#ifdef ELAST
- if (ev > ELAST)
- return std::string("unspecified generic_category error");
-#endif // ELAST
- return _do_message::message(ev);
-}
-
-const error_category&
-generic_category() {
- static _generic_error_category s;
- return s;
-}
-
-class _system_error_category : public _do_message {
-public:
- const char* name() const LLVM_NOEXCEPT override;
- std::string message(int ev) const override;
- error_condition default_error_condition(int ev) const override;
-};
-
-const char*
-_system_error_category::name() const {
- return "system";
-}
-
-// std::string _system_error_category::message(int ev) const {
-// Is in Platform/system_error.inc
-
-// error_condition _system_error_category::default_error_condition(int ev) const
-// Is in Platform/system_error.inc
-
-const error_category&
-system_category() {
- static _system_error_category s;
- return s;
-}
-
-// error_condition
-
-std::string
-error_condition::message() const {
- return _cat_->message(_val_);
-}
-
-// error_code
-
-std::string
-error_code::message() const {
- return _cat_->message(_val_);
-}
-
-} // end namespace llvm
-
-// Include the truly platform-specific parts of this class.
-#if defined(LLVM_ON_UNIX)
-#include "Unix/system_error.inc"
-#endif
-#if defined(LLVM_ON_WIN32)
-#include "Windows/system_error.inc"
-#endif
Modified: llvm/trunk/test/Object/directory.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/directory.ll?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/test/Object/directory.ll (original)
+++ llvm/trunk/test/Object/directory.ll Wed Jun 11 14:05:50 2014
@@ -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
Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Wed Jun 11 14:05:50 2014
@@ -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;
}
@@ -939,7 +939,7 @@ static int performOperation(ArchiveOpera
// 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;
@@ -957,7 +957,7 @@ static int performOperation(ArchiveOpera
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 + "'");
Modified: llvm/trunk/tools/llvm-cov/llvm-cov.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/llvm-cov.cpp?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/llvm-cov.cpp (original)
+++ llvm/trunk/tools/llvm-cov/llvm-cov.cpp Wed Jun 11 14:05:50 2014
@@ -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;
}
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.h?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.h (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.h Wed Jun 11 14:05:50 2014
@@ -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;
Modified: llvm/trunk/tools/llvm-readobj/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/Error.cpp?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/Error.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/Error.cpp Wed Jun 11 14:05:50 2014
@@ -50,7 +50,7 @@ std::string _readobj_error_category::mes
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 {
Modified: llvm/trunk/tools/llvm-readobj/Error.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/Error.h?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/Error.h (original)
+++ llvm/trunk/tools/llvm-readobj/Error.h Wed Jun 11 14:05:50 2014
@@ -33,8 +33,10 @@ inline error_code make_error_code(readob
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
Modified: llvm/trunk/tools/llvm-readobj/ObjDumper.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ObjDumper.h?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ObjDumper.h (original)
+++ llvm/trunk/tools/llvm-readobj/ObjDumper.h Wed Jun 11 14:05:50 2014
@@ -10,6 +10,8 @@
#ifndef LLVM_READOBJ_OBJDUMPER_H
#define LLVM_READOBJ_OBJDUMPER_H
+#include "llvm/Support/system_error.h"
+
#include <memory>
namespace llvm {
@@ -18,8 +20,6 @@ namespace object {
class ObjectFile;
}
-class error_code;
-
class StreamWriter;
class ObjDumper {
Modified: llvm/trunk/tools/llvm-readobj/llvm-readobj.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/llvm-readobj.h?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/llvm-readobj.h (original)
+++ llvm/trunk/tools/llvm-readobj/llvm-readobj.h Wed Jun 11 14:05:50 2014
@@ -18,8 +18,6 @@ namespace llvm {
class RelocationRef;
}
- class error_code;
-
// Various helper functions.
bool error(error_code ec);
bool relocAddressLess(object::RelocationRef A,
Modified: llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp (original)
+++ llvm/trunk/tools/llvm-symbolizer/LLVMSymbolize.cpp Wed Jun 11 14:05:50 2014
@@ -311,7 +311,7 @@ LLVMSymbolizer::getOrCreateBinary(const
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));
}
Modified: llvm/trunk/tools/obj2yaml/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/Error.cpp?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/tools/obj2yaml/Error.cpp (original)
+++ llvm/trunk/tools/obj2yaml/Error.cpp Wed Jun 11 14:05:50 2014
@@ -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 {
Modified: llvm/trunk/tools/obj2yaml/Error.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/Error.h?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/tools/obj2yaml/Error.h (original)
+++ llvm/trunk/tools/obj2yaml/Error.h Wed Jun 11 14:05:50 2014
@@ -27,8 +27,10 @@ inline error_code make_error_code(obj2ya
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
Modified: llvm/trunk/unittests/Support/ErrorOrTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ErrorOrTest.cpp?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/ErrorOrTest.cpp (original)
+++ llvm/trunk/unittests/Support/ErrorOrTest.cpp Wed Jun 11 14:05:50 2014
@@ -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();
@@ -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
Modified: llvm/trunk/unittests/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/Path.cpp (original)
+++ llvm/trunk/unittests/Support/Path.cpp Wed Jun 11 14:05:50 2014
@@ -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.
@@ -397,7 +397,7 @@ 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
}
@@ -405,7 +405,7 @@ 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"));
}
Modified: llvm/trunk/unittests/Transforms/DebugIR/DebugIR.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/DebugIR/DebugIR.cpp?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/unittests/Transforms/DebugIR/DebugIR.cpp (original)
+++ llvm/trunk/unittests/Transforms/DebugIR/DebugIR.cpp Wed Jun 11 14:05:50 2014
@@ -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() {
Modified: llvm/trunk/utils/KillTheDoctor/KillTheDoctor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/KillTheDoctor/KillTheDoctor.cpp?rev=210687&r1=210686&r2=210687&view=diff
==============================================================================
--- llvm/trunk/utils/KillTheDoctor/KillTheDoctor.cpp (original)
+++ llvm/trunk/utils/KillTheDoctor/KillTheDoctor.cpp Wed Jun 11 14:05:50 2014
@@ -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>
@@ -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) {
@@ -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...
More information about the llvm-commits
mailing list