Cleanup new/delete definitions

This patch cleans up how libc++abi handles the definitions for new/delete.
It is in preperation for upcoming changes to fix how both libc++ and libc++abi
handle new/delete.

The primary changes in this patch are:

* Move the definitions for bad_array_length and bad_new_array_length
  into stdlib_exception.cpp. This way stdlib_new_delete.cpp only
  contains new/delete.

* Rename cxa_new_delete.cpp -> stdlib_new_delete.cpp for consistency
  with other files.

* Add a FIXME regarding when stdlib_new_delete.cpp is actually compiled
  as part of the dylib.

git-svn-id: https://llvm.org/svn/llvm-project/libcxxabi/trunk@296715 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ed7e39e..8eb28d4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -7,7 +7,6 @@
   cxa_exception_storage.cpp
   cxa_guard.cpp
   cxa_handlers.cpp
-  cxa_new_delete.cpp
   cxa_unexpected.cpp
   cxa_vector.cpp
   cxa_virtual.cpp
@@ -21,6 +20,11 @@
   private_typeinfo.cpp
 )
 
+# FIXME: This file should only be compiled in special configurations such
+#  as building the Apple system dylib where libc++abi is expected to provide
+#  the new/delete definitions instead of libc++.
+list(APPEND LIBCXXABI_SOURCES stdlib_new_delete.cpp)
+
 if (LIBCXXABI_ENABLE_EXCEPTIONS)
   list(APPEND LIBCXXABI_SOURCES cxa_exception.cpp)
   list(APPEND LIBCXXABI_SOURCES cxa_personality.cpp)
diff --git a/src/stdlib_exception.cpp b/src/stdlib_exception.cpp
index fce6e8a..a8f71ab 100644
--- a/src/stdlib_exception.cpp
+++ b/src/stdlib_exception.cpp
@@ -7,6 +7,9 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define _LIBCPP_BUILDING_LIBRARY
+#define _LIBCPP_BUILDING_NEW
+#include <new>
 #include <exception>
 
 namespace std
@@ -34,4 +37,67 @@
   return "std::bad_exception";
 }
 
+
+//  bad_alloc
+
+bad_alloc::bad_alloc() _NOEXCEPT
+{
+}
+
+bad_alloc::~bad_alloc() _NOEXCEPT
+{
+}
+
+const char*
+bad_alloc::what() const _NOEXCEPT
+{
+    return "std::bad_alloc";
+}
+
+// bad_array_new_length
+
+bad_array_new_length::bad_array_new_length() _NOEXCEPT
+{
+}
+
+bad_array_new_length::~bad_array_new_length() _NOEXCEPT
+{
+}
+
+const char*
+bad_array_new_length::what() const _NOEXCEPT
+{
+    return "bad_array_new_length";
+}
+
+// bad_array_length
+
+#ifndef _LIBCPP_BAD_ARRAY_LENGTH_DEFINED
+
+class _LIBCPP_EXCEPTION_ABI bad_array_length
+    : public bad_alloc
+{
+public:
+    bad_array_length() _NOEXCEPT;
+    virtual ~bad_array_length() _NOEXCEPT;
+    virtual const char* what() const _NOEXCEPT;
+};
+
+#endif  // _LIBCPP_BAD_ARRAY_LENGTH_DEFINED
+
+bad_array_length::bad_array_length() _NOEXCEPT
+{
+}
+
+bad_array_length::~bad_array_length() _NOEXCEPT
+{
+}
+
+const char*
+bad_array_length::what() const _NOEXCEPT
+{
+    return "bad_array_length";
+}
+
+
 }  // std
diff --git a/src/cxa_new_delete.cpp b/src/stdlib_new_delete.cpp
similarity index 79%
rename from src/cxa_new_delete.cpp
rename to src/stdlib_new_delete.cpp
index a96b97a..45c6b17 100644
--- a/src/cxa_new_delete.cpp
+++ b/src/stdlib_new_delete.cpp
@@ -176,69 +176,3 @@
 {
     ::operator delete[](ptr);
 }
-
-namespace std
-{
-
-//  bad_alloc
-
-bad_alloc::bad_alloc() _NOEXCEPT
-{
-}
-
-bad_alloc::~bad_alloc() _NOEXCEPT
-{
-}
-
-const char*
-bad_alloc::what() const _NOEXCEPT
-{
-    return "std::bad_alloc";
-}
-
-// bad_array_new_length
-
-bad_array_new_length::bad_array_new_length() _NOEXCEPT
-{
-}
-
-bad_array_new_length::~bad_array_new_length() _NOEXCEPT
-{
-}
-
-const char*
-bad_array_new_length::what() const _NOEXCEPT
-{
-    return "bad_array_new_length";
-}
-
-// bad_array_length
-
-#ifndef _LIBCPP_BAD_ARRAY_LENGTH_DEFINED
-
-class _LIBCPP_EXCEPTION_ABI bad_array_length
-    : public bad_alloc
-{
-public:
-    bad_array_length() _NOEXCEPT;
-    virtual ~bad_array_length() _NOEXCEPT;
-    virtual const char* what() const _NOEXCEPT;
-};
-
-#endif  // _LIBCPP_BAD_ARRAY_LENGTH_DEFINED
-
-bad_array_length::bad_array_length() _NOEXCEPT
-{
-}
-
-bad_array_length::~bad_array_length() _NOEXCEPT
-{
-}
-
-const char*
-bad_array_length::what() const _NOEXCEPT
-{
-    return "bad_array_length";
-}
-
-}  // std