[libcxx-commits] [libcxx] c3598b1 - [libc++] Improve libc++ tests when using optimizations (#88897)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Apr 29 11:33:29 PDT 2024
Author: Jack Styles
Date: 2024-04-29T12:33:25-06:00
New Revision: c3598b161a4d868b1cd10a7ee7ac37d68e5a36fe
URL: https://github.com/llvm/llvm-project/commit/c3598b161a4d868b1cd10a7ee7ac37d68e5a36fe
DIFF: https://github.com/llvm/llvm-project/commit/c3598b161a4d868b1cd10a7ee7ac37d68e5a36fe.diff
LOG: [libc++] Improve libc++ tests when using optimizations (#88897)
Some tests were missing DoNotOptimize annotations.
Added:
Modified:
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.indirect.pass.cpp
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.pass.cpp
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align_nothrow.replace.indirect.pass.cpp
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align.replace.pass.cpp
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.indirect.pass.cpp
libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.indirect.pass.cpp b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.indirect.pass.cpp
index 0b540e09bab3cc..3d9856e0b1ba42 100644
--- a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.indirect.pass.cpp
+++ b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.indirect.pass.cpp
@@ -51,11 +51,12 @@ int main(int, char**) {
// Test with an overaligned type
{
new_called = delete_called = 0;
- OverAligned* x = DoNotOptimize(new OverAligned[3]);
+ OverAligned* dummy_data_block = new OverAligned[3];
+ OverAligned* x = DoNotOptimize(dummy_data_block);
ASSERT_WITH_OPERATOR_NEW_FALLBACKS(static_cast<void*>(x) == DummyData);
ASSERT_WITH_OPERATOR_NEW_FALLBACKS(new_called == 1);
- delete[] x;
+ delete[] dummy_data_block;
ASSERT_WITH_OPERATOR_NEW_FALLBACKS(delete_called == 1);
}
diff --git a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.pass.cpp b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.pass.cpp
index 2d021ecb30e793..73d1054df188e4 100644
--- a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.pass.cpp
+++ b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align.replace.pass.cpp
@@ -48,11 +48,12 @@ int main(int, char**) {
// Test with an overaligned type
{
new_called = delete_called = 0;
- OverAligned* x = new OverAligned[3];
+ OverAligned* dummy_data_block = new OverAligned[3];
+ OverAligned* x = DoNotOptimize(dummy_data_block);
assert(static_cast<void*>(x) == DummyData);
assert(new_called == 1);
- delete[] x;
+ delete[] dummy_data_block;
assert(delete_called == 1);
}
diff --git a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align_nothrow.replace.indirect.pass.cpp b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align_nothrow.replace.indirect.pass.cpp
index 227b20f0b1e18b..c9dc20a34b13ca 100644
--- a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align_nothrow.replace.indirect.pass.cpp
+++ b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new.size_align_nothrow.replace.indirect.pass.cpp
@@ -55,11 +55,12 @@ int main(int, char**) {
// Test with an overaligned type
{
new_called = delete_called = 0;
- OverAligned* x = DoNotOptimize(new (std::nothrow) OverAligned[3]);
+ OverAligned* dummy_data_block = new (std::nothrow) OverAligned[3];
+ OverAligned* x = DoNotOptimize(dummy_data_block);
ASSERT_WITH_OPERATOR_NEW_FALLBACKS(static_cast<void*>(x) == DummyData);
ASSERT_WITH_OPERATOR_NEW_FALLBACKS(new_called == 1);
- delete[] x;
+ delete[] dummy_data_block;
ASSERT_WITH_OPERATOR_NEW_FALLBACKS(delete_called == 1);
}
diff --git a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align.replace.pass.cpp b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align.replace.pass.cpp
index e5ef5f1669752b..f9e339b221906e 100644
--- a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align.replace.pass.cpp
+++ b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align.replace.pass.cpp
@@ -48,11 +48,12 @@ int main(int, char**) {
// Test with an overaligned type
{
new_called = delete_called = 0;
- OverAligned* x = new OverAligned;
+ OverAligned* dummy_data_block = new OverAligned;
+ OverAligned* x = DoNotOptimize(dummy_data_block);
assert(static_cast<void*>(x) == DummyData);
assert(new_called == 1);
- delete x;
+ delete dummy_data_block;
assert(delete_called == 1);
}
diff --git a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.indirect.pass.cpp b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.indirect.pass.cpp
index 7eab0729f9ef1a..dedd3089f5abdc 100644
--- a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.indirect.pass.cpp
+++ b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.indirect.pass.cpp
@@ -54,11 +54,12 @@ int main(int, char**) {
// Test with an overaligned type
{
new_called = delete_called = 0;
- OverAligned* x = DoNotOptimize(new (std::nothrow) OverAligned);
+ OverAligned* dummy_data_block = new (std::nothrow) OverAligned;
+ OverAligned* x = DoNotOptimize(dummy_data_block);
ASSERT_WITH_OPERATOR_NEW_FALLBACKS(static_cast<void*>(x) == DummyData);
ASSERT_WITH_OPERATOR_NEW_FALLBACKS(new_called == 1);
- delete x;
+ delete dummy_data_block;
ASSERT_WITH_OPERATOR_NEW_FALLBACKS(delete_called == 1);
}
diff --git a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.pass.cpp b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.pass.cpp
index 9a5b53e039025c..a25b67ea554b39 100644
--- a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.pass.cpp
+++ b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.size_align_nothrow.replace.pass.cpp
@@ -47,11 +47,12 @@ int main(int, char**) {
// Test with an overaligned type
{
new_nothrow_called = delete_called = 0;
- OverAligned* x = new (std::nothrow) OverAligned;
+ OverAligned* dummy_data_block = new (std::nothrow) OverAligned;
+ OverAligned* x = DoNotOptimize(dummy_data_block);
assert(static_cast<void*>(x) == DummyData);
ASSERT_WITH_OPERATOR_NEW_FALLBACKS(new_nothrow_called == 1);
- delete x;
+ delete dummy_data_block;
ASSERT_WITH_OPERATOR_NEW_FALLBACKS(delete_called == 1);
}
More information about the libcxx-commits
mailing list