[libcxx-commits] [libcxxabi] [libc++abi][NFC] Use C++11 spelling of [[noreturn]] (PR #207344)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Jul 3 01:05:16 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- libcxxabi/include/cxxabi.h libcxxabi/src/abort_message.h libcxxabi/src/cxa_aux_runtime.cpp libcxxabi/src/cxa_default_handlers.cpp libcxxabi/src/cxa_exception.cpp libcxxabi/src/cxa_handlers.cpp libcxxabi/src/cxa_handlers.h libcxxabi/src/cxa_personality.cpp libcxxabi/src/cxa_vector.cpp libcxxabi/src/cxa_virtual.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxxabi/include/cxxabi.h b/libcxxabi/include/cxxabi.h
index c65e353d6..5cb72f6d1 100644
--- a/libcxxabi/include/cxxabi.h
+++ b/libcxxabi/include/cxxabi.h
@@ -55,13 +55,12 @@ __cxa_init_primary_exception(void* object, std::type_info* tinfo, void(_LIBCXXAB
 #endif
 
 // 2.4.3 Throwing the Exception Object
-[[__noreturn__]] extern _LIBCXXABI_FUNC_VIS void
-__cxa_throw(void *thrown_exception, std::type_info *tinfo,
-#ifdef __wasm__
-            void *(_LIBCXXABI_DTOR_FUNC *dest)(void *));
-#else
-            void (_LIBCXXABI_DTOR_FUNC *dest)(void *));
-#endif
+[[__noreturn__]] extern _LIBCXXABI_FUNC_VIS void __cxa_throw(void* thrown_exception, std::type_info* tinfo,
+#  ifdef __wasm__
+                                                             void*(_LIBCXXABI_DTOR_FUNC* dest)(void*));
+#  else
+                                                             void(_LIBCXXABI_DTOR_FUNC* dest)(void*));
+#  endif
 
 // 2.5.3 Exception Handlers
 extern _LIBCXXABI_FUNC_VIS void *
@@ -87,8 +86,7 @@ extern _LIBCXXABI_FUNC_VIS std::type_info *__cxa_current_exception_type();
 // 2.6 Auxiliary Runtime APIs
 [[__noreturn__]] extern _LIBCXXABI_FUNC_VIS void __cxa_bad_cast(void);
 [[__noreturn__]] extern _LIBCXXABI_FUNC_VIS void __cxa_bad_typeid(void);
-[[__noreturn__]] extern _LIBCXXABI_FUNC_VIS void
-__cxa_throw_bad_array_new_length(void);
+[[__noreturn__]] extern _LIBCXXABI_FUNC_VIS void __cxa_throw_bad_array_new_length(void);
 
 // 3.2.6 Pure Virtual Function API
 [[__noreturn__]] extern _LIBCXXABI_FUNC_VIS void __cxa_pure_virtual(void);
diff --git a/libcxxabi/src/abort_message.h b/libcxxabi/src/abort_message.h
index 885dd3837..f52ae0082 100644
--- a/libcxxabi/src/abort_message.h
+++ b/libcxxabi/src/abort_message.h
@@ -11,8 +11,8 @@
 
 #include "cxxabi.h"
 
-extern "C" [[noreturn]] _LIBCXXABI_HIDDEN void
-__abort_message(const char *format, ...) __attribute__((format(printf, 1, 2)));
+extern "C" [[noreturn]] _LIBCXXABI_HIDDEN void __abort_message(const char* format, ...)
+    __attribute__((format(printf, 1, 2)));
 
 #ifndef _LIBCXXABI_ASSERT
 #  define _LIBCXXABI_ASSERT(expr, msg)                                                                                 \
diff --git a/libcxxabi/src/cxa_aux_runtime.cpp b/libcxxabi/src/cxa_aux_runtime.cpp
index e6bac221d..92b8b4cb7 100644
--- a/libcxxabi/src/cxa_aux_runtime.cpp
+++ b/libcxxabi/src/cxa_aux_runtime.cpp
@@ -32,8 +32,7 @@ extern "C" {
 #endif
 }
 
-[[noreturn]] _LIBCXXABI_FUNC_VIS void
-__cxa_throw_bad_array_new_length(void) {
+[[noreturn]] _LIBCXXABI_FUNC_VIS void __cxa_throw_bad_array_new_length(void) {
 #ifndef _LIBCXXABI_NO_EXCEPTIONS
   throw std::bad_array_new_length();
 #else
diff --git a/libcxxabi/src/cxa_default_handlers.cpp b/libcxxabi/src/cxa_default_handlers.cpp
index 5daf78b34..9bfd79926 100644
--- a/libcxxabi/src/cxa_default_handlers.cpp
+++ b/libcxxabi/src/cxa_default_handlers.cpp
@@ -24,70 +24,60 @@
 static constinit const char* cause = "uncaught";
 
 #  ifndef _LIBCXXABI_NO_EXCEPTIONS
-[[noreturn]] static void demangling_terminate_handler()
-{
-    using namespace __cxxabiv1;
-    __cxa_eh_globals* globals = __cxa_get_globals_fast();
+[[noreturn]] static void demangling_terminate_handler() {
+  using namespace __cxxabiv1;
+  __cxa_eh_globals* globals = __cxa_get_globals_fast();
 
-    // If there is no uncaught exception, just note that we're terminating
-    if (!globals)
-        __abort_message("terminating");
+  // If there is no uncaught exception, just note that we're terminating
+  if (!globals)
+    __abort_message("terminating");
 
-    __cxa_exception* exception_header = globals->caughtExceptions;
-    if (!exception_header)
-        __abort_message("terminating");
+  __cxa_exception* exception_header = globals->caughtExceptions;
+  if (!exception_header)
+    __abort_message("terminating");
 
-    _Unwind_Exception* unwind_exception =
-        reinterpret_cast<_Unwind_Exception*>(exception_header + 1) - 1;
+  _Unwind_Exception* unwind_exception = reinterpret_cast<_Unwind_Exception*>(exception_header + 1) - 1;
 
-    // If we're terminating due to a foreign exception
-    if (!__isOurExceptionClass(unwind_exception))
-        __abort_message("terminating due to %s foreign exception", cause);
+  // If we're terminating due to a foreign exception
+  if (!__isOurExceptionClass(unwind_exception))
+    __abort_message("terminating due to %s foreign exception", cause);
 
-    void* thrown_object =
-        __getExceptionClass(unwind_exception) == kOurDependentExceptionClass ?
-            ((__cxa_dependent_exception*)exception_header)->primaryException :
-            exception_header + 1;
-    const __shim_type_info* thrown_type =
-        static_cast<const __shim_type_info*>(exception_header->exceptionType);
+  void* thrown_object = __getExceptionClass(unwind_exception) == kOurDependentExceptionClass
+                            ? ((__cxa_dependent_exception*)exception_header)->primaryException
+                            : exception_header + 1;
+  const __shim_type_info* thrown_type = static_cast<const __shim_type_info*>(exception_header->exceptionType);
 
-    auto name = [str = thrown_type->name()] {
+  auto name = [str = thrown_type->name()] {
 #    ifndef LIBCXXABI_NON_DEMANGLING_TERMINATE
-      if (const char* result = __cxxabiv1::__cxa_demangle(str, nullptr, nullptr, nullptr))
-        // We're about to abort(), this memory can never be freed; so it's fine
-        // to just return a raw pointer
-        return result;
+    if (const char* result = __cxxabiv1::__cxa_demangle(str, nullptr, nullptr, nullptr))
+      // We're about to abort(), this memory can never be freed; so it's fine
+      // to just return a raw pointer
+      return result;
 #    endif
-      return str;
-    }();
-
-    // If the uncaught exception can be caught with std::exception&
-    const __shim_type_info* catch_type =
-        static_cast<const __shim_type_info*>(&typeid(std::exception));
-    if (catch_type->can_catch(thrown_type, thrown_object))
-    {
-        // Include the what() message from the exception
-        const std::exception* e = static_cast<const std::exception*>(thrown_object);
-        __abort_message("terminating due to %s exception of type %s: %s", cause, name, e->what());
-    }
-    else
-    {
-        // Else just note that we're terminating due to an exception
-        __abort_message("terminating due to %s exception of type %s", cause, name);
-    }
+    return str;
+  }();
+
+  // If the uncaught exception can be caught with std::exception&
+  const __shim_type_info* catch_type = static_cast<const __shim_type_info*>(&typeid(std::exception));
+  if (catch_type->can_catch(thrown_type, thrown_object)) {
+    // Include the what() message from the exception
+    const std::exception* e = static_cast<const std::exception*>(thrown_object);
+    __abort_message("terminating due to %s exception of type %s: %s", cause, name, e->what());
+  } else {
+    // Else just note that we're terminating due to an exception
+    __abort_message("terminating due to %s exception of type %s", cause, name);
+  }
 }
-#else // !_LIBCXXABI_NO_EXCEPTIONS
-[[noreturn]] static void demangling_terminate_handler()
-{
-    (void)cause;
-    __abort_message("terminating");
+#  else  // !_LIBCXXABI_NO_EXCEPTIONS
+[[noreturn]] static void demangling_terminate_handler() {
+  (void)cause;
+  __abort_message("terminating");
 }
-#endif // !_LIBCXXABI_NO_EXCEPTIONS
+#  endif // !_LIBCXXABI_NO_EXCEPTIONS
 
-[[noreturn]] static void demangling_unexpected_handler()
-{
-    cause = "unexpected";
-    std::terminate();
+[[noreturn]] static void demangling_unexpected_handler() {
+  cause = "unexpected";
+  std::terminate();
 }
 
 static constexpr std::terminate_handler default_terminate_handler = demangling_terminate_handler;
diff --git a/libcxxabi/src/cxa_exception.cpp b/libcxxabi/src/cxa_exception.cpp
index f56ecc248..f8e597315 100644
--- a/libcxxabi/src/cxa_exception.cpp
+++ b/libcxxabi/src/cxa_exception.cpp
@@ -141,15 +141,15 @@ exception_cleanup_func(_Unwind_Reason_Code reason, _Unwind_Exception* unwind_exc
 }
 
 [[noreturn]] static void failed_throw(__cxa_exception* exception_header) {
-//  Section 2.5.3 says:
-//      * For purposes of this ABI, several things are considered exception handlers:
-//      ** A terminate() call due to a throw.
-//  and
-//      * Upon entry, Following initialization of the catch parameter,
-//          a handler must call:
-//      * void *__cxa_begin_catch(void *exceptionObject );
-    (void) __cxa_begin_catch(&exception_header->unwindHeader);
-    std::__terminate(exception_header->terminateHandler);
+  //  Section 2.5.3 says:
+  //      * For purposes of this ABI, several things are considered exception handlers:
+  //      ** A terminate() call due to a throw.
+  //  and
+  //      * Upon entry, Following initialization of the catch parameter,
+  //          a handler must call:
+  //      * void *__cxa_begin_catch(void *exceptionObject );
+  (void)__cxa_begin_catch(&exception_header->unwindHeader);
+  std::__terminate(exception_header->terminateHandler);
 }
 
 // Return the offset of the __cxa_exception header from the start of the
diff --git a/libcxxabi/src/cxa_handlers.cpp b/libcxxabi/src/cxa_handlers.cpp
index 0abdc7404..921898165 100644
--- a/libcxxabi/src/cxa_handlers.cpp
+++ b/libcxxabi/src/cxa_handlers.cpp
@@ -36,11 +36,7 @@ __unexpected(unexpected_handler func)
     __abort_message("unexpected_handler unexpectedly returned");
 }
 
-[[noreturn]] void
-unexpected()
-{
-    __unexpected(get_unexpected());
-}
+[[noreturn]] void unexpected() { __unexpected(get_unexpected()); }
 
 terminate_handler
 get_terminate() noexcept
@@ -68,9 +64,7 @@ __terminate(terminate_handler func) noexcept
 #endif // _LIBCXXABI_NO_EXCEPTIONS
 }
 
-[[noreturn]] void
-terminate() noexcept
-{
+[[noreturn]] void terminate() noexcept {
 #ifndef _LIBCXXABI_NO_EXCEPTIONS
     // If there might be an uncaught exception
     using namespace __cxxabiv1;
diff --git a/libcxxabi/src/cxa_handlers.h b/libcxxabi/src/cxa_handlers.h
index 072b85ed8..e97b33da8 100644
--- a/libcxxabi/src/cxa_handlers.h
+++ b/libcxxabi/src/cxa_handlers.h
@@ -19,13 +19,9 @@
 namespace std
 {
 
-[[noreturn]] _LIBCXXABI_HIDDEN
-void
-__unexpected(unexpected_handler func);
+[[noreturn]] _LIBCXXABI_HIDDEN void __unexpected(unexpected_handler func);
 
-[[noreturn]] _LIBCXXABI_HIDDEN
-void
-__terminate(terminate_handler func) noexcept;
+[[noreturn]] _LIBCXXABI_HIDDEN void __terminate(terminate_handler func) noexcept;
 
 }  // std
 
diff --git a/libcxxabi/src/cxa_personality.cpp b/libcxxabi/src/cxa_personality.cpp
index c5050e46c..5a3a0adf8 100644
--- a/libcxxabi/src/cxa_personality.cpp
+++ b/libcxxabi/src/cxa_personality.cpp
@@ -1271,29 +1271,25 @@ __gxx_personality_v0(_Unwind_State state,
 }
 #endif
 
-
-[[noreturn]] _LIBCXXABI_FUNC_VIS void
-__cxa_call_unexpected(void* arg)
-{
-    _Unwind_Exception* unwind_exception = static_cast<_Unwind_Exception*>(arg);
-    if (unwind_exception == 0)
-        call_terminate(false, unwind_exception);
-    __cxa_begin_catch(unwind_exception);
-    bool native_old_exception = __isOurExceptionClass(unwind_exception);
-    std::unexpected_handler u_handler;
-    std::terminate_handler t_handler;
-    __cxa_exception* old_exception_header = 0;
-    int64_t ttypeIndex;
-    const uint8_t* lsda;
-    uintptr_t base = 0;
-
-    if (native_old_exception)
-    {
-        old_exception_header = (__cxa_exception*)(unwind_exception+1) - 1;
-        t_handler = old_exception_header->terminateHandler;
-        u_handler = old_exception_header->unexpectedHandler;
-        // If std::__unexpected(u_handler) rethrows the same exception,
-        //   these values get overwritten by the rethrow.  So save them now:
+[[noreturn]] _LIBCXXABI_FUNC_VIS void __cxa_call_unexpected(void* arg) {
+  _Unwind_Exception* unwind_exception = static_cast<_Unwind_Exception*>(arg);
+  if (unwind_exception == 0)
+    call_terminate(false, unwind_exception);
+  __cxa_begin_catch(unwind_exception);
+  bool native_old_exception = __isOurExceptionClass(unwind_exception);
+  std::unexpected_handler u_handler;
+  std::terminate_handler t_handler;
+  __cxa_exception* old_exception_header = 0;
+  int64_t ttypeIndex;
+  const uint8_t* lsda;
+  uintptr_t base = 0;
+
+  if (native_old_exception) {
+    old_exception_header = (__cxa_exception*)(unwind_exception + 1) - 1;
+    t_handler = old_exception_header->terminateHandler;
+    u_handler = old_exception_header->unexpectedHandler;
+    // If std::__unexpected(u_handler) rethrows the same exception,
+    //   these values get overwritten by the rethrow.  So save them now:
 #if defined(_LIBCXXABI_ARM_EHABI)
         ttypeIndex = (int64_t)(int32_t)unwind_exception->barrier_cache.bitpattern[4];
         lsda = (const uint8_t*)unwind_exception->barrier_cache.bitpattern[2];
diff --git a/libcxxabi/src/cxa_virtual.cpp b/libcxxabi/src/cxa_virtual.cpp
index 1d3f4c63c..375c22df4 100644
--- a/libcxxabi/src/cxa_virtual.cpp
+++ b/libcxxabi/src/cxa_virtual.cpp
@@ -11,13 +11,9 @@
 
 namespace __cxxabiv1 {
 extern "C" {
-[[noreturn]] _LIBCXXABI_FUNC_VIS
-void __cxa_pure_virtual(void) {
-  __abort_message("Pure virtual function called!");
-}
+[[noreturn]] _LIBCXXABI_FUNC_VIS void __cxa_pure_virtual(void) { __abort_message("Pure virtual function called!"); }
 
-[[noreturn]] _LIBCXXABI_FUNC_VIS
-void __cxa_deleted_virtual(void) {
+[[noreturn]] _LIBCXXABI_FUNC_VIS void __cxa_deleted_virtual(void) {
   __abort_message("Deleted virtual function called!");
 }
 } // extern "C"

``````````

</details>


https://github.com/llvm/llvm-project/pull/207344


More information about the libcxx-commits mailing list