Skip to content

Commit

Permalink
[libc++] Properly define _LIBCPP_HAS_NO_UNICODE in __config_site (llv…
Browse files Browse the repository at this point in the history
…m#95138)

Fixes llvm#93638

Co-authored-by: Mark de Wever <[email protected]>
  • Loading branch information
ldionne and mordante authored Jun 18, 2024
1 parent 7b33c5c commit 04a75f5
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 9 deletions.
1 change: 1 addition & 0 deletions libcxx/include/__config_site.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#cmakedefine _LIBCPP_HAS_NO_FILESYSTEM
#cmakedefine _LIBCPP_HAS_NO_RANDOM_DEVICE
#cmakedefine _LIBCPP_HAS_NO_LOCALIZATION
#cmakedefine _LIBCPP_HAS_NO_UNICODE
#cmakedefine _LIBCPP_HAS_NO_WIDE_CHARACTERS
#cmakedefine _LIBCPP_HAS_NO_STD_MODULES
#cmakedefine _LIBCPP_HAS_NO_TIME_ZONE_DATABASE
Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/__format/parser_std_format_spec.h
Original file line number Diff line number Diff line change
Expand Up @@ -1155,8 +1155,8 @@ __estimate_column_width(basic_string_view<_CharT> __str, size_t __maximum, __col
// When Unicode isn't supported assume ASCII and every code unit is one code
// point. In ASCII the estimated column width is always one. Thus there's no
// need for rounding.
size_t __width_ = std::min(__str.size(), __maximum);
return {__width_, __str.begin() + __width_};
size_t __width = std::min(__str.size(), __maximum);
return {__width, __str.begin() + __width};
}

# endif // !defined(_LIBCPP_HAS_NO_UNICODE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// UNSUPPORTED: no-filesystem, no-rtti
// UNSUPPORTED: libcpp-has-no-unicode
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME

// XFAIL: availability-fp_to_chars-missing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// UNSUPPORTED: no-filesystem
// UNSUPPORTED: libcpp-has-no-unicode
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME
// ADDITIONAL_COMPILE_FLAGS(has-fconstexpr-steps): -fconstexpr-steps=2000000

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

// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// UNSUPPORTED: no-filesystem
// UNSUPPORTED: libcpp-has-no-unicode
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME

// XFAIL: availability-fp_to_chars-missing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// UNSUPPORTED: no-filesystem
// UNSUPPORTED: no-wide-characters
// UNSUPPORTED: libcpp-has-no-unicode
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME

// Clang modules do not work with the definiton of _LIBCPP_TESTING_PRINT_WRITE_TO_WINDOWS_CONSOLE_FUNCTION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
// UNSUPPORTED: c++03, c++11, c++14, c++17
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME

// Force unicode to be disabled.
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_HAS_NO_UNICODE
// REQUIRES: libcpp-has-no-unicode

// TODO FMT This test should not require std::to_chars(floating-point)
// XFAIL: availability-fp_to_chars-missing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
// TODO FMT This test should not require std::to_chars(floating-point)
// XFAIL: availability-fp_to_chars-missing

// Force unicode to be disabled.
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_HAS_NO_UNICODE
// REQUIRES: libcpp-has-no-unicode

// <format>

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

// UNSUPPORTED: c++03, c++11, c++14, c++17
// UNSUPPORTED: libcpp-has-no-unicode
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME

// <format>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ test(std::stringstream& stream, std::string expected, test_format_string<char, A
"\nFormat string ", fmt.get(), "\nExpected output ", expected, "\nActual output ", out, '\n'));
}
// *** vprint_unicode ***
#ifndef TEST_HAS_NO_UNICODE
{
stream.str("");

Expand All @@ -75,6 +76,7 @@ test(std::stringstream& stream, std::string expected, test_format_string<char, A
TEST_WRITE_CONCATENATED(
"\nFormat string ", fmt.get(), "\nExpected output ", expected, "\nActual output ", out, '\n'));
}
#endif // TEST_HAS_NO_UNICODE
// *** vprint_nonunicode ***
{
stream.str("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// UNSUPPORTED: libcpp-has-no-unicode
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME

// TODO PRINT Investigate see https://reviews.llvm.org/D156585
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ static void test_println_blank_line() {
}

static void test_vprint_unicode() {
#ifdef TEST_HAS_NO_UNICODE
std::array<char, 100> buffer{0};

FILE* file = fmemopen(buffer.data(), buffer.size(), "wb");
Expand All @@ -92,6 +93,7 @@ static void test_vprint_unicode() {

assert(pos > 0);
assert(std::string_view(buffer.data(), pos) == "hello world!");
#endif // TEST_HAS_NO_UNICODE
}

static void test_vprint_nonunicode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
// UNSUPPORTED: no-filesystem
// UNSUPPORTED: libcpp-has-no-unicode
// UNSUPPORTED: GCC-ALWAYS_INLINE-FIXME

// XFAIL: availability-fp_to_chars-missing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,19 @@ void test() {
#if TEST_STD_VER > 20
test(STR(R"('\u{0}')"), STR("?}"), '\x00');
test(STR("'a'"), STR("?}"), 'a');
# ifndef TEST_HAS_NO_UNICODE
if constexpr (std::same_as<CharT, char>) {
test(STR(R"('\x{80}')"), STR("?}"), '\x80');
test(STR(R"('\x{ff}')"), STR("?}"), '\xff');
}
# ifndef TEST_HAS_NO_WIDE_CHARACTERS
# ifndef TEST_HAS_NO_WIDE_CHARACTERS
else {
test(STR(R"('\u{80}')"), STR("?}"), '\x80');
test(STR("'\u00ff'"), STR("?}"), '\xff');
}
# endif // TEST_HAS_NO_WIDE_CHARACTERS
#endif // TEST_STD_VER > 20
# endif // TEST_HAS_NO_WIDE_CHARACTERS
# endif // TEST_HAS_NO_UNICODE
#endif // TEST_STD_VER > 20

test(STR("10000000"), STR("b}"), char(-128));
test(STR("11111111"), STR("b}"), char(-1));
Expand Down

0 comments on commit 04a75f5

Please sign in to comment.