Skip to content

Commit e8cfbfd

Browse files
committed
[libc++] Granularize system_error.
Reviewed By: #libc, philnik Differential Revision: https://reviews.llvm.org/D147853
1 parent bdf7fd8 commit e8cfbfd

File tree

49 files changed

+660
-420
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+660
-420
lines changed

libcxx/docs/ReleaseNotes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ Deprecations and Removals
6363
includes are removed based on the language version used. Incidental transitive
6464
inclusions of the following headers have been removed:
6565

66-
- C++2b: ``atomic``, ``bit``, ``cstdint``, ``cstdlib``, ``cstring``, ``initializer_list``, ``new``, ``stdexcept``,
67-
``type_traits``, ``typeinfo``
66+
- C++2b: ``atomic``, ``bit``, ``cstdint``, ``cstdlib``, ``cstring``, ``initializer_list``, ``limits``, ``new``,
67+
``stdexcept``, ``system_error``, ``type_traits``, ``typeinfo``
6868

6969
- The headers ``<experimental/algorithm>`` and ``<experimental/functional>`` have been removed, since all the contents
7070
have been implemented in namespace ``std`` for at least two releases.

libcxx/include/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,10 @@ set(files
589589
__support/xlocale/__nop_locale_mgmt.h
590590
__support/xlocale/__posix_l_fallback.h
591591
__support/xlocale/__strtonum_fallback.h
592+
__system_error/error_category.h
593+
__system_error/error_code.h
594+
__system_error/error_condition.h
595+
__system_error/system_error.h
592596
__thread/poll_with_backoff.h
593597
__thread/timed_backoff_policy.h
594598
__threading_support

libcxx/include/__condition_variable/condition_variable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
#include <__config>
1616
#include <__mutex/mutex.h>
1717
#include <__mutex/unique_lock.h>
18+
#include <__system_error/system_error.h>
1819
#include <__threading_support>
1920
#include <__type_traits/enable_if.h>
2021
#include <__type_traits/is_floating_point.h>
2122
#include <__utility/move.h>
2223
#include <ratio>
23-
#include <system_error>
2424

2525
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2626
# pragma GCC system_header

libcxx/include/__filesystem/directory_entry.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <__availability>
1414
#include <__chrono/time_point.h>
15+
#include <__compare/ordering.h>
1516
#include <__config>
1617
#include <__errc>
1718
#include <__filesystem/file_status.h>
@@ -21,10 +22,11 @@
2122
#include <__filesystem/operations.h>
2223
#include <__filesystem/path.h>
2324
#include <__filesystem/perms.h>
25+
#include <__system_error/error_code.h>
26+
#include <__utility/move.h>
2427
#include <__utility/unreachable.h>
2528
#include <cstdint>
2629
#include <iosfwd>
27-
#include <system_error>
2830

2931
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
3032
# pragma GCC system_header

libcxx/include/__filesystem/directory_iterator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
#include <__memory/shared_ptr.h>
2121
#include <__ranges/enable_borrowed_range.h>
2222
#include <__ranges/enable_view.h>
23+
#include <__system_error/error_code.h>
24+
#include <__utility/move.h>
2325
#include <cstddef>
24-
#include <system_error>
2526

2627
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2728
# pragma GCC system_header

libcxx/include/__filesystem/filesystem_error.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
#include <__config>
1515
#include <__filesystem/path.h>
1616
#include <__memory/shared_ptr.h>
17+
#include <__system_error/error_code.h>
18+
#include <__system_error/system_error.h>
1719
#include <__utility/forward.h>
1820
#include <__verbose_abort>
1921
#include <iosfwd>
2022
#include <new>
21-
#include <system_error>
23+
#include <string>
2224

2325
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2426
# pragma GCC system_header

libcxx/include/__filesystem/operations.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
#include <__filesystem/perm_options.h>
2222
#include <__filesystem/perms.h>
2323
#include <__filesystem/space_info.h>
24+
#include <__system_error/error_code.h>
2425
#include <cstdint>
25-
#include <system_error>
2626

2727
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2828
# pragma GCC system_header

libcxx/include/__filesystem/recursive_directory_iterator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@
1919
#include <__memory/shared_ptr.h>
2020
#include <__ranges/enable_borrowed_range.h>
2121
#include <__ranges/enable_view.h>
22+
#include <__system_error/error_code.h>
23+
#include <__utility/move.h>
2224
#include <cstddef>
23-
#include <system_error>
2425

2526
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2627
# pragma GCC system_header

libcxx/include/__mutex/unique_lock.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
#include <__config>
1515
#include <__memory/addressof.h>
1616
#include <__mutex/tag_types.h>
17+
#include <__system_error/system_error.h>
1718
#include <__utility/swap.h>
18-
#include <system_error>
19+
#include <cerrno>
1920

2021
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
2122
# pragma GCC system_header
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// -*- C++ -*-
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef _LIBCPP___SYSTEM_ERROR_ERROR_CATEGORY_H
11+
#define _LIBCPP___SYSTEM_ERROR_ERROR_CATEGORY_H
12+
13+
#include <__compare/ordering.h>
14+
#include <__config>
15+
#include <string>
16+
17+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18+
# pragma GCC system_header
19+
#endif
20+
21+
_LIBCPP_BEGIN_NAMESPACE_STD
22+
23+
class _LIBCPP_TYPE_VIS error_condition;
24+
class _LIBCPP_TYPE_VIS error_code;
25+
26+
class _LIBCPP_HIDDEN __do_message;
27+
28+
class _LIBCPP_TYPE_VIS error_category
29+
{
30+
public:
31+
virtual ~error_category() _NOEXCEPT;
32+
33+
#if defined(_LIBCPP_ERROR_CATEGORY_DEFINE_LEGACY_INLINE_FUNCTIONS)
34+
error_category() noexcept;
35+
#else
36+
_LIBCPP_INLINE_VISIBILITY
37+
_LIBCPP_CONSTEXPR_SINCE_CXX14 error_category() _NOEXCEPT = default;
38+
#endif
39+
error_category(const error_category&) = delete;
40+
error_category& operator=(const error_category&) = delete;
41+
42+
virtual const char* name() const _NOEXCEPT = 0;
43+
virtual error_condition default_error_condition(int __ev) const _NOEXCEPT;
44+
virtual bool equivalent(int __code, const error_condition& __condition) const _NOEXCEPT;
45+
virtual bool equivalent(const error_code& __code, int __condition) const _NOEXCEPT;
46+
virtual string message(int __ev) const = 0;
47+
48+
_LIBCPP_INLINE_VISIBILITY
49+
bool operator==(const error_category& __rhs) const _NOEXCEPT {return this == &__rhs;}
50+
51+
#if _LIBCPP_STD_VER >= 20
52+
53+
_LIBCPP_HIDE_FROM_ABI
54+
strong_ordering operator<=>(const error_category& __rhs) const noexcept {return compare_three_way()(this, std::addressof(__rhs));}
55+
56+
#else // _LIBCPP_STD_VER >= 20
57+
58+
_LIBCPP_INLINE_VISIBILITY
59+
bool operator!=(const error_category& __rhs) const _NOEXCEPT {return !(*this == __rhs);}
60+
61+
_LIBCPP_INLINE_VISIBILITY
62+
bool operator< (const error_category& __rhs) const _NOEXCEPT {return this < &__rhs;}
63+
64+
#endif // _LIBCPP_STD_VER >= 20
65+
66+
friend class _LIBCPP_HIDDEN __do_message;
67+
};
68+
69+
class _LIBCPP_HIDDEN __do_message
70+
: public error_category
71+
{
72+
public:
73+
string message(int __ev) const override;
74+
};
75+
76+
_LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT;
77+
_LIBCPP_FUNC_VIS const error_category& system_category() _NOEXCEPT;
78+
79+
_LIBCPP_END_NAMESPACE_STD
80+
81+
#endif // _LIBCPP___SYSTEM_ERROR_ERROR_CATEGORY_H

0 commit comments

Comments
 (0)