Skip to content

Commit 3465f02

Browse files
committed
[libc++][NFC] Add missing conditionals for the existence of wide characters
Differential Revision: https://reviews.llvm.org/D138435
1 parent 8b97b4e commit 3465f02

30 files changed

+77
-4
lines changed

libcxx/include/locale

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2385,7 +2385,9 @@ extern template _LIBCPP_FUNC_VIS __time_get_storage<_CharT>::string_type __time_
23852385
/**/
23862386

23872387
_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(char)
2388+
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
23882389
_LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION(wchar_t)
2390+
#endif
23892391
#undef _LIBCPP_TIME_GET_STORAGE_EXPLICIT_INSTANTIATION
23902392

23912393
template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> >
@@ -2445,8 +2447,10 @@ protected:
24452447
~__time_put();
24462448
void __do_put(char* __nb, char*& __ne, const tm* __tm,
24472449
char __fmt, char __mod) const;
2450+
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
24482451
void __do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm,
24492452
char __fmt, char __mod) const;
2453+
#endif
24502454
};
24512455

24522456
template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> >

libcxx/include/streambuf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,10 +489,12 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type)
489489
}
490490

491491
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<char>;
492-
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>;
493-
494492
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<char>;
493+
494+
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
495+
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_streambuf<wchar_t>;
495496
extern template class _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS basic_ios<wchar_t>;
497+
#endif
496498

497499
_LIBCPP_END_NAMESPACE_STD
498500

libcxx/test/libcxx/input.output/file.streams/fstreams/filebuf/traits_mismatch.fail.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
//
1414
// The char type of the stream and the char_type of the traits have to match
1515

16+
// UNSUPPORTED: no-wide-characters
17+
1618
#include <fstream>
1719

1820
int main(int, char**)

libcxx/test/libcxx/input.output/file.streams/fstreams/traits_mismatch.fail.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
// The char type of the stream and the char_type of the traits have to match
1515

16+
// UNSUPPORTED: no-wide-characters
17+
1618
#include <fstream>
1719

1820
int main(int, char**)

libcxx/test/libcxx/utilities/format/format.string/format.string.std/extended_grapheme_cluster.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
#include <string_view>
6666
#include <vector>
6767

