Skip to content

Commit 9fdb4f3

Browse files
authored
[libc++] Make bad_function_call::what() existence a matter of availability instead of ABI (#127697)
We're currently adding `bad_function_call::what()` behind an ABI flag, even though adding it is not an ABI break and can be handled through availability.
1 parent 166e5b1 commit 9fdb4f3

13 files changed

+15
-15
lines changed

libcxx/include/__configuration/abi.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@
5151
# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
5252
# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
5353
# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
54-
// Override the default return value of exception::what() for bad_function_call::what()
55-
// with a string that is specific to bad_function_call (see http://wg21.link/LWG2233).
56-
// This is an ABI break on platforms that sign and authenticate vtable function pointers
57-
// because it changes the mangling of the virtual function located in the vtable, which
58-
// changes how it gets signed.
59-
# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
6054
// Give reverse_iterator<T> one data member of type T, not two.
6155
// Also, in C++17 and later, don't derive iterator types from std::iterator.
6256
# define _LIBCPP_ABI_NO_ITERATOR_BASES

libcxx/include/__configuration/availability.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,11 @@
372372
#define _LIBCPP_AVAILABILITY_HAS_HASH_MEMORY _LIBCPP_INTRODUCED_IN_LLVM_21
373373
// No attribute, since we've had hash in the headers before
374374

375+
// This controls whether we provide a message for `bad_function_call::what()` that specific to `std::bad_function_call`.
376+
// See https://wg21.link/LWG2233. This requires `std::bad_function_call::what()` to be available in the dylib.
377+
#define _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE _LIBCPP_INTRODUCED_IN_LLVM_21
378+
// No attribute, since we've had bad_function_call::what() in the headers before
379+
375380
// Define availability attributes that depend on _LIBCPP_HAS_EXCEPTIONS.
376381
// Those are defined in terms of the availability attributes above, and
377382
// should not be vendor-specific.

libcxx/include/__functional/function.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_function_call : public exception {
7171
_LIBCPP_HIDE_FROM_ABI_VIRTUAL ~bad_function_call() _NOEXCEPT override {}
7272
# endif
7373

74-
# ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
74+
# if _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
7575
const char* what() const _NOEXCEPT override;
7676
# endif
7777
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,7 @@
15081508
{'is_defined': True, 'name': '__ZNSt3__117bad_function_callD0Ev', 'type': 'FUNC'}
15091509
{'is_defined': True, 'name': '__ZNSt3__117bad_function_callD1Ev', 'type': 'FUNC'}
15101510
{'is_defined': True, 'name': '__ZNSt3__117bad_function_callD2Ev', 'type': 'FUNC'}
1511+
{'is_defined': True, 'name': '__ZNKSt3__117bad_function_call4whatEv', 'type': 'FUNC'}
15111512
{'is_defined': True, 'name': '__ZNSt3__117iostream_categoryEv', 'type': 'FUNC'}
15121513
{'is_defined': True, 'name': '__ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc', 'type': 'FUNC'}
15131514
{'is_defined': True, 'name': '__ZNSt3__117moneypunct_bynameIcLb1EE4initEPKc', 'type': 'FUNC'}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,7 @@
11441144
{'is_defined': True, 'name': '_ZNSt6__ndk117bad_function_callD0Ev', 'type': 'FUNC'}
11451145
{'is_defined': True, 'name': '_ZNSt6__ndk117bad_function_callD1Ev', 'type': 'FUNC'}
11461146
{'is_defined': True, 'name': '_ZNSt6__ndk117bad_function_callD2Ev', 'type': 'FUNC'}
1147+
{'is_defined': True, 'name': '_ZNKSt6__ndk117bad_function_call4whatEv', 'type': 'FUNC'}
11471148
{'is_defined': True, 'name': '_ZNSt6__ndk117iostream_categoryEv', 'type': 'FUNC'}
11481149
{'is_defined': True, 'name': '_ZNSt6__ndk117moneypunct_bynameIcLb0EE4initEPKc', 'type': 'FUNC'}
11491150
{'is_defined': True, 'name': '_ZNSt6__ndk117moneypunct_bynameIcLb1EE4initEPKc', 'type': 'FUNC'}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@
503503
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117bad_function_callD0Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
504504
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117bad_function_callD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
505505
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117bad_function_callD2Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
506+
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNKSt3__117bad_function_call4whatEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
506507
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117iostream_categoryEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
507508
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
508509
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb1EE4initEPKc', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
@@ -1066,7 +1067,6 @@
10661067
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZTv0_n12_NSt3__19strstreamD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
10671068
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNKSt11logic_error4whatEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
10681069
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNKSt13runtime_error4whatEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
1069-
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNKSt9exception4whatEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
10701070
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNSt11logic_errorD2Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
10711071
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNSt12length_errorD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
10721072
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNSt12out_of_rangeD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@
503503
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117bad_function_callD0Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
504504
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117bad_function_callD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
505505
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117bad_function_callD2Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
506+
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNKSt3__117bad_function_call4whatEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
506507
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117iostream_categoryEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
507508
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
508509
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb1EE4initEPKc', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
@@ -1066,7 +1067,6 @@
10661067
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZTv0_n24_NSt3__19strstreamD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
10671068
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNKSt11logic_error4whatEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
10681069
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNKSt13runtime_error4whatEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
1069-
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNKSt9exception4whatEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
10701070
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNSt11logic_errorD2Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
10711071
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNSt12length_errorD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
10721072
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNSt12out_of_rangeD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
{'is_defined': False, 'name': '__ZNKSt20bad_array_new_length4whatEv', 'type': 'U'}
66
{'is_defined': False, 'name': '__ZNKSt8bad_cast4whatEv', 'type': 'U'}
77
{'is_defined': False, 'name': '__ZNKSt9bad_alloc4whatEv', 'type': 'U'}
8-
{'is_defined': False, 'name': '__ZNKSt9exception4whatEv', 'type': 'U'}
98
{'is_defined': False, 'name': '__ZNSt10bad_typeidC1Ev', 'type': 'U'}
109
{'is_defined': False, 'name': '__ZNSt10bad_typeidC2Ev', 'type': 'U'}
1110
{'is_defined': False, 'name': '__ZNSt10bad_typeidD0Ev', 'type': 'U'}
@@ -1508,6 +1507,7 @@
15081507
{'is_defined': True, 'name': '__ZNSt3__117bad_function_callD0Ev', 'type': 'FUNC'}
15091508
{'is_defined': True, 'name': '__ZNSt3__117bad_function_callD1Ev', 'type': 'FUNC'}
15101509
{'is_defined': True, 'name': '__ZNSt3__117bad_function_callD2Ev', 'type': 'FUNC'}
1510+
{'is_defined': True, 'name': '__ZNKSt3__117bad_function_call4whatEv', 'type': 'FUNC'}
15111511
{'is_defined': True, 'name': '__ZNSt3__117iostream_categoryEv', 'type': 'FUNC'}
15121512
{'is_defined': True, 'name': '__ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc', 'type': 'FUNC'}
15131513
{'is_defined': True, 'name': '__ZNSt3__117moneypunct_bynameIcLb1EE4initEPKc', 'type': 'FUNC'}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,7 @@
11441144
{'is_defined': True, 'name': '_ZNSt6__ndk117bad_function_callD0Ev', 'type': 'FUNC'}
11451145
{'is_defined': True, 'name': '_ZNSt6__ndk117bad_function_callD1Ev', 'type': 'FUNC'}
11461146
{'is_defined': True, 'name': '_ZNSt6__ndk117bad_function_callD2Ev', 'type': 'FUNC'}
1147+
{'is_defined': True, 'name': '_ZNKSt6__ndk117bad_function_call4whatEv', 'type': 'FUNC'}
11471148
{'is_defined': True, 'name': '_ZNSt6__ndk117iostream_categoryEv', 'type': 'FUNC'}
11481149
{'is_defined': True, 'name': '_ZNSt6__ndk117moneypunct_bynameIcLb0EE4initEPKc', 'type': 'FUNC'}
11491150
{'is_defined': True, 'name': '_ZNSt6__ndk117moneypunct_bynameIcLb1EE4initEPKc', 'type': 'FUNC'}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{'is_defined': False, 'name': '_ZNKSt11logic_error4whatEv', 'type': 'FUNC'}
22
{'is_defined': False, 'name': '_ZNKSt13runtime_error4whatEv', 'type': 'FUNC'}
3-
{'is_defined': False, 'name': '_ZNKSt9exception4whatEv', 'type': 'FUNC'}
43
{'is_defined': False, 'name': '_ZNSt11logic_errorD2Ev', 'type': 'FUNC'}
54
{'is_defined': False, 'name': '_ZNSt12length_errorD1Ev', 'type': 'FUNC'}
65
{'is_defined': False, 'name': '_ZNSt12out_of_rangeD1Ev', 'type': 'FUNC'}
@@ -1159,6 +1158,7 @@
11591158
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD0Ev', 'type': 'FUNC'}
11601159
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD1Ev', 'type': 'FUNC'}
11611160
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD2Ev', 'type': 'FUNC'}
1161+
{'is_defined': True, 'name': '_ZNKSt3__117bad_function_call4whatEv', 'type': 'FUNC'}
11621162
{'is_defined': True, 'name': '_ZNSt3__117iostream_categoryEv', 'type': 'FUNC'}
11631163
{'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc', 'type': 'FUNC'}
11641164
{'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb1EE4initEPKc', 'type': 'FUNC'}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{'is_defined': False, 'name': '_ZNKSt11logic_error4whatEv', 'type': 'FUNC'}
22
{'is_defined': False, 'name': '_ZNKSt13runtime_error4whatEv', 'type': 'FUNC'}
3-
{'is_defined': False, 'name': '_ZNKSt9exception4whatEv', 'type': 'FUNC'}
43
{'is_defined': False, 'name': '_ZNSt11logic_errorD2Ev', 'type': 'FUNC'}
54
{'is_defined': False, 'name': '_ZNSt12length_errorD1Ev', 'type': 'FUNC'}
65
{'is_defined': False, 'name': '_ZNSt12out_of_rangeD1Ev', 'type': 'FUNC'}
@@ -1157,6 +1156,7 @@
11571156
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD0Ev', 'type': 'FUNC'}
11581157
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD1Ev', 'type': 'FUNC'}
11591158
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD2Ev', 'type': 'FUNC'}
1159+
{'is_defined': True, 'name': '_ZNKSt3__117bad_function_call4whatEv', 'type': 'FUNC'}
11601160
{'is_defined': True, 'name': '_ZNSt3__117iostream_categoryEv', 'type': 'FUNC'}
11611161
{'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc', 'type': 'FUNC'}
11621162
{'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb1EE4initEPKc', 'type': 'FUNC'}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{'is_defined': False, 'name': '_ZNKSt11logic_error4whatEv', 'type': 'FUNC'}
22
{'is_defined': False, 'name': '_ZNKSt13runtime_error4whatEv', 'type': 'FUNC'}
3-
{'is_defined': False, 'name': '_ZNKSt9exception4whatEv', 'type': 'FUNC'}
43
{'is_defined': False, 'name': '_ZNSt11logic_errorD2Ev', 'type': 'FUNC'}
54
{'is_defined': False, 'name': '_ZNSt13runtime_errorD2Ev', 'type': 'FUNC'}
65
{'is_defined': False, 'name': '_ZNSt8bad_castD2Ev', 'type': 'FUNC'}
@@ -1128,6 +1127,7 @@
11281127
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD0Ev', 'type': 'FUNC'}
11291128
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD1Ev', 'type': 'FUNC'}
11301129
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD2Ev', 'type': 'FUNC'}
1130+
{'is_defined': True, 'name': '_ZNKSt3__117bad_function_call4whatEv', 'type': 'FUNC'}
11311131
{'is_defined': True, 'name': '_ZNSt3__117iostream_categoryEv', 'type': 'FUNC'}
11321132
{'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc', 'type': 'FUNC'}
11331133
{'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb1EE4initEPKc', 'type': 'FUNC'}

libcxx/src/functional.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
1212

1313
bad_function_call::~bad_function_call() noexcept {}
1414

15-
#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
1615
const char* bad_function_call::what() const noexcept { return "std::bad_function_call"; }
17-
#endif
1816

1917
size_t __hash_memory(_LIBCPP_NOESCAPE const void* ptr, size_t size) noexcept {
2018
return __murmur2_or_cityhash<size_t>()(ptr, size);

0 commit comments

Comments
 (0)