Skip to content

release/20.x: [libcxx] Provide locale conversions to tests through lit substitution (#105651) #139468

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

Open
wants to merge 4 commits into
base: release/20.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/libcxx-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,20 @@ jobs:
os: macos-15
- config: apple-configuration
os: macos-15
# TODO: These jobs are intended to test back-deployment (building against ToT libc++ but running against an
# older system-provided libc++.dylib). Doing this properly would require building the test suite on a
# recent macOS using a recent Clang (hence recent Xcode), and then running the actual test suite on an
# older mac. We could do that by e.g. sharing artifacts between the two jobs.
#
# However, our Lit configuration currently doesn't provide a good way to do that in a batch, so our only
# alternative is to actually build on the same host that we're going to run on. Sadly, that doesn't work
# since older macOSes don't support newer Xcodes. For now, we run the "backdeployment" jobs on recent
# macOS versions as a way to avoid rotting that configuration, but it doesn't provide a lot of additional
# coverage.
- config: apple-system
os: macos-13
os: macos-15
- config: apple-system-hardened
os: macos-13
os: macos-15
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
//
//===----------------------------------------------------------------------===//

// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// UNSUPPORTED: no-exceptions

// The fix for issue 57964 requires an updated dylib due to explicit
// instantiations. That means Apple backdeployment targets remain broken.
// XFAIL: using-built-library-before-llvm-19
// XFAIL using-built-library-before-llvm-19

// <ios>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@

// <string>

// This test demonstrates the smaller allocation sizes when the alignment
// requirements of std::string are dropped from 16 to 8.
//
// XFAIL: using-built-library-before-llvm-19

#include <algorithm>
#include <cassert>
#include <cstddef>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@
//
//===----------------------------------------------------------------------===//

// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// <fstream>

// basic_streambuf<charT, traits>* setbuf(char_type* s, streamsize n) override;

// In C++23 and later, this test requires support for P2467R1 in the dylib (a3f17ba3febbd546f2342ffc780ac93b694fdc8d)
// XFAIL: (!c++03 && !c++11 && !c++14 && !c++17 && !c++20) && using-built-library-before-llvm-18
// This test requires the fix to https://github.com/llvm/llvm-project/issues/60509 in the dylib,
// which landed in 5afb937d8a30445642ccaf33866ee4cdd0713222.
// XFAIL using-built-library-before-llvm-19

#include <fstream>
#include <cstddef>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@
//
//===----------------------------------------------------------------------===//

// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// <istream>

// int sync();

// The fix for bug 51497 and bug 51499 require and updated dylib due to
// explicit instantiations. That means Apple backdeployment targets remain
// broken.
// XFAIL: using-built-library-before-llvm-19
// XFAIL using-built-library-before-llvm-19

#include <istream>
#include <cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
//
//===----------------------------------------------------------------------===//

// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// Bionic has minimal locale support, investigate this later.
// XFAIL: LIBCXX-ANDROID-FIXME

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: darwin
// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// XFAIL darwin

// NetBSD does not support LC_MONETARY at the moment
// XFAIL: netbsd

// REQUIRES: locale.fr_FR.UTF-8

// ADDITIONAL_COMPILE_FLAGS: -DFR_MON_THOU_SEP=%{LOCALE_CONV_FR_FR_UTF_8_MON_THOUSANDS_SEP}

// <locale>

// class money_get<charT, InputIterator>
Expand Down Expand Up @@ -59,7 +64,8 @@ class my_facetw
};

static std::wstring convert_thousands_sep(std::wstring const& in) {
return LocaleHelpers::convert_thousands_sep_fr_FR(in);
const wchar_t fr_sep = LocaleHelpers::mon_thousands_sep_or_default(FR_MON_THOU_SEP);
return LocaleHelpers::convert_thousands_sep(in, fr_sep);
}
#endif // TEST_HAS_NO_WIDE_CHARACTERS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
//
//===----------------------------------------------------------------------===//

// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// NetBSD does not support LC_MONETARY at the moment
// XFAIL: netbsd

// REQUIRES: locale.ru_RU.UTF-8

// ADDITIONAL_COMPILE_FLAGS: -DRU_MON_THOU_SEP=%{LOCALE_CONV_RU_RU_UTF_8_MON_THOUSANDS_SEP}

// XFAIL: glibc-old-ru_RU-decimal-point

// <locale>
Expand Down Expand Up @@ -52,7 +57,8 @@ class my_facetw
};

static std::wstring convert_thousands_sep(std::wstring const& in) {
return LocaleHelpers::convert_thousands_sep_ru_RU(in);
const wchar_t ru_sep = LocaleHelpers::mon_thousands_sep_or_default(RU_MON_THOU_SEP);
return LocaleHelpers::convert_thousands_sep(in, ru_sep);
}
#endif // TEST_HAS_NO_WIDE_CHARACTERS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//

// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// NetBSD does not support LC_MONETARY at the moment
// XFAIL: netbsd

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: darwin
// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// XFAIL darwin

// NetBSD does not support LC_MONETARY at the moment
// XFAIL: netbsd

// REQUIRES: locale.fr_FR.UTF-8

// ADDITIONAL_COMPILE_FLAGS: -DFR_MON_THOU_SEP=%{LOCALE_CONV_FR_FR_UTF_8_MON_THOUSANDS_SEP}

// <locale>

// class money_put<charT, OutputIterator>
Expand Down Expand Up @@ -59,7 +64,8 @@ class my_facetw
};

static std::wstring convert_thousands_sep(std::wstring const& in) {
return LocaleHelpers::convert_thousands_sep_fr_FR(in);
const wchar_t fr_sep = LocaleHelpers::mon_thousands_sep_or_default(FR_MON_THOU_SEP);
return LocaleHelpers::convert_thousands_sep(in, fr_sep);
}
#endif // TEST_HAS_NO_WIDE_CHARACTERS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
//
//===----------------------------------------------------------------------===//

// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// NetBSD does not support LC_MONETARY at the moment
// XFAIL: netbsd

// REQUIRES: locale.ru_RU.UTF-8

// ADDITIONAL_COMPILE_FLAGS: -DRU_MON_THOU_SEP=%{LOCALE_CONV_RU_RU_UTF_8_MON_THOUSANDS_SEP}

// XFAIL: glibc-old-ru_RU-decimal-point

// <locale>
Expand Down Expand Up @@ -52,7 +57,8 @@ class my_facetw
};

static std::wstring convert_thousands_sep(std::wstring const& in) {
return LocaleHelpers::convert_thousands_sep_ru_RU(in);
const wchar_t ru_sep = LocaleHelpers::mon_thousands_sep_or_default(RU_MON_THOU_SEP);
return LocaleHelpers::convert_thousands_sep(in, ru_sep);
}
#endif // TEST_HAS_NO_WIDE_CHARACTERS

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//

// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// NetBSD does not support LC_MONETARY at the moment
// XFAIL: netbsd

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//

// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// NetBSD does not support LC_MONETARY at the moment
// XFAIL: netbsd

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// XFAIL: darwin

// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// XFAIL darwin
//
// NetBSD does not support LC_MONETARY at the moment
// XFAIL: netbsd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//

// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// NetBSD does not support LC_MONETARY at the moment
// XFAIL: netbsd

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
// NetBSD does not support LC_MONETARY at the moment
// XFAIL: netbsd

// XFAIL: LIBCXX-FREEBSD-FIXME

// REQUIRES: locale.en_US.UTF-8
// REQUIRES: locale.fr_FR.UTF-8
// REQUIRES: locale.ru_RU.UTF-8
// REQUIRES: locale.zh_CN.UTF-8

