[libcxx-commits] [libcxx] [libc++][test] Replace uses of `_LIBCPP_ABI_MICROSOFT` in tests (PR #77233)

S. B. Tam via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 9 22:47:42 PST 2024


https://github.com/cpplearner updated https://github.com/llvm/llvm-project/pull/77233

>From 9dfe8387ef70005c39cf5dcd47106afe29978ba0 Mon Sep 17 00:00:00 2001
From: cpplearner <cpplearner at outlook.com>
Date: Sun, 7 Jan 2024 18:36:21 +0800
Subject: [PATCH 1/3] [libc++][test] Replace uses of `_LIBCPP_ABI_MICROSOFT` in
 tests

---
 .../support.exception/propagation/make_exception_ptr.pass.cpp | 2 +-
 .../support.exception/propagation/rethrow_exception.pass.cpp  | 2 +-
 libcxx/test/support/msvc_stdlib_force_include.h               | 1 +
 libcxx/test/support/test_macros.h                             | 4 ++++
 4 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/libcxx/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp b/libcxx/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
index e97b15adc50a65..8290b874db6479 100644
--- a/libcxx/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
+++ b/libcxx/test/std/language.support/support.exception/propagation/make_exception_ptr.pass.cpp
@@ -39,7 +39,7 @@ int main(int, char**)
         }
         catch (const A& a)
         {
-#ifndef _LIBCPP_ABI_MICROSOFT
+#ifndef TEST_ABI_MICROSOFT
             assert(A::constructed == 1);
 #else
             // On Windows exception_ptr copies the exception
diff --git a/libcxx/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp b/libcxx/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp
index d109f98fbc2131..57e1e8e90caa2c 100644
--- a/libcxx/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp
+++ b/libcxx/test/std/language.support/support.exception/propagation/rethrow_exception.pass.cpp
@@ -47,7 +47,7 @@ int main(int, char**)
         }
         catch (const A& a)
         {
-#ifndef _LIBCPP_ABI_MICROSOFT
+#ifndef TEST_ABI_MICROSOFT
             assert(A::constructed == 1);
 #else
             // On Windows the exception_ptr copies the exception
diff --git a/libcxx/test/support/msvc_stdlib_force_include.h b/libcxx/test/support/msvc_stdlib_force_include.h
index c027dc5c851e56..6c26085e72c45f 100644
--- a/libcxx/test/support/msvc_stdlib_force_include.h
+++ b/libcxx/test/support/msvc_stdlib_force_include.h
@@ -101,6 +101,7 @@ const AssertionDialogAvoider assertion_dialog_avoider{};
 #endif
 
 #define TEST_SHORT_WCHAR
+#define TEST_ABI_MICROSOFT
 
 #define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
 
diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h
index ea289f0432e686..2203b900f94546 100644
--- a/libcxx/test/support/test_macros.h
+++ b/libcxx/test/support/test_macros.h
@@ -443,6 +443,10 @@ inline void DoNotOptimize(Tp const& value) {
 #  define TEST_SHORT_WCHAR
 #endif
 
+#ifdef _LIBCPP_ABI_MICROSOFT
+#  define TEST_ABI_MICROSOFT
+#endif
+
 // This is a temporary workaround for user-defined `operator new` definitions
 // not being picked up on Apple platforms in some circumstances. This is under
 // investigation and should be short-lived.

>From aa16dba12c837461ae03852971f837f69c740aee Mon Sep 17 00:00:00 2001
From: cpplearner <cpplearner at outlook.com>
Date: Sun, 7 Jan 2024 20:57:48 +0800
Subject: [PATCH 2/3] Use `TEST_ABI_MICROSOFT` in `libcxx/test/libcxx`

---
 .../memory/trivial_abi/unique_ptr_destruction_order.pass.cpp    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp b/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp
index f8025f8ef57c5e..10dc5878325b67 100644
--- a/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp
+++ b/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp
@@ -55,7 +55,7 @@ int main(int, char**) {
   func(A(shared_buf, &cur_idx), std::unique_ptr<B>(new B(shared_buf, &cur_idx)),
        C(shared_buf, &cur_idx));
 
-#if defined(_LIBCPP_ABI_MICROSOFT)
+#if defined(TEST_ABI_MICROSOFT)
   // On Microsoft ABI, the dtor order is always A,B,C (because callee-destroyed)
   assert(shared_buf[0] == 'A' && shared_buf[1] == 'B' && shared_buf[2] == 'C');
 #else

>From 2f53554c3b0628ad79618ad91ad1d5563bfc9baa Mon Sep 17 00:00:00 2001
From: cpplearner <cpplearner at outlook.com>
Date: Wed, 10 Jan 2024 14:46:45 +0800
Subject: [PATCH 3/3] include "test_macros.h"

---
 .../memory/trivial_abi/unique_ptr_destruction_order.pass.cpp    | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp b/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp
index 10dc5878325b67..8752ba5a01d6ea 100644
--- a/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp
+++ b/libcxx/test/libcxx/memory/trivial_abi/unique_ptr_destruction_order.pass.cpp
@@ -17,6 +17,8 @@
 #include <memory>
 #include <cassert>
 
+#include "test_macros.h"
+
 __attribute__((noinline)) void call_something() { asm volatile(""); }
 
 struct Base {



More information about the libcxx-commits mailing list