[libcxx-commits] [libcxx] [libc++] Fix missing 'get_new_handler()' for Windows builds (PR #150182)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Dec 12 22:48:01 PST 2025
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 h,cpp -- libcxx/include/__new/global_new_delete.h libcxx/include/__new/new_handler.h libcxx/include/__new/nothrow_t.h libcxx/include/__new/placement_new_delete.h libcxx/src/new_handler.cpp libcxx/test/std/language.support/support.dynamic/alloc.errors/set.new.handler/get_new_handler.pass.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/libcxx/include/__new/global_new_delete.h b/libcxx/include/__new/global_new_delete.h
index 4720a7d71..fe509d101 100644
--- a/libcxx/include/__new/global_new_delete.h
+++ b/libcxx/include/__new/global_new_delete.h
@@ -32,7 +32,7 @@
#endif
#if defined(_LIBCPP_ABI_VCRUNTIME)
-#include <vcruntime_new.h>
+# include <vcruntime_new.h>
#else
[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz) _THROW_BAD_ALLOC;
[[__nodiscard__]] _LIBCPP_OVERRIDABLE_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT
diff --git a/libcxx/include/__new/nothrow_t.h b/libcxx/include/__new/nothrow_t.h
index 2b4d9d2f1..7d9e73648 100644
--- a/libcxx/include/__new/nothrow_t.h
+++ b/libcxx/include/__new/nothrow_t.h
@@ -16,7 +16,7 @@
#endif
#if defined(_LIBCPP_ABI_VCRUNTIME)
-#include <vcruntime_new.h>
+# include <vcruntime_new.h>
#else
_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
struct nothrow_t {
diff --git a/libcxx/include/__new/placement_new_delete.h b/libcxx/include/__new/placement_new_delete.h
index 9fefb1782..f0bb2fd31 100644
--- a/libcxx/include/__new/placement_new_delete.h
+++ b/libcxx/include/__new/placement_new_delete.h
@@ -17,7 +17,7 @@
#endif
#if defined(_LIBCPP_ABI_VCRUNTIME)
-#include <vcruntime_new.h>
+# include <vcruntime_new.h>
#else
[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void*
operator new(std::size_t, void* __p) _NOEXCEPT {
diff --git a/libcxx/src/new_handler.cpp b/libcxx/src/new_handler.cpp
index b773e733d..aeab6946a 100644
--- a/libcxx/src/new_handler.cpp
+++ b/libcxx/src/new_handler.cpp
@@ -26,33 +26,33 @@
static constinit std::new_handler __new_handler = nullptr;
-#ifdef _LIBCPP_ABI_VCRUNTIME
+# ifdef _LIBCPP_ABI_VCRUNTIME
// to avoid including <new.h>
using _new_h = int(__cdecl*)(size_t);
extern "C" _new_h __cdecl _set_new_handler(_new_h);
namespace {
- // adapter for _callnewh
- int __cdecl _new_handler_adapter(size_t) {
- std::__libcpp_atomic_load(&__new_handler)();
- return 1;
- }
+// adapter for _callnewh
+int __cdecl _new_handler_adapter(size_t) {
+ std::__libcpp_atomic_load (&__new_handler)();
+ return 1;
}
-#endif
+} // namespace
+# endif
namespace std { // purposefully not versioned
new_handler set_new_handler(new_handler handler) noexcept {
-#ifdef _LIBCPP_ABI_VCRUNTIME
- auto old = __libcpp_atomic_exchange(&__new_handler, handler);
- _set_new_handler(handler ? _new_handler_adapter: nullptr);
- return old;
-#else
- return __libcpp_atomic_exchange(&__new_handler, handler);
-#endif
+# ifdef _LIBCPP_ABI_VCRUNTIME
+ auto old = __libcpp_atomic_exchange(&__new_handler, handler);
+ _set_new_handler(handler ? _new_handler_adapter : nullptr);
+ return old;
+# else
+ return __libcpp_atomic_exchange(&__new_handler, handler);
+# endif
}
-new_handler get_new_handler() noexcept {return __libcpp_atomic_load(&__new_handler);}
+new_handler get_new_handler() noexcept { return __libcpp_atomic_load(&__new_handler); }
} // namespace std
``````````
</details>
https://github.com/llvm/llvm-project/pull/150182
More information about the libcxx-commits
mailing list