// ADDITIONAL_COMPILE_FLAGS: -DFR_MON_THOU_SEP=%{LOCALE_CONV_FR_FR_UTF_8_MON_THOUSANDS_SEP}
// ADDITIONAL_COMPILE_FLAGS: -DRU_MON_THOU_SEP=%{LOCALE_CONV_RU_RU_UTF_8_MON_THOUSANDS_SEP}

// <locale>

// class moneypunct_byname<charT, International>
Expand All @@ -27,6 +28,7 @@
#include <cassert>

#include "test_macros.h"
#include "locale_helpers.h"
#include "platform_support.h" // locale name macros

class Fnf
Expand Down Expand Up @@ -110,17 +112,10 @@ int main(int, char**)
Fnt f(LOCALE_fr_FR_UTF_8, 1);
assert(f.thousands_sep() == ' ');
}
// The below tests work around GLIBC's use of U202F as mon_thousands_sep.

#ifndef TEST_HAS_NO_WIDE_CHARACTERS
#if defined(_CS_GNU_LIBC_VERSION)
const wchar_t fr_sep = glibc_version_less_than("2.27") ? L' ' : L'\u202F';
#elif defined(_WIN32)
const wchar_t fr_sep = L'\u00A0';
#elif defined(_AIX)
const wchar_t fr_sep = L'\u202F';
#else
const wchar_t fr_sep = L' ';
#endif
const wchar_t fr_sep = LocaleHelpers::mon_thousands_sep_or_default(FR_MON_THOU_SEP);

{
Fwf f(LOCALE_fr_FR_UTF_8, 1);
assert(f.thousands_sep() == fr_sep);
Expand All @@ -140,19 +135,8 @@ int main(int, char**)
assert(f.thousands_sep() == sep);
}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
// The below tests work around GLIBC's use of U00A0 as mon_thousands_sep
// and U002E as mon_decimal_point.
// TODO: Fix thousands_sep for 'char'.
// related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16006
# if defined(_CS_GNU_LIBC_VERSION)
// FIXME libc++ specifically works around \u00A0 by translating it into
// a regular space.
const wchar_t wsep = glibc_version_less_than("2.27") ? L'\u00A0' : L'\u202F';
# elif defined(_WIN32) || defined(_AIX)
const wchar_t wsep = L'\u00A0';
# else
const wchar_t wsep = L' ';
# endif
const wchar_t wsep = LocaleHelpers::mon_thousands_sep_or_default(RU_MON_THOU_SEP);

{
Fwf f(LOCALE_ru_RU_UTF_8, 1);
assert(f.thousands_sep() == wsep);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
//
//===----------------------------------------------------------------------===//

// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// The fix for LWG2381 (https://github.com/llvm/llvm-project/pull/77948) changed behavior of
// FP parsing. This requires 3e15c97fa3812993bdc319827a5c6d867b765ae8 in the dylib.
// XFAIL using-built-library-before-llvm-19

// <locale>

// class num_get<charT, InputIterator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
//
//===----------------------------------------------------------------------===//

// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// The fix for LWG2381 (https://github.com/llvm/llvm-project/pull/77948) changed behavior of
// FP parsing. This requires 3e15c97fa3812993bdc319827a5c6d867b765ae8 in the dylib.
// XFAIL using-built-library-before-llvm-19

// <locale>

// class num_get<charT, InputIterator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
//
//===----------------------------------------------------------------------===//

// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// The fix for LWG2381 (https://github.com/llvm/llvm-project/pull/77948) changed behavior of
// FP parsing. This requires 3e15c97fa3812993bdc319827a5c6d867b765ae8 in the dylib.
// XFAIL using-built-library-before-llvm-19

// <locale>

// class num_get<charT, InputIterator>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//

// TODO(mordante) Investigate
// UNSUPPORTED: apple-clang

// NetBSD does not support LC_NUMERIC at the moment
// XFAIL: netbsd

Expand Down
Loading
Loading