-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[libc] Update floating testing infra for MSVC compatibility. #159810
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-libc Author: None (lntue) ChangesFull diff: https://github.com/llvm/llvm-project/pull/159810.diff 2 Files Affected:
diff --git a/libc/test/UnitTest/FEnvSafeTest.cpp b/libc/test/UnitTest/FEnvSafeTest.cpp
index f644569695eec..2730de350b39a 100644
--- a/libc/test/UnitTest/FEnvSafeTest.cpp
+++ b/libc/test/UnitTest/FEnvSafeTest.cpp
@@ -51,7 +51,8 @@ void FEnvSafeTest::expect_fenv_eq(const fenv_t &before_fenv,
EXPECT_EQ(before_state.ControlWord, after_state.ControlWord);
EXPECT_EQ(before_state.StatusWord, after_state.StatusWord);
-#elif defined(LIBC_TARGET_ARCH_IS_X86) && !defined(__APPLE__)
+#elif defined(LIBC_TARGET_ARCH_IS_X86) && !defined(__APPLE__) && \
+ !defined(LIBC_COMPILER_IS_MSVC)
using LIBC_NAMESPACE::fputil::internal::FPState;
const FPState &before_state = reinterpret_cast<const FPState &>(before_fenv);
const FPState &after_state = reinterpret_cast<const FPState &>(after_fenv);
diff --git a/libc/test/UnitTest/FPMatcher.h b/libc/test/UnitTest/FPMatcher.h
index 6a68211e6d849..f74276f54eb25 100644
--- a/libc/test/UnitTest/FPMatcher.h
+++ b/libc/test/UnitTest/FPMatcher.h
@@ -125,6 +125,7 @@ template <typename T, TestCond Condition> class CFPMatcher : public Matcher<T> {
bool match(T actualValue) {
actual = actualValue;
+#ifndef LIBC_COMPILER_IS_MSVC
if constexpr (cpp::is_complex_type_same<T, _Complex float>())
return matchComplex<float>();
else if constexpr (cpp::is_complex_type_same<T, _Complex double>())
@@ -134,14 +135,18 @@ template <typename T, TestCond Condition> class CFPMatcher : public Matcher<T> {
#ifdef LIBC_TYPES_HAS_CFLOAT16
else if constexpr (cpp::is_complex_type_same<T, cfloat16>())
return matchComplex<float16>();
-#endif
+#endif // LIBC_TYPES_HAS_CFLOAT16
#ifdef LIBC_TYPES_HAS_CFLOAT128
else if constexpr (cpp::is_complex_type_same<T, cfloat128>())
return matchComplex<float128>();
-#endif
+#endif // LIBC_TYPES_HAS_CFLOAT128
+#else // LIBC_COMPILER_IS_MSVC
+ return true;
+#endif // LIBC_COMPILER_IS_MSVC
}
void explainError() override {
+#ifndef LIBC_COMPILER_IS_MSVC
if constexpr (cpp::is_complex_type_same<T, _Complex float>())
return explainErrorComplex<float>();
else if constexpr (cpp::is_complex_type_same<T, _Complex double>())
@@ -151,11 +156,12 @@ template <typename T, TestCond Condition> class CFPMatcher : public Matcher<T> {
#ifdef LIBC_TYPES_HAS_CFLOAT16
else if constexpr (cpp::is_complex_type_same<T, cfloat16>())
return explainErrorComplex<float16>();
-#endif
+#endif // LIBC_TYPES_HAS_CFLOAT16
#ifdef LIBC_TYPES_HAS_CFLOAT128
else if constexpr (cpp::is_complex_type_same<T, cfloat128>())
return explainErrorComplex<float128>();
-#endif
+#endif // LIBC_TYPES_HAS_CFLOAT128
+#endif // LIBC_COMPILER_IS_MSVC
}
};
|
|
||
void explainError() override { | ||
#ifndef LIBC_COMPILER_IS_MSVC | ||
if constexpr (cpp::is_complex_type_same<T, _Complex float>()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does MSVC reject the _Complex
type entirely or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, MSVC does not support complex
or _Complex
at all. They do have their own complex types defined in their complex.h
. We will deal with complex support for MSVC later when we need those in LLVM/Clang.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's a different magic type can we typedef it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's their own struct:
#ifndef _C_COMPLEX_T
#define _C_COMPLEX_T
typedef struct _C_double_complex
{
double _Val[2];
} _C_double_complex;
typedef struct _C_float_complex
{
float _Val[2];
} _C_float_complex;
typedef struct _C_ldouble_complex
{
long double _Val[2];
} _C_ldouble_complex;
#endif
typedef _C_double_complex _Dcomplex;
typedef _C_float_complex _Fcomplex;
typedef _C_ldouble_complex _Lcomplex;
So we will need to clean up quite a bit to not using complex
and _Complex
directly, probably changing everything into our own typedefs cfloat32
, cfloat64
similar to our current cfloat16
and cfloat128
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.