[libcxx-commits] [PATCH] D153136: [libc++] Move non operator new definitions outside of new.cpp

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jun 19 06:47:10 PDT 2023


This revision was automatically updated to reflect the committed changes.
Closed by commit rG3956a34e4fc6: [libc++] Move non operator new definitions outside of new.cpp (authored by ldionne).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153136/new/

https://reviews.llvm.org/D153136

Files:
  libcxx/src/CMakeLists.txt
  libcxx/src/new.cpp
  libcxx/src/new_helpers.cpp


Index: libcxx/src/new_helpers.cpp
===================================================================
--- /dev/null
+++ libcxx/src/new_helpers.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <cstdlib>
+#include <new>
+
+namespace std { // purposefully not versioned
+
+#ifndef __GLIBCXX__
+const nothrow_t nothrow{};
+#endif
+
+#ifndef LIBSTDCXX
+
+void __throw_bad_alloc() {
+#  ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+  throw bad_alloc();
+#  else
+  std::abort();
+#  endif
+}
+
+#endif // !LIBSTDCXX
+
+} // namespace std
Index: libcxx/src/new.cpp
===================================================================
--- libcxx/src/new.cpp
+++ libcxx/src/new.cpp
@@ -10,29 +10,6 @@
 #include <cstdlib>
 #include <new>
 
-namespace std
-{
-
-#ifndef __GLIBCXX__
-const nothrow_t nothrow{};
-#endif
-
-#ifndef LIBSTDCXX
-
-void
-__throw_bad_alloc()
-{
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
-    throw bad_alloc();
-#else
-    _VSTD::abort();
-#endif
-}
-
-#endif // !LIBSTDCXX
-
-}  // std
-
 #if !defined(__GLIBCXX__) &&                                                   \
     !defined(_LIBCPP_ABI_VCRUNTIME) &&      \
     !defined(_LIBCPP_DISABLE_NEW_DELETE_DEFINITIONS)
Index: libcxx/src/CMakeLists.txt
===================================================================
--- libcxx/src/CMakeLists.txt
+++ libcxx/src/CMakeLists.txt
@@ -36,6 +36,7 @@
   mutex_destructor.cpp
   new.cpp
   new_handler.cpp
+  new_helpers.cpp
   optional.cpp
   random_shuffle.cpp
   ryu/d2fixed.cpp


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153136.532636.patch
Type: text/x-patch
Size: 1837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230619/4fa7b2d1/attachment.bin>


More information about the libcxx-commits mailing list