[libcxx-commits] [libcxx] 55158ef - [libc++] Remove MSVC code

Nikolas Klauser via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 20 01:11:51 PDT 2022


Author: Nikolas Klauser
Date: 2022-09-20T10:11:42+02:00
New Revision: 55158efe104570642f4c6ada1b63c4725291e275

URL: https://github.com/llvm/llvm-project/commit/55158efe104570642f4c6ada1b63c4725291e275
DIFF: https://github.com/llvm/llvm-project/commit/55158efe104570642f4c6ada1b63c4725291e275.diff

LOG: [libc++] Remove MSVC code

It's been one and a half months now and nobody said anything, so I guess this code can be removed.

Reviewed By: ldionne, #libc

Spies: Mordante, libcxx-commits, mgorny, mstorsjo

Differential Revision: https://reviews.llvm.org/D132943

Added: 
    

Modified: 
    libcxx/include/CMakeLists.txt
    libcxx/include/__bits
    libcxx/include/__config
    libcxx/include/bit
    libcxx/include/charconv
    libcxx/include/limits
    libcxx/src/locale.cpp

Removed: 
    libcxx/include/__support/win32/limits_msvc_win32.h


################################################################################
diff  --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 080d9ea8a5d1f..19a0fd5901778 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -512,7 +512,6 @@ set(files
   __support/solaris/floatingpoint.h
   __support/solaris/wchar.h
   __support/solaris/xlocale.h
-  __support/win32/limits_msvc_win32.h
   __support/win32/locale_win32.h
   __support/xlocale/__nop_locale_mgmt.h
   __support/xlocale/__posix_l_fallback.h

diff  --git a/libcxx/include/__bits b/libcxx/include/__bits
index 92ef5c0a7b492..d2c8439a6ba72 100644
--- a/libcxx/include/__bits
+++ b/libcxx/include/__bits
@@ -22,8 +22,6 @@ _LIBCPP_PUSH_MACROS
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
-#ifndef _LIBCPP_COMPILER_MSVC
-
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
 int __libcpp_ctz(unsigned __x)           _NOEXCEPT { return __builtin_ctz(__x); }
 
@@ -70,91 +68,6 @@ int __libcpp_popcount(unsigned long __x)      _NOEXCEPT { return __builtin_popco
 inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
 int __libcpp_popcount(unsigned long long __x) _NOEXCEPT { return __builtin_popcountll(__x); }
 
-#else  // _LIBCPP_COMPILER_MSVC
-
-// Precondition:  __x != 0
-inline _LIBCPP_INLINE_VISIBILITY
-int __libcpp_ctz(unsigned __x) {
-  static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
-  static_assert(sizeof(unsigned long) == 4, "");
-  unsigned long __where;
-  if (_BitScanForward(&__where, __x))
-    return static_cast<int>(__where);
-  return 32;
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-int __libcpp_ctz(unsigned long __x) {
-    static_assert(sizeof(unsigned long) == sizeof(unsigned), "");
-    return __ctz(static_cast<unsigned>(__x));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-int __libcpp_ctz(unsigned long long __x) {
-    unsigned long __where;
-#if defined(_LIBCPP_HAS_BITSCAN64)
-  if (_BitScanForward64(&__where, __x))
-    return static_cast<int>(__where);
-#else
-  // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
-  if (_BitScanForward(&__where, static_cast<unsigned long>(__x)))
-    return static_cast<int>(__where);
-  if (_BitScanForward(&__where, static_cast<unsigned long>(__x >> 32)))
-    return static_cast<int>(__where + 32);
-#endif
-  return 64;
-}
-
-// Precondition:  __x != 0
-inline _LIBCPP_INLINE_VISIBILITY
-int __libcpp_clz(unsigned __x) {
-  static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
-  static_assert(sizeof(unsigned long) == 4, "");
-  unsigned long __where;
-  if (_BitScanReverse(&__where, __x))
-    return static_cast<int>(31 - __where);
-  return 32; // Undefined Behavior.
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-int __libcpp_clz(unsigned long __x) {
-    static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
-    return __libcpp_clz(static_cast<unsigned>(__x));
-}
-
-inline _LIBCPP_INLINE_VISIBILITY
-int __libcpp_clz(unsigned long long __x) {
-  unsigned long __where;
-#if defined(_LIBCPP_HAS_BITSCAN64)
-  if (_BitScanReverse64(&__where, __x))
-    return static_cast<int>(63 - __where);
-#else
-  // Win32 doesn't have _BitScanReverse64 so emulate it with two 32 bit calls.
-  if (_BitScanReverse(&__where, static_cast<unsigned long>(__x >> 32)))
-    return static_cast<int>(63 - (__where + 32));
-  if (_BitScanReverse(&__where, static_cast<unsigned long>(__x)))
-    return static_cast<int>(63 - __where);
-#endif
-  return 64; // Undefined Behavior.
-}
-
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned __x) {
-  static_assert(sizeof(unsigned) == 4, "");
-  return __popcnt(__x);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned long __x) {
-  static_assert(sizeof(unsigned long) == 4, "");
-  return __popcnt(__x);
-}
-
-inline _LIBCPP_INLINE_VISIBILITY int __libcpp_popcount(unsigned long long __x) {
-  static_assert(sizeof(unsigned long long) == 8, "");
-  return __popcnt64(__x);
-}
-
-#endif // _LIBCPP_COMPILER_MSVC
-
 _LIBCPP_END_NAMESPACE_STD
 
 _LIBCPP_POP_MACROS

diff  --git a/libcxx/include/__config b/libcxx/include/__config
index b7ec573217800..cfe2b20bdd3c4 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -210,20 +210,12 @@
 #    define _LIBCPP_CLANG_VER (__clang_major__ * 100 + __clang_minor__)
 #  elif defined(__GNUC__)
 #    define _LIBCPP_COMPILER_GCC
-#  elif defined(_MSC_VER)
-#    define _LIBCPP_COMPILER_MSVC
 #  endif
 
 #  if !defined(_LIBCPP_COMPILER_CLANG_BASED) && __cplusplus < 201103L
 #    error "libc++ only supports C++03 with Clang-based compilers. Please enable C++11"
 #  endif
 
-#  ifdef _LIBCPP_COMPILER_MSVC
-#    error If you successfully use libc++ with MSVC please tell the libc++ developers and consider upstreaming your \
-changes. We are not aware of anybody using this configuration and know that at least some code is currently broken. \
-If there are users of this configuration we are happy to provide support.
-#  endif
-
 // FIXME: ABI detection should be done via compiler builtin macros. This
 // is just a placeholder until Clang implements such macros. For now assume
 // that Windows compilers pretending to be MSVC++ target the Microsoft ABI,
@@ -494,27 +486,7 @@ typedef __char32_t char32_t;
 
 #    define _LIBCPP_DISABLE_EXTENSION_WARNING __extension__
 
-#  elif defined(_LIBCPP_COMPILER_MSVC)
-
-#    define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x))
-
-#    if _MSC_VER < 1900
-#      error "MSVC versions prior to Visual Studio 2015 are not supported"
-#    endif
-
-#    define _LIBCPP_NORETURN __declspec(noreturn)
-
-#    define _LIBCPP_WEAK
-
-#    define _LIBCPP_HAS_NO_ASAN
-
-#    define _LIBCPP_ALWAYS_INLINE __forceinline
-
-#    define _LIBCPP_HAS_NO_VECTOR_EXTENSION
-
-#    define _LIBCPP_DISABLE_EXTENSION_WARNING
-
-#  endif // _LIBCPP_COMPILER_[CLANG|GCC|MSVC]
+#  endif // _LIBCPP_COMPILER_[CLANG|GCC]
 
 #  if defined(_LIBCPP_OBJECT_FORMAT_COFF)
 
@@ -1085,7 +1057,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD _LIBCPP_END_NAMESPACE_STD
 #    define _LIBCPP_IF_WIDE_CHARACTERS(...) __VA_ARGS__
 #  endif
 
-#  if defined(_LIBCPP_ABI_MICROSOFT) && (defined(_LIBCPP_COMPILER_MSVC) || __has_declspec_attribute(empty_bases))
+#  if defined(_LIBCPP_ABI_MICROSOFT) && __has_declspec_attribute(empty_bases)
 #    define _LIBCPP_DECLSPEC_EMPTY_BASES __declspec(empty_bases)
 #  else
 #    define _LIBCPP_DECLSPEC_EMPTY_BASES

diff  --git a/libcxx/include/__support/win32/limits_msvc_win32.h b/libcxx/include/__support/win32/limits_msvc_win32.h
deleted file mode 100644
index 87e4e7db668f7..0000000000000
--- a/libcxx/include/__support/win32/limits_msvc_win32.h
+++ /dev/null
@@ -1,71 +0,0 @@
-// -*- C++ -*-
-//===-----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef _LIBCPP_SUPPORT_WIN32_LIMITS_MSVC_WIN32_H
-#define _LIBCPP_SUPPORT_WIN32_LIMITS_MSVC_WIN32_H
-
-#if !defined(_LIBCPP_MSVCRT)
-#error "This header complements the Microsoft C Runtime library, and should not be included otherwise."
-#endif
-#if defined(__clang__)
-#error "This header should only be included when using Microsoft's C1XX frontend"
-#endif
-
-#include <float.h> // limit constants
-#include <limits.h> // CHAR_BIT
-#include <math.h> // HUGE_VAL
-#include <ymath.h> // internal MSVC header providing the needed functionality
-
-#define __CHAR_BIT__       CHAR_BIT
-
-#define __FLT_MANT_DIG__   FLT_MANT_DIG
-#define __FLT_DIG__        FLT_DIG
-#define __FLT_RADIX__      FLT_RADIX
-#define __FLT_MIN_EXP__    FLT_MIN_EXP
-#define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP
-#define __FLT_MAX_EXP__    FLT_MAX_EXP
-#define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP
-#define __FLT_MIN__        FLT_MIN
-#define __FLT_MAX__        FLT_MAX
-#define __FLT_EPSILON__    FLT_EPSILON
-// predefined by MinGW GCC
-#define __FLT_DENORM_MIN__ 1.40129846432481707092e-45F
-
-#define __DBL_MANT_DIG__   DBL_MANT_DIG
-#define __DBL_DIG__        DBL_DIG
-#define __DBL_RADIX__      DBL_RADIX
-#define __DBL_MIN_EXP__    DBL_MIN_EXP
-#define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP
-#define __DBL_MAX_EXP__    DBL_MAX_EXP
-#define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP
-#define __DBL_MIN__        DBL_MIN
-#define __DBL_MAX__        DBL_MAX
-#define __DBL_EPSILON__    DBL_EPSILON
-// predefined by MinGW GCC
-#define __DBL_DENORM_MIN__ double(4.94065645841246544177e-324L)
-
-#define __LDBL_MANT_DIG__   LDBL_MANT_DIG
-#define __LDBL_DIG__        LDBL_DIG
-#define __LDBL_RADIX__      LDBL_RADIX
-#define __LDBL_MIN_EXP__    LDBL_MIN_EXP
-#define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP
-#define __LDBL_MAX_EXP__    LDBL_MAX_EXP
-#define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP
-#define __LDBL_MIN__        LDBL_MIN
-#define __LDBL_MAX__        LDBL_MAX
-#define __LDBL_EPSILON__    LDBL_EPSILON
-// predefined by MinGW GCC
-#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L
-
-// __builtin replacements/workarounds
-#define __builtin_huge_vall()    _LInf._Long_double
-#define __builtin_nanl(__dummmy) _LNan._Long_double
-#define __builtin_nansl(__dummy) _LSnan._Long_double
-
-#endif // _LIBCPP_SUPPORT_WIN32_LIMITS_MSVC_WIN32_H

diff  --git a/libcxx/include/bit b/libcxx/include/bit
index e3fb6e336b2be..d2061d3e6f5b2 100644
--- a/libcxx/include/bit
+++ b/libcxx/include/bit
@@ -71,10 +71,6 @@ namespace std {
 #include <type_traits>
 #include <version>
 
-#if defined(_LIBCPP_COMPILER_MSVC)
-#  include <intrin.h>
-#endif
-
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif

diff  --git a/libcxx/include/charconv b/libcxx/include/charconv
index 6d6a7db9310ac..35ac05e5a9c76 100644
--- a/libcxx/include/charconv
+++ b/libcxx/include/charconv
@@ -222,13 +222,7 @@ inline _LIBCPP_HIDE_FROM_ABI bool
 __mul_overflowed(_Tp __a, _Tp __b, _Tp& __r)
 {
     static_assert(is_unsigned<_Tp>::value, "");
-#if !defined(_LIBCPP_COMPILER_MSVC)
     return __builtin_mul_overflow(__a, __b, &__r);
-#else
-    bool __did = __b && (numeric_limits<_Tp>::max() / __b) < __a;
-    __r = __a * __b;
-    return __did;
-#endif
 }
 
 template <typename _Tp, typename _Up>

diff  --git a/libcxx/include/limits b/libcxx/include/limits
index 2e2883f44c0d7..3e074185702c8 100644
--- a/libcxx/include/limits
+++ b/libcxx/include/limits
@@ -106,10 +106,6 @@ template<> class numeric_limits<cv long double>;
 #include <__config>
 #include <type_traits>
 
-#if defined(_LIBCPP_COMPILER_MSVC)
-#include "__support/win32/limits_msvc_win32.h"
-#endif // _LIBCPP_MSVCRT
-
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #  pragma GCC system_header
 #endif

diff  --git a/libcxx/src/locale.cpp b/libcxx/src/locale.cpp
index e5035bd73157e..678c4877ef8b4 100644
--- a/libcxx/src/locale.cpp
+++ b/libcxx/src/locale.cpp
@@ -141,14 +141,7 @@ class _LIBCPP_HIDDEN locale::__imp
     : public facet
 {
     enum {N = 30};
-#if defined(_LIBCPP_COMPILER_MSVC)
-// FIXME: MSVC doesn't support aligned parameters by value.
-// I can't get the __sso_allocator to work here
-// for MSVC I think for this reason.
-    vector<facet*> facets_;
-#else
     vector<facet*, __sso_allocator<facet*, N> > facets_;
-#endif
     string         name_;
 public:
     explicit __imp(size_t refs = 0);


        


More information about the libcxx-commits mailing list