[libcxx] r284289 - Prevent new/delete replacement tests from being optimized away.

Eric Fiselier via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 14 15:47:08 PDT 2016


Author: ericwf
Date: Fri Oct 14 17:47:08 2016
New Revision: 284289

URL: http://llvm.org/viewvc/llvm-project?rev=284289&view=rev
Log:
Prevent new/delete replacement tests from being optimized away.

Modified:
    libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
    libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp
    libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp
    libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
    libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp
    libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_calls_unsized_delete.pass.cpp
    libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp

Modified: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp?rev=284289&r1=284288&r2=284289&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/delete_align_val_t_replace.pass.cpp Fri Oct 14 17:47:08 2016
@@ -15,10 +15,7 @@
 // XFAIL: clang-3, apple-clang
 
 // None of the current GCC compilers support this.
-// XFAIL: gcc-4, gcc-5, gcc-6
-
-// TODO Investigate why UBSAN prevents new from calling our replacement.
-// XFAIL: ubsan
+// XFAIL: gcc
 
 #include <new>
 #include <cstddef>
@@ -58,28 +55,31 @@ void operator delete [] (void* p, std::a
 struct alignas(OverAligned) A {};
 struct alignas(std::max_align_t) B {};
 
+B* volatile b; // Escape the memory
+A* volatile a;
+
 int main()
 {
     reset();
     {
-        B *x = new B[2];
+        b = new B[2];
         assert(0 == unsized_delete_called);
         assert(0 == unsized_delete_nothrow_called);
         assert(0 == aligned_delete_called);
 
-        delete [] x;
+        delete [] b;
         assert(1 == unsized_delete_called);
         assert(0 == unsized_delete_nothrow_called);
         assert(0 == aligned_delete_called);
     }
     reset();
     {
-        A *x = new A[2];
+        a = new A[2];
         assert(0 == unsized_delete_called);
         assert(0 == unsized_delete_nothrow_called);
         assert(0 == aligned_delete_called);
 
-        delete [] x;
+        delete [] a;
         assert(0 == unsized_delete_called);
         assert(0 == unsized_delete_nothrow_called);
         assert(1 == aligned_delete_called);

Modified: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp?rev=284289&r1=284288&r2=284289&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp Fri Oct 14 17:47:08 2016
@@ -11,10 +11,6 @@
 
 // UNSUPPORTED: sanitizer-new-delete
 
-// TODO Investigate why UBSAN prevents new from calling our replacement.
-// XFAIL: ubsan
-
-
 #include <new>
 #include <cstddef>
 #include <cstdlib>
@@ -45,9 +41,11 @@ struct A
     ~A() {--A_constructed;}
 };
 
+A* volatile ap;
+
 int main()
 {
-    A* ap = new (std::nothrow) A[3];
+    ap = new (std::nothrow) A[3];
     assert(ap);
     assert(A_constructed == 3);
     assert(new_called);

Modified: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp?rev=284289&r1=284288&r2=284289&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp Fri Oct 14 17:47:08 2016
@@ -11,9 +11,6 @@
 
 // UNSUPPORTED: sanitizer-new-delete
 
-// TODO Investigate why UBSAN prevents new from calling our replacement.
-// XFAIL: ubsan
-
 
 #include <new>
 #include <cstddef>
@@ -45,9 +42,11 @@ struct A
     ~A() {--A_constructed;}
 };
 
+A* volatile ap;
+
 int main()
 {
-    A* ap = new A[3];
+    ap = new A[3];
     assert(ap);
     assert(A_constructed == 3);
     assert(new_called == 1);

Modified: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp?rev=284289&r1=284288&r2=284289&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/delete_align_val_t_replace.pass.cpp Fri Oct 14 17:47:08 2016
@@ -15,10 +15,8 @@
 // XFAIL: clang-3, apple-clang
 
 // None of the current GCC compilers support this.
-// XFAIL: gcc-4, gcc-5, gcc-6
+// XFAIL: gcc
 
-// TODO Investigate why UBSAN prevents new from calling our replacement.
-// XFAIL: ubsan
 
 #include <new>
 #include <cstddef>
@@ -58,28 +56,31 @@ void operator delete(void* p, std::align
 struct alignas(OverAligned) A {};
 struct alignas(std::max_align_t) B {};
 
+B* volatile bp;
+A* volatile ap;
+
 int main()
 {
     reset();
     {
-        B *x = new B;
+        bp = new B;
         assert(0 == unsized_delete_called);
         assert(0 == unsized_delete_nothrow_called);
         assert(0 == aligned_delete_called);
 
-        delete x;
+        delete bp;
         assert(1 == unsized_delete_called);
         assert(0 == unsized_delete_nothrow_called);
         assert(0 == aligned_delete_called);
     }
     reset();
     {
-        A *x = new A;
+        ap = new A;
         assert(0 == unsized_delete_called);
         assert(0 == unsized_delete_nothrow_called);
         assert(0 == aligned_delete_called);
 
-        delete x;
+        delete ap;
         assert(0 == unsized_delete_called);
         assert(0 == unsized_delete_nothrow_called);
         assert(1 == aligned_delete_called);

Modified: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp?rev=284289&r1=284288&r2=284289&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp Fri Oct 14 17:47:08 2016
@@ -11,9 +11,6 @@
 
 // UNSUPPORTED: sanitizer-new-delete
 
-// TODO Investigate why UBSAN prevents nothrow new from calling our replacement.
-// XFAIL: ubsan
-
 #include <new>
 #include <cstddef>
 #include <cstdlib>
@@ -44,9 +41,11 @@ struct A
     ~A() {A_constructed = false;}
 };
 
+A* volatile ap;
+
 int main()
 {
-    A* ap = new (std::nothrow) A;
+    ap = new (std::nothrow) A;
     assert(ap);
     assert(A_constructed);
     assert(new_called);

Modified: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_calls_unsized_delete.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_calls_unsized_delete.pass.cpp?rev=284289&r1=284288&r2=284289&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_calls_unsized_delete.pass.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_calls_unsized_delete.pass.cpp Fri Oct 14 17:47:08 2016
@@ -13,10 +13,6 @@
 
 // UNSUPPORTED: sanitizer-new-delete
 
-// TODO Investigate why UBSAN prevents new from calling our replacement.
-// XFAIL: ubsan
-
-
 #include <new>
 #include <cstddef>
 #include <cstdlib>
@@ -37,9 +33,11 @@ void operator delete(void* p, const std:
     std::free(p);
 }
 
+int* volatile x;
+
 int main()
 {
-    int *x = new int(42);
+    x = new int(42);
     assert(0 == delete_called);
     assert(0 == delete_nothrow_called);
 

Modified: libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp?rev=284289&r1=284288&r2=284289&view=diff
==============================================================================
--- libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp (original)
+++ libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete_fsizeddeallocation.sh.cpp Fri Oct 14 17:47:08 2016
@@ -14,9 +14,6 @@
 
 // UNSUPPORTED: sanitizer-new-delete
 
-// TODO Investigate why UBSAN prevents new from calling our replacement.
-// XFAIL: ubsan
-
 // NOTE: Only clang-3.7 and GCC 5.1 and greater support -fsized-deallocation.
 // REQUIRES: fsized-deallocation
 
@@ -58,9 +55,11 @@ void operator delete(void* p, std::size_
     std::free(p);
 }
 
+int* volatile x;
+
 int main()
 {
-    int *x = new int(42);
+    x = new int(42);
     assert(0 == sized_delete_called);
     assert(0 == unsized_delete_called);
     assert(0 == unsized_delete_nothrow_called);




More information about the cfe-commits mailing list