Skip to content

Commit fcb19f8

Browse files
committed
Address review comments
1 parent da474b7 commit fcb19f8

13 files changed

+90
-53
lines changed

libcxx/include/__exception/exception_ptr.h

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,10 @@ _LIBCPP_PUSH_MACROS
3535
// definitions is an ABI break, however. To prevent this, we have to make sure
3636
// the symbols remain available in the libc++ library, in addition to being
3737
// defined inline here in this header.
38-
// To this end, we use _LIBCPP_EXPORTED_FROM_LIB_INLINEABLE macro:
39-
// The macro is defined as empty for src/exception.cpp, forcing the definitions of
40-
// the functions to be emitted and included in the library. When users of libc++
41-
// compile their code, the __gnu_inline__ attribute will suppress generation of
42-
// these functions while making their definitions available for inlining.
43-
# ifdef _LIBCPP_EMIT_CODE_FOR_EXCEPTION_PTR
38+
# ifdef _LIBCPP_BUILDING_LIBRARY
4439
# define _LIBCPP_EXPORTED_FROM_LIB_INLINEABLE _LIBCPP_EXPORTED_FROM_ABI
4540
# else
46-
# if !__has_cpp_attribute(__gnu__::__gnu_inline__)
47-
# error "GNU inline attribute is not supported"
48-
# endif
49-
# define _LIBCPP_EXPORTED_FROM_LIB_INLINEABLE [[__gnu__::__gnu_inline__]] inline
41+
# define _LIBCPP_EXPORTED_FROM_LIB_INLINEABLE _LIBCPP_HIDE_FROM_ABI
5042
# endif
5143

5244
_LIBCPP_DIAGNOSTIC_PUSH
@@ -89,16 +81,8 @@ inline _LIBCPP_HIDE_FROM_ABI void swap(exception_ptr& __x, exception_ptr& __y) _
8981
class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
9082
void* __ptr_;
9183

92-
static void __do_increment_refcount(void* __ptr) _NOEXCEPT;
93-
static void __do_decrement_refcount(void* __ptr) _NOEXCEPT;
94-
_LIBCPP_HIDE_FROM_ABI static void __increment_refcount(void* __ptr) _NOEXCEPT {
95-
if (__ptr)
96-
__do_increment_refcount(__ptr);
97-
}
98-
_LIBCPP_HIDE_FROM_ABI static void __decrement_refcount(void* __ptr) _NOEXCEPT {
99-
if (__ptr)
100-
__do_decrement_refcount(__ptr);
101-
}
84+
static void __increment_refcount([[__gnu__::__nonnull__]] _LIBCPP_NOESCAPE void* __ptr) _NOEXCEPT;
85+
static void __decrement_refcount([[__gnu__::__nonnull__]] _LIBCPP_NOESCAPE void* __ptr) _NOEXCEPT;
10286

10387
static exception_ptr __from_native_exception_pointer(void*) _NOEXCEPT;
10488