68+
#include "test_macros.h"
69+
6870
template <class CharT>
6971
struct data {
7072
/// The input to parse.
@@ -689,6 +691,7 @@ std::array<data<char>, 602> data_utf8 = {{
689691
/// Note that most of the data for the UTF-16 and UTF-32 are identical. However
690692
/// since the size of the code units differ the breaks can contain different
691693
/// values.
694+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
692695
std::array<data<wchar_t>, 602> data_utf16 = {{
693696
{L"\U00000020\U00000020", {32, 32}, {1, 2}},
694697
{L"\U00000020\U00000308\U00000020", {32, 32}, {2, 3}},
@@ -1901,5 +1904,6 @@ std::array<data<wchar_t>, 602> data_utf32 = {{
19011904
{L"\U00000061\U0000200d\U0001f6d1", {97, 128721}, {2, 3}},
19021905
{L"\U00002701\U0000200d\U00002701", {9985}, {3}},
19031906
{L"\U00000061\U0000200d\U00002701", {97, 9985}, {2, 3}}}};
1907+
#endif // TEST_HAS_NO_WIDE_CHARACTERS
19041908

19051909
#endif // LIBCXX_TEST_STD_UTILITIES_FORMAT_FORMAT_STRING_FORMAT_STRING_STD_EXTENDED_GRAPHEME_CLUSTER_H

libcxx/test/std/re/re.iter/re.tokiter/re.tokiter.cnstr/default.pass.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ test()
2828
int main(int, char**)
2929
{
3030
test<char>();
31+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
3132
test<wchar_t>();
33+
#endif
3234

33-
return 0;
35+
return 0;
3436
}

libcxx/test/std/strings/basic.string/string.cons/iter_alloc_deduction.pass.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,13 @@ struct CanDeduce<Iter, Alloc, decltype((void)
4444
std::basic_string{std::declval<Iter>(), std::declval<Iter>(), std::declval<Alloc>()}
4545
)> : std::true_type { };
4646

47-
static_assert( CanDeduce<int*, std::allocator<int>>::value);
47+
static_assert( CanDeduce<char*, std::allocator<char>>::value);
4848
static_assert(!CanDeduce<NotAnIterator, std::allocator<char>>::value);
4949
static_assert(!CanDeduce<NotAnInputIterator, std::allocator<char16_t>>::value);
50+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
51+
static_assert( CanDeduce<wchar_t*, std::allocator<wchar_t>>::value);
5052
static_assert(!CanDeduce<wchar_t const*, NotAnAllocator<wchar_t>>::value);
53+
#endif
5154

5255
TEST_CONSTEXPR_CXX20 bool test() {
5356
{
@@ -70,6 +73,7 @@ TEST_CONSTEXPR_CXX20 bool test() {
7073
assert(s1.size() == 10);
7174
assert(s1.compare(0, s1.size(), s, s1.size()) == 0);
7275
}
76+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
7377
{
7478
const wchar_t* s = L"12345678901234";
7579
std::basic_string s1{s, s+10, test_allocator<wchar_t>{}};
@@ -80,6 +84,7 @@ TEST_CONSTEXPR_CXX20 bool test() {
8084
assert(s1.size() == 10);
8185
assert(s1.compare(0, s1.size(), s, s1.size()) == 0);
8286
}
87+
#endif
8388
{
8489
const char16_t* s = u"12345678901234";
8590
std::basic_string s1{s, s+10, min_allocator<char16_t>{}};

libcxx/test/std/strings/basic.string/traits_mismatch.verify.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
// <string>
1010
// The strings's value type must be the same as the traits's char_type
1111

12+
// UNSUPPORTED: no-wide-characters
13+
1214
#include <string>
1315

1416
std::basic_string<char, std::char_traits<wchar_t> > s; // expected-error@*:* {{traits_type::char_type must be the same type as CharT}}

libcxx/test/std/strings/basic.string/types.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ test()
7474
int main(int, char**)
7575
{
7676
test<test_traits<char>, test_allocator<char> >();
77+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
7778
test<std::char_traits<wchar_t>, std::allocator<wchar_t> >();
79+
#endif
7880
static_assert((std::is_same<std::basic_string<char>::traits_type,
7981
std::char_traits<char> >::value), "");
8082
static_assert((std::is_same<std::basic_string<char>::allocator_type,

libcxx/test/std/strings/string.view/string.view.access/at.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ int main(int, char**) {
3535
test ( "ABCDE", 5 );
3636
test ( "a", 1 );
3737

38+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
3839
test ( L"ABCDE", 5 );
3940
test ( L"a", 1 );
41+
#endif
4042

4143
#if TEST_STD_VER >= 11
4244
test ( u"ABCDE", 5 );

libcxx/test/std/strings/string.view/string.view.access/back.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ int main(int, char**) {
3232
assert ( test ( "ABCDE", 5 ));
3333
assert ( test ( "a", 1 ));
3434

35+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
3536
assert ( test ( L"ABCDE", 5 ));
3637
assert ( test ( L"a", 1 ));
38+
#endif
3739

3840
#if TEST_STD_VER >= 11
3941
assert ( test ( u"ABCDE", 5 ));

libcxx/test/std/strings/string.view/string.view.access/data.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ int main(int, char**) {
3333
test ( "ABCDE", 5 );
3434
test ( "a", 1 );
3535

36+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
3637
test ( L"ABCDE", 5 );
3738
test ( L"a", 1 );
39+
#endif
3840

3941
#if TEST_STD_VER >= 11
4042
test ( u"ABCDE", 5 );

libcxx/test/std/strings/string.view/string.view.access/front.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ int main(int, char**) {
3232
assert ( test ( "ABCDE", 5 ));
3333
assert ( test ( "a", 1 ));
3434

35+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
3536
assert ( test ( L"ABCDE", 5 ));
3637
assert ( test ( L"a", 1 ));
38+
#endif
3739

3840
#if TEST_STD_VER >= 11
3941
assert ( test ( u"ABCDE", 5 ));

libcxx/test/std/strings/string.view/string.view.access/index.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,10 @@ int main(int, char**) {
3434
test ( "ABCDE", 5 );
3535
test ( "a", 1 );
3636

37+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
3738
test ( L"ABCDE", 5 );
3839
test ( L"a", 1 );
40+
#endif
3941

4042
#if TEST_STD_VER >= 11
4143
test ( u"ABCDE", 5 );

libcxx/test/std/strings/string.view/string.view.cons/from_literal.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ int main(int, char**) {
4545
test ( "A" );
4646
test ( "" );
4747

48+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
4849
test ( L"QBCDE" );
4950
test ( L"A" );
5051
test ( L"" );
52+
#endif
5153

5254
#if TEST_STD_VER >= 11
5355
test ( u"QBCDE" );

libcxx/test/std/strings/string.view/string.view.cons/from_ptr_len.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ int main(int, char**) {
4545
}
4646
#endif
4747

48+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
4849
test ( L"QBCDE", 5 );
4950
test ( L"QBCDE", 2 );
5051
test ( L"", 0 );
@@ -56,6 +57,7 @@ int main(int, char**) {
5657
static_assert ( sv1.data() == s, "" );
5758
}
5859
#endif
60+
#endif // TEST_HAS_NO_WIDE_CHARACTERS
5961

6062
#if TEST_STD_VER >= 11
6163
test ( u"QBCDE", 5 );

libcxx/test/std/strings/string.view/string.view.ops/compare.pointer.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ int main(int, char**)
5555
test("abcdefghijklmnopqrst", "abcdefghijklmnopqrst", 0);
5656
}
5757

58+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
5859
{
5960
test(L"", L"", 0);
6061
test(L"", L"abcde", -5);
@@ -73,6 +74,7 @@ int main(int, char**)
7374
test(L"abcdefghijklmnopqrst", L"abcdefghij", 10);
7475
test(L"abcdefghijklmnopqrst", L"abcdefghijklmnopqrst", 0);
7576
}
77+
#endif
7678

7779
#if TEST_STD_VER >= 11
7880
{

libcxx/test/std/strings/string.view/string.view.ops/compare.pointer_size.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ int main(int, char**)
381381
test("abcdefghijklmnopqrst", 0, static_cast<size_t>(-1), "abcdefghijklmnopqrst", 0);
382382
}
383383

384+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
384385
{
385386
test(L"", 0, 0, L"", 0);
386387
test(L"", 0, 0, L"abcde", -5);
@@ -399,6 +400,7 @@ int main(int, char**)
399400
test(L"abcdefghijklmnopqrst", 0, 12, L"abcdefghij", 10);
400401
test(L"abcdefghijklmnopqrst", 0, static_cast<size_t>(-1), L"abcdefghijklmnopqrst", 0);
401402
}
403+
#endif
402404

403405
#if TEST_STD_VER >= 11
404406
{

libcxx/test/std/strings/string.view/string.view.ops/compare.size_size_sv.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,12 +368,14 @@ int main(int, char**) {
368368
test("ABCde", 2, 4, "abcde", -1);
369369
}
370370

371+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
371372
{
372373
test(L"abcde", 5, 1, L"", 0);
373374
test(L"abcde", 2, 4, L"", 3);
374375
test(L"abcde", 2, 4, L"abcde", 2);
375376
test(L"ABCde", 2, 4, L"abcde", -1);
376377
}
378+
#endif
377379

378380
#if TEST_STD_VER >= 11
379381
{

libcxx/test/std/strings/string.view/string.view.ops/compare.size_size_sv_pointer_size.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,13 +1315,15 @@ int main(int, char**) {
13151315
test("abcdefghijklmnopqrst", 10, 0, "abcdefghij", 10, -10);
13161316
}
13171317

1318+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
13181319
{
13191320
test(L"", 0, 0, L"abcde", 0, 0);
13201321
test(L"", 0, 0, L"abcde", 1, -1);
13211322
test(L"abcdefghijklmnopqrst", 21, 0, L"abcde", 0, 0);
13221323
test(L"abcdefghijklmnopqrst", 21, 0, L"abcde", 1, 0);
13231324
test(L"abcdefghijklmnopqrst", 10, 0, L"abcdefghij", 10, -10);
13241325
}
1326+
#endif
13251327

13261328
#if TEST_STD_VER >= 11
13271329
{

libcxx/test/std/strings/string.view/string.view.ops/compare.size_size_sv_size_size.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5814,12 +5814,14 @@ int main(int, char**) {
58145814
test("ABCde", 2, 4, "abcde", 2, 4, -1);
58155815
}
58165816

5817+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
58175818
{
58185819
test(L"abcde", 5, 1, L"", 0, 0, 0);
58195820
test(L"abcde", 2, 4, L"", 0, 0, 3);
58205821
test(L"abcde", 2, 4, L"abcde", 3, 4, -2);
58215822
test(L"ABCde", 2, 4, L"abcde", 2, 4, -1);
58225823
}
5824+
#endif
58235825

58245826
#if TEST_STD_VER >= 11
58255827
{

libcxx/test/std/strings/string.view/string.view.ops/compare.sv.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ int main(int, char**) {
5555
test("abcdefghijklmnopqrst", "abcdefghij", 10);
5656
test("abcdefghijklmnopqrst", "abcdefghijklmnopqrst", 0);
5757

58+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
5859
test(L"", L"", 0);
5960
test(L"", L"abcde", -5);
6061
test(L"", L"abcdefghij", -10);
@@ -71,6 +72,7 @@ int main(int, char**) {
7172
test(L"abcdefghijklmnopqrst", L"abcde", 15);
7273
test(L"abcdefghijklmnopqrst", L"abcdefghij", 10);
7374
test(L"abcdefghijklmnopqrst", L"abcdefghijklmnopqrst", 0);
75+
#endif
7476

7577
#if TEST_STD_VER >= 11
7678
test(u"", u"", 0);

libcxx/test/std/strings/string.view/string.view.ops/copy.pass.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,12 @@ int main(int, char**) {
9393
test ( "a" );
9494
test ( "" );
9595

96+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
9697
test ( L"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
9798
test ( L"ABCDE" );
9899
test ( L"a" );
99100
test ( L"" );
101+
#endif
100102

101103
#if TEST_STD_VER >= 11
102104
test ( u"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
@@ -111,7 +113,9 @@ int main(int, char**) {
111113
#endif
112114

113115
test_constexpr_copy("ABCDE", "GHIJK", "BCDJK");
116+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
114117
test_constexpr_copy(L"ABCDE", L"GHIJK", L"BCDJK");
118+
#endif
115119
#if TEST_STD_VER >= 11
116120
test_constexpr_copy(u"ABCDE", u"GHIJK", u"BCDJK");
117121
test_constexpr_copy(U"ABCDE", U"GHIJK", U"BCDJK");
@@ -121,7 +125,9 @@ int main(int, char**) {
121125
#endif
122126
#if TEST_STD_VER >= 20
123127
static_assert(test_constexpr_copy("ABCDE", "GHIJK", "BCDJK"));
128+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
124129
static_assert(test_constexpr_copy(L"ABCDE", L"GHIJK", L"BCDJK"));
130+
#endif
125131
static_assert(test_constexpr_copy(u"ABCDE", u"GHIJK", u"BCDJK"));
126132
static_assert(test_constexpr_copy(U"ABCDE", U"GHIJK", U"BCDJK"));
127133
static_assert(test_constexpr_copy(u8"ABCDE", u8"GHIJK", u8"BCDJK"));

libcxx/test/std/strings/string.view/string.view.ops/substr.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ int main(int, char**) {
7777
test ( "a" );
7878
test ( "" );
7979

80+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
8081
test ( L"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );
8182
test ( L"ABCDE" );
8283
test ( L"a" );
8384
test ( L"" );
85+
#endif
8486

8587
#if TEST_STD_VER >= 11
8688
test ( u"ABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDEABCDE" );

libcxx/test/std/strings/string.view/types.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,9 @@ test()
7272
int main(int, char**)
7373
{
7474
test<std::char_traits<char> >();
75+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
7576
test<std::char_traits<wchar_t> >();
77+
#endif
7678
#ifndef TEST_HAS_NO_CHAR8_T
7779
test<std::char_traits<char8_t> >();
7880
#endif

libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/advance_to.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ constexpr void test(const CharT* fmt) {
5050

5151
constexpr bool test() {
5252
test("abc");
53+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
5354
test(L"abc");
55+
#endif
5456
#ifndef TEST_HAS_NO_CHAR8_T
5557
test(u8"abc");
5658
#endif

libcxx/test/std/utilities/format/format.formatter/format.parse.ctx/begin.pass.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ constexpr void test(const CharT* fmt) {
3636

3737
constexpr bool test() {
3838
test("abc");
39+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
3940
test(L"abc");
41+
#endif
4042
#ifndef TEST_HAS_NO_CHAR8_T
4143
test(u8"abc");
4244
#endif

0 commit comments

Comments
 (0)