Skip to content

Conversation

lntue
Copy link
Contributor

@lntue lntue commented Sep 19, 2025

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Sep 19, 2025

@llvm/pr-subscribers-libc

Author: None (lntue)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/159810.diff

2 Files Affected:

  • (modified) libc/test/UnitTest/FEnvSafeTest.cpp (+2-1)
  • (modified) libc/test/UnitTest/FPMatcher.h (+10-4)
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>())
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lntue lntue merged commit 21821f5 into llvm:main Sep 19, 2025
21 checks passed
@lntue lntue deleted the windows branch September 19, 2025 17:46
SeongjaeP pushed a commit to SeongjaeP/llvm-project that referenced this pull request Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants