[llvm-branch-commits] [libcxxabi] bc556e5 - [libc++/abi] Re-remove unnecessary null pointer checks from operator delete

Louis Dionne via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jan 8 14:08:52 PST 2021


Author: Louis Dionne
Date: 2021-01-08T17:03:50-05:00
New Revision: bc556e5685c0f97e79fb7b3c6f15cc5062db8e36

URL: https://github.com/llvm/llvm-project/commit/bc556e5685c0f97e79fb7b3c6f15cc5062db8e36
DIFF: https://github.com/llvm/llvm-project/commit/bc556e5685c0f97e79fb7b3c6f15cc5062db8e36.diff

LOG: [libc++/abi] Re-remove unnecessary null pointer checks from operator delete

In 7cd67904f776, we removed the unnecessary nullptr checks from the libc++abi
definition of operator delete, but we forgot to update the definition in
libc++ (damn code duplication!). Then, in d4a1e03c5fb5, I synced the
definitions across libc++ and libc++abi, but I did it the wrong way around.
I re-added the if() checks to libc++abi instead of removing them from libc++.

In ef74f0fdc339, we re-removed the if() check from operator delete, but
only in libc++abi. This patch corrects this mess and removes it
consistently in libc++ and libc++abi.

Differential Revision: https://reviews.llvm.org/D93473

Added: 
    

Modified: 
    libcxx/src/new.cpp
    libcxxabi/src/stdlib_new_delete.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/src/new.cpp b/libcxx/src/new.cpp
index 8bdaf13cf9532..9d01330ba7d5f 100644
--- a/libcxx/src/new.cpp
+++ b/libcxx/src/new.cpp
@@ -130,8 +130,7 @@ _LIBCPP_WEAK
 void
 operator delete(void* ptr) _NOEXCEPT
 {
-    if (ptr)
-        ::free(ptr);
+    ::free(ptr);
 }
 
 _LIBCPP_WEAK
@@ -252,9 +251,7 @@ _LIBCPP_WEAK
 void
 operator delete(void* ptr, std::align_val_t) _NOEXCEPT
 {
-    if (ptr) {
-        std::__libcpp_aligned_free(ptr);
-    }
+    std::__libcpp_aligned_free(ptr);
 }
 
 _LIBCPP_WEAK

diff  --git a/libcxxabi/src/stdlib_new_delete.cpp b/libcxxabi/src/stdlib_new_delete.cpp
index a3e028be0fd26..8ef3057dd45e4 100644
--- a/libcxxabi/src/stdlib_new_delete.cpp
+++ b/libcxxabi/src/stdlib_new_delete.cpp
@@ -214,9 +214,7 @@ _LIBCXXABI_WEAK
 void
 operator delete(void* ptr, std::align_val_t) _NOEXCEPT
 {
-    if (ptr) {
-        std::__libcpp_aligned_free(ptr);
-    }
+    std::__libcpp_aligned_free(ptr);
 }
 
 _LIBCXXABI_WEAK


        


More information about the llvm-branch-commits mailing list