[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.
This commit is contained in:
Nikolas Klauser
2025-04-25 10:45:46 +02:00
committed by GitHub
parent 166e5b1f0f
commit 9fdb4f3537
13 changed files with 15 additions and 15 deletions

View File

@@ -51,12 +51,6 @@
# define _LIBCPP_ABI_FIX_UNORDERED_NODE_POINTER_UB
# define _LIBCPP_ABI_FORWARD_LIST_REMOVE_NODE_POINTER_UB
# define _LIBCPP_ABI_FIX_UNORDERED_CONTAINER_SIZE_TYPE
// Override the default return value of exception::what() for bad_function_call::what()
// with a string that is specific to bad_function_call (see http://wg21.link/LWG2233).
// This is an ABI break on platforms that sign and authenticate vtable function pointers
// because it changes the mangling of the virtual function located in the vtable, which
// changes how it gets signed.
# define _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
// Give reverse_iterator<T> one data member of type T, not two.
// Also, in C++17 and later, don't derive iterator types from std::iterator.
# define _LIBCPP_ABI_NO_ITERATOR_BASES

View File

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

View File

@@ -71,7 +71,7 @@ public:
_LIBCPP_HIDE_FROM_ABI_VIRTUAL ~bad_function_call() _NOEXCEPT override {}
# endif
# ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
# if _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
const char* what() const _NOEXCEPT override;
# endif
};

View File

@@ -1508,6 +1508,7 @@
{'is_defined': True, 'name': '__ZNSt3__117bad_function_callD0Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__117bad_function_callD1Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__117bad_function_callD2Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNKSt3__117bad_function_call4whatEv', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__117iostream_categoryEv', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__117moneypunct_bynameIcLb1EE4initEPKc', 'type': 'FUNC'}

View File

@@ -1144,6 +1144,7 @@
{'is_defined': True, 'name': '_ZNSt6__ndk117bad_function_callD0Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt6__ndk117bad_function_callD1Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt6__ndk117bad_function_callD2Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNKSt6__ndk117bad_function_call4whatEv', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt6__ndk117iostream_categoryEv', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt6__ndk117moneypunct_bynameIcLb0EE4initEPKc', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt6__ndk117moneypunct_bynameIcLb1EE4initEPKc', 'type': 'FUNC'}

View File

@@ -503,6 +503,7 @@
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117bad_function_callD0Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117bad_function_callD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117bad_function_callD2Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNKSt3__117bad_function_call4whatEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117iostream_categoryEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb1EE4initEPKc', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
@@ -1066,7 +1067,6 @@
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZTv0_n12_NSt3__19strstreamD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNKSt11logic_error4whatEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNKSt13runtime_error4whatEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNKSt9exception4whatEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNSt11logic_errorD2Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNSt12length_errorD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNSt12out_of_rangeD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}

View File

@@ -503,6 +503,7 @@
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117bad_function_callD0Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117bad_function_callD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117bad_function_callD2Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNKSt3__117bad_function_call4whatEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117iostream_categoryEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb1EE4initEPKc', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
@@ -1066,7 +1067,6 @@
{'import_export': 'EXP', 'is_defined': True, 'name': '_ZTv0_n24_NSt3__19strstreamD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNKSt11logic_error4whatEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNKSt13runtime_error4whatEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNKSt9exception4whatEv', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNSt11logic_errorD2Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNSt12length_errorD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}
{'import_export': 'IMP', 'is_defined': False, 'name': '_ZNSt12out_of_rangeD1Ev', 'storage_mapping_class': 'DS', 'type': 'FUNC'}

View File

@@ -5,7 +5,6 @@
{'is_defined': False, 'name': '__ZNKSt20bad_array_new_length4whatEv', 'type': 'U'}
{'is_defined': False, 'name': '__ZNKSt8bad_cast4whatEv', 'type': 'U'}
{'is_defined': False, 'name': '__ZNKSt9bad_alloc4whatEv', 'type': 'U'}
{'is_defined': False, 'name': '__ZNKSt9exception4whatEv', 'type': 'U'}
{'is_defined': False, 'name': '__ZNSt10bad_typeidC1Ev', 'type': 'U'}
{'is_defined': False, 'name': '__ZNSt10bad_typeidC2Ev', 'type': 'U'}
{'is_defined': False, 'name': '__ZNSt10bad_typeidD0Ev', 'type': 'U'}
@@ -1508,6 +1507,7 @@
{'is_defined': True, 'name': '__ZNSt3__117bad_function_callD0Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__117bad_function_callD1Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__117bad_function_callD2Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNKSt3__117bad_function_call4whatEv', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__117iostream_categoryEv', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc', 'type': 'FUNC'}
{'is_defined': True, 'name': '__ZNSt3__117moneypunct_bynameIcLb1EE4initEPKc', 'type': 'FUNC'}

