[libcxx] Avoid pulling in xlocinfo.h in public headers

Including xlocinfo.h is a bit of a layering violation; locale.h is
the C library header we should use, while xlocinfo.h is essentially
part of the MS C++ library. Including xlocinfo.h brings in yvals.h,
which brings in yvals_core.h, which defines the MS STL's version
support macros, overriding what libc++'s <version> had defined.

Instead just include locale.h, and provide the few defines we need
for locale categories manually.

Differential Revision: https://reviews.llvm.org/D99213
This commit is contained in:
Martin Storsjö 2021-03-23 22:02:26 +02:00
parent 39f3e9a9e0
commit 675401e04c
6 changed files with 20 additions and 7 deletions

View file

@ -12,9 +12,28 @@
#include <__config>
#include <stdio.h>
#include <xlocinfo.h> // _locale_t
#include <locale.h> // _locale_t
#include <__nullptr>
#define _X_ALL LC_ALL
#define _X_COLLATE LC_COLLATE
#define _X_CTYPE LC_CTYPE
#define _X_MONETARY LC_MONETARY
#define _X_NUMERIC LC_NUMERIC
#define _X_TIME LC_TIME
#define _X_MAX LC_MAX
#define _X_MESSAGES 6
#define _NCAT (_X_MESSAGES + 1)
#define _CATMASK(n) ((1 << (n)) >> 1)
#define _M_COLLATE _CATMASK(_X_COLLATE)
#define _M_CTYPE _CATMASK(_X_CTYPE)
#define _M_MONETARY _CATMASK(_X_MONETARY)
#define _M_NUMERIC _CATMASK(_X_NUMERIC)
#define _M_TIME _CATMASK(_X_TIME)
#define _M_MESSAGES _CATMASK(_X_MESSAGES)
#define _M_ALL (_CATMASK(_NCAT) - 1)
#define LC_COLLATE_MASK _M_COLLATE
#define LC_CTYPE_MASK _M_CTYPE
#define LC_MONETARY_MASK _M_MONETARY

View file

@ -13,8 +13,6 @@
// <complex>
// XFAIL: LIBCXX-WINDOWS-FIXME
// Test the feature test macros defined by <complex>
/* Constant Value

View file

@ -12,7 +12,6 @@
// clang-format off
// UNSUPPORTED: libcpp-has-no-filesystem-library
// XFAIL: LIBCXX-WINDOWS-FIXME
// <filesystem>

View file

@ -12,7 +12,6 @@
// clang-format off
// UNSUPPORTED: libcpp-has-no-localization
// XFAIL: LIBCXX-WINDOWS-FIXME
// <istream>

View file

@ -12,7 +12,6 @@
// clang-format off
// UNSUPPORTED: libcpp-has-no-localization
// XFAIL: LIBCXX-WINDOWS-FIXME
// <locale>

View file

@ -12,7 +12,6 @@
// clang-format off
// UNSUPPORTED: libcpp-has-no-localization
// XFAIL: LIBCXX-WINDOWS-FIXME
// <ostream>