[libcxx-commits] [libcxx] [libc++] Make bad_function_call::what() existance a matter of availability instead of ABI (PR #127697)
via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Feb 18 13:09:57 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libcxx
Author: Nikolas Klauser (philnik777)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/127697.diff
3 Files Affected:
- (modified) libcxx/include/__configuration/availability.h (+10)
- (modified) libcxx/include/__functional/function.h (+1-1)
- (modified) libcxx/src/functional.cpp (-2)
``````````diff
diff --git a/libcxx/include/__configuration/availability.h b/libcxx/include/__configuration/availability.h
index 261cf9c1ae9d8..bdb72d86c2603 100644
--- a/libcxx/include/__configuration/availability.h
+++ b/libcxx/include/__configuration/availability.h
@@ -78,6 +78,9 @@
// in all versions of the library are available.
#if !_LIBCPP_HAS_VENDOR_AVAILABILITY_ANNOTATIONS
+# define _LIBCPP_INTRODUCED_IN_LLVM_21 1
+# define _LIBCPP_INTRODUCED_IN_LLVM_21_ATTRIBUTE /* nothing */
+
# define _LIBCPP_INTRODUCED_IN_LLVM_20 1
# define _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE /* nothing */
@@ -114,6 +117,11 @@
// clang-format off
+// LLVM 21
+// TODO: Fill this in
+# define _LIBCPP_INTRODUCED_IN_LLVM_21 0
+# define _LIBCPP_INTRODUCED_IN_LLVM_21_ATTRIBUTE __attribute__((unavailable))
+
// LLVM 20
// TODO: Fill this in
# define _LIBCPP_INTRODUCED_IN_LLVM_20 0
@@ -359,6 +367,8 @@
#define _LIBCPP_AVAILABILITY_HAS_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20
#define _LIBCPP_AVAILABILITY_FROM_CHARS_FLOATING_POINT _LIBCPP_INTRODUCED_IN_LLVM_20_ATTRIBUTE
+#define _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE _LIBCPP_INTRODUCED_IN_LLVM_21
+
// 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.
diff --git a/libcxx/include/__functional/function.h b/libcxx/include/__functional/function.h
index 2a1293cfcc26b..cd77012173512 100644
--- a/libcxx/include/__functional/function.h
+++ b/libcxx/include/__functional/function.h
@@ -71,7 +71,7 @@ class _LIBCPP_EXPORTED_FROM_ABI bad_function_call : public exception {
_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
};
diff --git a/libcxx/src/functional.cpp b/libcxx/src/functional.cpp
index ef53e3e84da0e..f2c70fc54392d 100644
--- a/libcxx/src/functional.cpp
+++ b/libcxx/src/functional.cpp
@@ -12,8 +12,6 @@ _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
_LIBCPP_END_NAMESPACE_STD
``````````
</details>
https://github.com/llvm/llvm-project/pull/127697
More information about the libcxx-commits
mailing list