View File

@@ -1144,6 +1144,7 @@
{'is_defined': True, 'name': '_ZNSt6__ndk117bad_function_callD0Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt6__ndk117bad_function_callD1Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt6__ndk117bad_function_callD2Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNKSt6__ndk117bad_function_call4whatEv', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt6__ndk117iostream_categoryEv', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt6__ndk117moneypunct_bynameIcLb0EE4initEPKc', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt6__ndk117moneypunct_bynameIcLb1EE4initEPKc', 'type': 'FUNC'}

View File

@@ -1,6 +1,5 @@
{'is_defined': False, 'name': '_ZNKSt11logic_error4whatEv', 'type': 'FUNC'}
{'is_defined': False, 'name': '_ZNKSt13runtime_error4whatEv', 'type': 'FUNC'}
{'is_defined': False, 'name': '_ZNKSt9exception4whatEv', 'type': 'FUNC'}
{'is_defined': False, 'name': '_ZNSt11logic_errorD2Ev', 'type': 'FUNC'}
{'is_defined': False, 'name': '_ZNSt12length_errorD1Ev', 'type': 'FUNC'}
{'is_defined': False, 'name': '_ZNSt12out_of_rangeD1Ev', 'type': 'FUNC'}
@@ -1159,6 +1158,7 @@
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD0Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD1Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD2Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNKSt3__117bad_function_call4whatEv', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__117iostream_categoryEv', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb1EE4initEPKc', 'type': 'FUNC'}

View File

@@ -1,6 +1,5 @@
{'is_defined': False, 'name': '_ZNKSt11logic_error4whatEv', 'type': 'FUNC'}
{'is_defined': False, 'name': '_ZNKSt13runtime_error4whatEv', 'type': 'FUNC'}
{'is_defined': False, 'name': '_ZNKSt9exception4whatEv', 'type': 'FUNC'}
{'is_defined': False, 'name': '_ZNSt11logic_errorD2Ev', 'type': 'FUNC'}
{'is_defined': False, 'name': '_ZNSt12length_errorD1Ev', 'type': 'FUNC'}
{'is_defined': False, 'name': '_ZNSt12out_of_rangeD1Ev', 'type': 'FUNC'}
@@ -1157,6 +1156,7 @@
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD0Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD1Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD2Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNKSt3__117bad_function_call4whatEv', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__117iostream_categoryEv', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb1EE4initEPKc', 'type': 'FUNC'}

View File

@@ -1,6 +1,5 @@
{'is_defined': False, 'name': '_ZNKSt11logic_error4whatEv', 'type': 'FUNC'}
{'is_defined': False, 'name': '_ZNKSt13runtime_error4whatEv', 'type': 'FUNC'}
{'is_defined': False, 'name': '_ZNKSt9exception4whatEv', 'type': 'FUNC'}
{'is_defined': False, 'name': '_ZNSt11logic_errorD2Ev', 'type': 'FUNC'}
{'is_defined': False, 'name': '_ZNSt13runtime_errorD2Ev', 'type': 'FUNC'}
{'is_defined': False, 'name': '_ZNSt8bad_castD2Ev', 'type': 'FUNC'}
@@ -1128,6 +1127,7 @@
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD0Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD1Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__117bad_function_callD2Ev', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNKSt3__117bad_function_call4whatEv', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__117iostream_categoryEv', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb0EE4initEPKc', 'type': 'FUNC'}
{'is_defined': True, 'name': '_ZNSt3__117moneypunct_bynameIcLb1EE4initEPKc', 'type': 'FUNC'}

View File

@@ -12,9 +12,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD
bad_function_call::~bad_function_call() noexcept {}
#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
const char* bad_function_call::what() const noexcept { return "std::bad_function_call"; }
#endif
size_t __hash_memory(_LIBCPP_NOESCAPE const void* ptr, size_t size) noexcept {
return __murmur2_or_cityhash<size_t>()(ptr, size);