@@ -120,7 +104,8 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
120104
}
121105
_LIBCPP_EXPORTED_FROM_LIB_INLINEABLE exception_ptr& operator=(const exception_ptr&) _NOEXCEPT;
122106
_LIBCPP_HIDE_FROM_ABI exception_ptr& operator=(exception_ptr&& __other) _NOEXCEPT {
123-
__decrement_refcount(__ptr_);
107+
if (__ptr_)
108+
__decrement_refcount(__ptr_);
124109
__ptr_ = __other.__ptr_;
125110
__other.__ptr_ = nullptr;
126111
return *this;
@@ -143,24 +128,31 @@ class _LIBCPP_EXPORTED_FROM_ABI exception_ptr {
143128
friend _LIBCPP_EXPORTED_FROM_ABI void rethrow_exception(exception_ptr);
144129
};
145130

146-
// Must be defined outside the class definition due to _LIBCPP_EXPORTED_FROM_LIB_INLINEABLE
131+
#ifndef _LIBCPP_BUILDING_LIBRARY
132+
147133
_LIBCPP_EXPORTED_FROM_LIB_INLINEABLE exception_ptr::exception_ptr(const exception_ptr& __other) _NOEXCEPT
148134
: __ptr_(__other.__ptr_) {
149-
__increment_refcount(__ptr_);
135+
if (__ptr_)
136+
__increment_refcount(__ptr_);
150137
}
151138

152-
// Must be defined outside the class definition due to _LIBCPP_EXPORTED_FROM_LIB_INLINEABLE
153139
_LIBCPP_EXPORTED_FROM_LIB_INLINEABLE exception_ptr& exception_ptr::operator=(const exception_ptr& __other) _NOEXCEPT {
154140
if (__ptr_ != __other.__ptr_) {
155-
__increment_refcount(__other.__ptr_);
156-
__decrement_refcount(__ptr_);
141+
if (__other.__ptr_)
142+
__increment_refcount(__other.__ptr_);
143+
if (__ptr_)
144+
__decrement_refcount(__ptr_);
157145
__ptr_ = __other.__ptr_;
158146
}
159147
return *this;
160148
}
161149

162-
// Must be defined outside the class definition due to _LIBCPP_EXPORTED_FROM_LIB_INLINEABLE
163-
_LIBCPP_EXPORTED_FROM_LIB_INLINEABLE exception_ptr::~exception_ptr() _NOEXCEPT { __decrement_refcount(__ptr_); }
150+
_LIBCPP_EXPORTED_FROM_LIB_INLINEABLE exception_ptr::~exception_ptr() _NOEXCEPT {
151+
if (__ptr_)
152+
__decrement_refcount(__ptr_);
153+
}
154+
155+
#endif // _LIBCPP_BUILDING_LIBRARY
164156

165157
inline _LIBCPP_HIDE_FROM_ABI void swap(exception_ptr& __x, exception_ptr& __y) _NOEXCEPT {
166158
std::swap(__x.__ptr_, __y.__ptr_);

libcxx/lib/abi/arm64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,8 +858,8 @@
858858
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD0Ev', 'type': 'I'}
859859
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD1Ev', 'type': 'I'}
860860
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD2Ev', 'type': 'I'}
861-
{'is_defined': True, 'name': '__ZNSt13exception_ptr23__do_decrement_refcountEPv', 'type': 'FUNC'}
862-
{'is_defined': True, 'name': '__ZNSt13exception_ptr23__do_increment_refcountEPv', 'type': 'FUNC'}
861+
{'is_defined': True, 'name': '__ZNSt13exception_ptr23__decrement_refcountEPv', 'type': 'FUNC'}
862+
{'is_defined': True, 'name': '__ZNSt13exception_ptr23__increment_refcountEPv', 'type': 'FUNC'}
863863
{'is_defined': True, 'name': '__ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
864864
{'is_defined': True, 'name': '__ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
865865
{'is_defined': True, 'name': '__ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}

libcxx/lib/abi/i686-linux-android21.libcxxabi.v1.stable.exceptions.nonew.abilist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,8 @@
494494
{'is_defined': True, 'name': '_ZNSt13bad_exceptionD0Ev', 'type': 'FUNC'}
495495
{'is_defined': True, 'name': '_ZNSt13bad_exceptionD1Ev', 'type': 'FUNC'}
496496
{'is_defined': True, 'name': '_ZNSt13bad_exceptionD2Ev', 'type': 'FUNC'}
497-
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__do_decrement_refcountEPv', 'type': 'FUNC'}
498-
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__do_increment_refcountEPv', 'type': 'FUNC'}
497+
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__decrement_refcountEPv', 'type': 'FUNC'}
498+
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__increment_refcountEPv', 'type': 'FUNC'}
499499
{'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
500500
{'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
501501
{'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}

libcxx/lib/abi/powerpc-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@
250250
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
251251
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
252252
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
253-
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr23__do_decrement_refcountEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
254-
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr23__do_increment_refcountEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
253+
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr23__decrement_refcountEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
254+
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr23__increment_refcountEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
255255
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
256256
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
257257
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'storage_mapping_class': 'DS', 'type': 'FUNC'}

libcxx/lib/abi/powerpc64-ibm-aix.libcxxabi.v1.stable.exceptions.nonew.abilist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,8 @@
250250
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
251251
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
252252
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
253-
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr23__do_decrement_refcountEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
254-
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr23__do_increment_refcountEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
253+
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr23__decrement_refcountEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
254+
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr23__increment_refcountEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
255255
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
256256
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
257257
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'storage_mapping_class': 'DS', 'type': 'FUNC'}

libcxx/lib/abi/x86_64-apple-darwin.libcxxabi.v1.stable.exceptions.nonew.abilist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,8 +857,8 @@
857857
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD0Ev', 'type': 'I'}
858858
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD1Ev', 'type': 'I'}
859859
{'is_defined': True, 'name': '__ZNSt13bad_exceptionD2Ev', 'type': 'I'}
860-
{'is_defined': True, 'name': '__ZNSt13exception_ptr23__do_decrement_refcountEPv', 'type': 'FUNC'}
861-
{'is_defined': True, 'name': '__ZNSt13exception_ptr23__do_increment_refcountEPv', 'type': 'FUNC'}
860+
{'is_defined': True, 'name': '__ZNSt13exception_ptr23__decrement_refcountEPv', 'type': 'FUNC'}
861+
{'is_defined': True, 'name': '__ZNSt13exception_ptr23__increment_refcountEPv', 'type': 'FUNC'}
862862
{'is_defined': True, 'name': '__ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
863863
{'is_defined': True, 'name': '__ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
864864
{'is_defined': True, 'name': '__ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}

libcxx/lib/abi/x86_64-linux-android21.libcxxabi.v1.stable.exceptions.nonew.abilist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,8 @@
494494
{'is_defined': True, 'name': '_ZNSt13bad_exceptionD0Ev', 'type': 'FUNC'}
495495
{'is_defined': True, 'name': '_ZNSt13bad_exceptionD1Ev', 'type': 'FUNC'}
496496
{'is_defined': True, 'name': '_ZNSt13bad_exceptionD2Ev', 'type': 'FUNC'}
497-
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__do_decrement_refcountEPv', 'type': 'FUNC'}
498-
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__do_increment_refcountEPv', 'type': 'FUNC'}
497+
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__decrement_refcountEPv', 'type': 'FUNC'}
498+
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__increment_refcountEPv', 'type': 'FUNC'}
499499
{'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
500500
{'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
501501
{'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}

libcxx/lib/abi/x86_64-unknown-freebsd.libcxxabi.v1.stable.exceptions.nonew.abilist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,8 @@
525525
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'type': 'FUNC'}
526526
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'type': 'FUNC'}
527527
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'type': 'FUNC'}
528-
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__do_decrement_refcountEPv', 'type': 'FUNC'}
529-
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__do_increment_refcountEPv', 'type': 'FUNC'}
528+
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__decrement_refcountEPv', 'type': 'FUNC'}
529+
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__increment_refcountEPv', 'type': 'FUNC'}
530530
{'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
531531
{'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
532532
{'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}

libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.exceptions.nonew.abilist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,8 @@
523523
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'type': 'FUNC'}
524524
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'type': 'FUNC'}
525525
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'type': 'FUNC'}
526-
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__do_decrement_refcountEPv', 'type': 'FUNC'}
527-
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__do_increment_refcountEPv', 'type': 'FUNC'}
526+
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__decrement_refcountEPv', 'type': 'FUNC'}
527+
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__increment_refcountEPv', 'type': 'FUNC'}
528528
{'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
529529
{'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
530530
{'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}

libcxx/lib/abi/x86_64-unknown-linux-gnu.libcxxabi.v1.stable.noexceptions.nonew.abilist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,8 +494,8 @@
494494
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD0Ev', 'type': 'FUNC'}
495495
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD1Ev', 'type': 'FUNC'}
496496
{'is_defined': True, 'name': '_ZNSt12experimental19bad_optional_accessD2Ev', 'type': 'FUNC'}
497-
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__do_decrement_refcountEPv', 'type': 'FUNC'}
498-
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__do_increment_refcountEPv', 'type': 'FUNC'}
497+
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__decrement_refcountEPv', 'type': 'FUNC'}
498+
{'is_defined': True, 'name': '_ZNSt13exception_ptr23__increment_refcountEPv', 'type': 'FUNC'}
499499
{'is_defined': True, 'name': '_ZNSt13exception_ptr31__from_native_exception_pointerEPv', 'type': 'FUNC'}
500500
{'is_defined': True, 'name': '_ZNSt13exception_ptrC1ERKS_', 'type': 'FUNC'}
501501
{'is_defined': True, 'name': '_ZNSt13exception_ptrC2ERKS_', 'type': 'FUNC'}

0 commit comments

Comments
 (0)