pw_libcxx: Actually implement operator delete

These should be able to call free now that we added them to llvm-libc.

Change-Id: Ie87bcf7176eef1c528dd94f40469a23b3f3e553c
Original-Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/223692
Original-Reviewed-by: Armando Montanez <amontanez@google.com>
Original-Reviewed-by: Petr Hosek <phosek@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/llvm-integration/+/235149
Reviewed-by: Armando Montanez <amontanez@google.com>
Commit-Queue: Prabhu Karthikeyan Rajasekaran <prabhukr@google.com>
diff --git a/pw_libcxx/operator_delete.cc b/pw_libcxx/operator_delete.cc
index e625fd0..e661812 100644
--- a/pw_libcxx/operator_delete.cc
+++ b/pw_libcxx/operator_delete.cc
@@ -12,26 +12,21 @@
 // License for the specific language governing permissions and limitations under
 // the License.
 
+#include <cstdlib>
 #include <new>
 
-// fxbug.dev/42082880: We should look into compiler changes to avoid emitting
-// references to these symbols.
-// These operator delete implementations are provided to satisfy references from
-// the vtable for the deleting destructor. In practice, these will never be
-// reached because users should not be using new/delete.
+void operator delete(void* ptr) noexcept { free(ptr); }
+void operator delete[](void* ptr) noexcept { free(ptr); }
 
-void operator delete(void*) noexcept { __builtin_trap(); }
-void operator delete[](void*) noexcept { __builtin_trap(); }
+void operator delete(void* ptr, std::align_val_t) noexcept { free(ptr); }
+void operator delete[](void* ptr, std::align_val_t) noexcept { free(ptr); }
 
-void operator delete(void*, std::align_val_t) noexcept { __builtin_trap(); }
-void operator delete[](void*, std::align_val_t) noexcept { __builtin_trap(); }
+void operator delete(void* ptr, std::size_t) noexcept { free(ptr); }
+void operator delete[](void* ptr, std::size_t) noexcept { free(ptr); }
 
-void operator delete(void*, std::size_t) noexcept { __builtin_trap(); }
-void operator delete[](void*, std::size_t) noexcept { __builtin_trap(); }
-
-void operator delete(void*, std::size_t, std::align_val_t) noexcept {
-  __builtin_trap();
+void operator delete(void* ptr, std::size_t, std::align_val_t) noexcept {
+  free(ptr);
 }
-void operator delete[](void*, std::size_t, std::align_val_t) noexcept {
-  __builtin_trap();
+void operator delete[](void* ptr, std::size_t, std::align_val_t) noexcept {
+  free(ptr);
 }