[libcxx-commits] [libcxx] [libc++][test] Update `msvc_stdlib_force_include.h` (PR #74266)
Stephan T. Lavavej via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Dec 3 17:12:47 PST 2023
https://github.com/StephanTLavavej updated https://github.com/llvm/llvm-project/pull/74266
>From 9147dda0631e174472e1570285d7923f62829d46 Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Sun, 3 Dec 2023 14:52:04 -0800
Subject: [PATCH 1/3] Define `_CRT_DECLARE_NONSTDC_NAMES`,
`_CRT_NONSTDC_NO_WARNINGS`, `NOMINMAX`.
---
libcxx/test/support/msvc_stdlib_force_include.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/libcxx/test/support/msvc_stdlib_force_include.h b/libcxx/test/support/msvc_stdlib_force_include.h
index 3c61f0b880b18..132a6877a0485 100644
--- a/libcxx/test/support/msvc_stdlib_force_include.h
+++ b/libcxx/test/support/msvc_stdlib_force_include.h
@@ -18,6 +18,15 @@
// Avoid assertion dialogs.
#define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
+
+ // Declare POSIX function names. (By default, Clang -fno-ms-compatibility causes them to be omitted.)
+ #define _CRT_DECLARE_NONSTDC_NAMES 1
+
+ // Silence warnings about POSIX function names.
+ #define _CRT_NONSTDC_NO_WARNINGS 1
+
+ // Avoid Windows.h macroizing min() and max().
+ #define NOMINMAX 1
#endif // _LIBCXX_IN_DEVCRT
#include <crtdbg.h>
>From 3b04b0a26a59a1b6e2c7841fdd47195a956f186a Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Sun, 3 Dec 2023 15:01:17 -0800
Subject: [PATCH 2/3] Simulate `__has_feature(hwaddress_sanitizer)` as `0` and
`__has_builtin(__builtin_source_location)` as `1`.
---
libcxx/test/support/msvc_stdlib_force_include.h | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/libcxx/test/support/msvc_stdlib_force_include.h b/libcxx/test/support/msvc_stdlib_force_include.h
index 132a6877a0485..1f5c1269ee00e 100644
--- a/libcxx/test/support/msvc_stdlib_force_include.h
+++ b/libcxx/test/support/msvc_stdlib_force_include.h
@@ -54,15 +54,19 @@ const AssertionDialogAvoider assertion_dialog_avoider{};
#if !defined(__clang__)
// Simulate feature-test macros.
#define __has_feature(X) _MSVC_HAS_FEATURE_ ## X
- #define _MSVC_HAS_FEATURE_cxx_exceptions 1
- #define _MSVC_HAS_FEATURE_cxx_rtti 1
- #define _MSVC_HAS_FEATURE_address_sanitizer 0
- #define _MSVC_HAS_FEATURE_memory_sanitizer 0
- #define _MSVC_HAS_FEATURE_thread_sanitizer 0
+ #define _MSVC_HAS_FEATURE_cxx_exceptions 1
+ #define _MSVC_HAS_FEATURE_cxx_rtti 1
+ #define _MSVC_HAS_FEATURE_address_sanitizer 0
+ #define _MSVC_HAS_FEATURE_hwaddress_sanitizer 0
+ #define _MSVC_HAS_FEATURE_memory_sanitizer 0
+ #define _MSVC_HAS_FEATURE_thread_sanitizer 0
#define __has_attribute(X) _MSVC_HAS_ATTRIBUTE_ ## X
#define _MSVC_HAS_ATTRIBUTE_vector_size 0
+ #define __has_builtin(X) _MSVC_HAS_BUILTIN_ ## X
+ #define _MSVC_HAS_BUILTIN___builtin_source_location 1
+
// Silence compiler warnings.
#pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored
#pragma warning(disable: 4324) // structure was padded due to alignment specifier
>From e94ef92b39dde09a7d318b43a1f23e96f40462ac Mon Sep 17 00:00:00 2001
From: "Stephan T. Lavavej" <stl at nuwen.net>
Date: Sun, 3 Dec 2023 17:10:25 -0800
Subject: [PATCH 3/3] clang-format msvc_stdlib_force_include.h, no manual
changes.
---
.../test/support/msvc_stdlib_force_include.h | 123 +++++++++---------
1 file changed, 59 insertions(+), 64 deletions(-)
diff --git a/libcxx/test/support/msvc_stdlib_force_include.h b/libcxx/test/support/msvc_stdlib_force_include.h
index 1f5c1269ee00e..bb00ac4e3404c 100644
--- a/libcxx/test/support/msvc_stdlib_force_include.h
+++ b/libcxx/test/support/msvc_stdlib_force_include.h
@@ -13,38 +13,38 @@
// MSVC standard library.
#ifndef _LIBCXX_IN_DEVCRT
- // Silence warnings about CRT machinery.
- #define _CRT_SECURE_NO_WARNINGS 1
+// Silence warnings about CRT machinery.
+# define _CRT_SECURE_NO_WARNINGS 1
- // Avoid assertion dialogs.
- #define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
+// Avoid assertion dialogs.
+# define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort()
- // Declare POSIX function names. (By default, Clang -fno-ms-compatibility causes them to be omitted.)
- #define _CRT_DECLARE_NONSTDC_NAMES 1
+// Declare POSIX function names. (By default, Clang -fno-ms-compatibility causes them to be omitted.)
+# define _CRT_DECLARE_NONSTDC_NAMES 1
- // Silence warnings about POSIX function names.
- #define _CRT_NONSTDC_NO_WARNINGS 1
+// Silence warnings about POSIX function names.
+# define _CRT_NONSTDC_NO_WARNINGS 1
- // Avoid Windows.h macroizing min() and max().
- #define NOMINMAX 1
+// Avoid Windows.h macroizing min() and max().
+# define NOMINMAX 1
#endif // _LIBCXX_IN_DEVCRT
#include <crtdbg.h>
#include <stdlib.h>
#if defined(_LIBCPP_VERSION)
- #error This header may not be used when targeting libc++
+# error This header may not be used when targeting libc++
#endif
#ifndef _LIBCXX_IN_DEVCRT
struct AssertionDialogAvoider {
- AssertionDialogAvoider() {
- _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
- _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+ AssertionDialogAvoider() {
+ _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
+ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
- _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
- _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
- }
+ _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
+ _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
+ }
};
const AssertionDialogAvoider assertion_dialog_avoider{};
@@ -52,72 +52,67 @@ const AssertionDialogAvoider assertion_dialog_avoider{};
// MSVC frontend only configurations
#if !defined(__clang__)
- // Simulate feature-test macros.
- #define __has_feature(X) _MSVC_HAS_FEATURE_ ## X
- #define _MSVC_HAS_FEATURE_cxx_exceptions 1
- #define _MSVC_HAS_FEATURE_cxx_rtti 1
- #define _MSVC_HAS_FEATURE_address_sanitizer 0
- #define _MSVC_HAS_FEATURE_hwaddress_sanitizer 0
- #define _MSVC_HAS_FEATURE_memory_sanitizer 0
- #define _MSVC_HAS_FEATURE_thread_sanitizer 0
-
- #define __has_attribute(X) _MSVC_HAS_ATTRIBUTE_ ## X
- #define _MSVC_HAS_ATTRIBUTE_vector_size 0
-
- #define __has_builtin(X) _MSVC_HAS_BUILTIN_ ## X
- #define _MSVC_HAS_BUILTIN___builtin_source_location 1
-
- // Silence compiler warnings.
- #pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored
- #pragma warning(disable: 4324) // structure was padded due to alignment specifier
- #pragma warning(disable: 4521) // multiple copy constructors specified
- #pragma warning(disable: 4702) // unreachable code
- #pragma warning(disable: 28251) // Inconsistent annotation for 'new': this instance has no annotations.
-#endif // !defined(__clang__)
+// Simulate feature-test macros.
+# define __has_feature(X) _MSVC_HAS_FEATURE_##X
+# define _MSVC_HAS_FEATURE_cxx_exceptions 1
+# define _MSVC_HAS_FEATURE_cxx_rtti 1
+# define _MSVC_HAS_FEATURE_address_sanitizer 0
+# define _MSVC_HAS_FEATURE_hwaddress_sanitizer 0
+# define _MSVC_HAS_FEATURE_memory_sanitizer 0
+# define _MSVC_HAS_FEATURE_thread_sanitizer 0
+
+# define __has_attribute(X) _MSVC_HAS_ATTRIBUTE_##X
+# define _MSVC_HAS_ATTRIBUTE_vector_size 0
+
+# define __has_builtin(X) _MSVC_HAS_BUILTIN_##X
+# define _MSVC_HAS_BUILTIN___builtin_source_location 1
+
+// Silence compiler warnings.
+# pragma warning(disable : 4180) // qualifier applied to function type has no meaning; ignored
+# pragma warning(disable : 4324) // structure was padded due to alignment specifier
+# pragma warning(disable : 4521) // multiple copy constructors specified
+# pragma warning(disable : 4702) // unreachable code
+# pragma warning(disable : 28251) // Inconsistent annotation for 'new': this instance has no annotations.
+#endif // !defined(__clang__)
#ifndef _LIBCXX_IN_DEVCRT
- // atomic_is_lock_free.pass.cpp needs this VS 2015 Update 2 fix.
- #define _ENABLE_ATOMIC_ALIGNMENT_FIX
+// atomic_is_lock_free.pass.cpp needs this VS 2015 Update 2 fix.
+# define _ENABLE_ATOMIC_ALIGNMENT_FIX
- // Restore features that are removed in C++20.
- #define _HAS_FEATURES_REMOVED_IN_CXX20 1
+// Restore features that are removed in C++20.
+# define _HAS_FEATURES_REMOVED_IN_CXX20 1
- // Silence warnings about the unspecified complex<non-floating-point>
- #define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING
+// Silence warnings about the unspecified complex<non-floating-point>
+# define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING
- // Silence warnings about features that are deprecated in non-default language modes.
- #define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
- #define _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS
- #define _SILENCE_ALL_CXX23_DEPRECATION_WARNINGS
+// Silence warnings about features that are deprecated in non-default language modes.
+# define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS
+# define _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS
+# define _SILENCE_ALL_CXX23_DEPRECATION_WARNINGS
#endif // _LIBCXX_IN_DEVCRT
#include <version>
#if _HAS_CXX23
- #define TEST_STD_VER 99
+# define TEST_STD_VER 99
#elif _HAS_CXX20
- #define TEST_STD_VER 20
+# define TEST_STD_VER 20
#elif _HAS_CXX17
- #define TEST_STD_VER 17
+# define TEST_STD_VER 17
#else
- #define TEST_STD_VER 14
+# define TEST_STD_VER 14
#endif
#define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST
#ifdef __clang__
-#define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
- _Pragma("GCC diagnostic push") \
- _Pragma("GCC diagnostic ignored \"-Wdeprecated\"")
-#define _LIBCPP_SUPPRESS_DEPRECATED_POP \
- _Pragma("GCC diagnostic pop")
+# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
+ _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wdeprecated\"")
+# define _LIBCPP_SUPPRESS_DEPRECATED_POP _Pragma("GCC diagnostic pop")
#else // ^^^ clang / MSVC vvv
-#define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
- __pragma(warning(push)) \
- __pragma(warning(disable : 4996)) \
- __pragma(warning(disable : 5215))
-#define _LIBCPP_SUPPRESS_DEPRECATED_POP \
- __pragma(warning(pop))
+# define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \
+ __pragma(warning(push)) __pragma(warning(disable : 4996)) __pragma(warning(disable : 5215))
+# define _LIBCPP_SUPPRESS_DEPRECATED_POP __pragma(warning(pop))
#endif // __clang__
#endif // SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H
More information about the libcxx-commits
mailing list