Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/libcxx
diff options
context:
space:
mode:
authorLouis Dionne <ldionne.2@gmail.com>2022-02-03 23:42:40 +0300
committerLouis Dionne <ldionne.2@gmail.com>2022-03-07 16:48:50 +0300
commit311ff3917827131c20d4b8dac4ce0394a2351b94 (patch)
tree6f74cde6664b02c19e8ddda9aa2bf9ed1e95237e /libcxx
parent4bbee17ecb00bcdf43a43650a64172a4d9eb130c (diff)
[libc++] Add missing header <cuchar>
Fixes llvm-project#44216 Differential Revision: https://reviews.llvm.org/D97870
Diffstat (limited to 'libcxx')
-rw-r--r--libcxx/include/CMakeLists.txt2
-rw-r--r--libcxx/include/cuchar60
-rw-r--r--libcxx/include/module.modulemap10
-rw-r--r--libcxx/include/uchar.h52
-rw-r--r--libcxx/test/libcxx/clang_tidy.sh.cpp2
-rw-r--r--libcxx/test/libcxx/double_include.sh.cpp5
-rw-r--r--libcxx/test/libcxx/min_max_macros.compile.pass.cpp7
-rw-r--r--libcxx/test/libcxx/nasty_macros.compile.pass.cpp5
-rw-r--r--libcxx/test/libcxx/no_assert_include.compile.pass.cpp5
-rw-r--r--libcxx/test/libcxx/strings/c.strings/version_cuchar.pass.cpp10
-rw-r--r--libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp30
-rw-r--r--libcxx/test/std/depr/depr.c.headers/uchar_h.pass.cpp22
-rw-r--r--libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp32
-rw-r--r--libcxx/test/std/strings/c.strings/cuchar.pass.cpp26
-rwxr-xr-xlibcxx/utils/generate_header_inclusion_tests.py2
15 files changed, 214 insertions, 56 deletions
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index bf8a7c8d5bac..cc0a0ee421e1 100644
--- a/libcxx/include/CMakeLists.txt
+++ b/libcxx/include/CMakeLists.txt
@@ -448,6 +448,7 @@ set(files
ctgmath
ctime
ctype.h
+ cuchar
cwchar
cwctype
deque
@@ -541,6 +542,7 @@ set(files
type_traits
typeindex
typeinfo
+ uchar.h
unordered_map
unordered_set
utility
diff --git a/libcxx/include/cuchar b/libcxx/include/cuchar
new file mode 100644
index 000000000000..fec14929bd23
--- /dev/null
+++ b/libcxx/include/cuchar
@@ -0,0 +1,60 @@
+// -*- 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_CUCHAR
+#define _LIBCPP_CUCHAR
+
+/*
+ cuchar synopsis // since C++11
+
+Macros:
+
+ __STDC_UTF_16__
+ __STDC_UTF_32__
+
+namespace std {
+
+Types:
+
+ mbstate_t
+ size_t
+
+size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps);
+size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps);
+size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps);
+size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);
+
+} // std
+
+*/
+
+#include <__config>
+#include <uchar.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if !defined(_LIBCPP_CXX03_LANG)
+
+using ::mbstate_t _LIBCPP_USING_IF_EXISTS;
+using ::size_t _LIBCPP_USING_IF_EXISTS;
+
+using ::mbrtoc16 _LIBCPP_USING_IF_EXISTS;
+using ::c16rtomb _LIBCPP_USING_IF_EXISTS;
+using ::mbrtoc32 _LIBCPP_USING_IF_EXISTS;
+using ::c32rtomb _LIBCPP_USING_IF_EXISTS;
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CUCHAR
diff --git a/libcxx/include/module.modulemap b/libcxx/include/module.modulemap
index 9d196b993aa0..48f05bab1b2e 100644
--- a/libcxx/include/module.modulemap
+++ b/libcxx/include/module.modulemap
@@ -80,7 +80,10 @@ module std [system] {
header "string.h"
export *
}
- // FIXME: <uchar.h> is missing.
+ module uchar_h {
+ header "uchar.h"
+ export *
+ }
// <time.h> provided by C library.
module wchar_h {
// <wchar.h>'s __need_* macros require textual inclusion.
@@ -203,7 +206,10 @@ module std [system] {
header "ctime"
export *
}
- // FIXME: <cuchar> is missing.
+ module cuchar {
+ header "cuchar"
+ export *
+ }
module cwchar {
header "cwchar"
export depr.stdio_h
diff --git a/libcxx/include/uchar.h b/libcxx/include/uchar.h
new file mode 100644
index 000000000000..bb152c72cb3c
--- /dev/null
+++ b/libcxx/include/uchar.h
@@ -0,0 +1,52 @@
+// -*- 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_UCHAR_H
+#define _LIBCPP_UCHAR_H
+
+/*
+ uchar.h synopsis // since C++11
+
+Macros:
+
+ __STDC_UTF_16__
+ __STDC_UTF_32__
+
+Types:
+
+ mbstate_t
+ size_t
+
+size_t mbrtoc16(char16_t* pc16, const char* s, size_t n, mbstate_t* ps);
+size_t c16rtomb(char* s, char16_t c16, mbstate_t* ps);
+size_t mbrtoc32(char32_t* pc32, const char* s, size_t n, mbstate_t* ps);
+size_t c32rtomb(char* s, char32_t c32, mbstate_t* ps);
+
+*/
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#if !defined(_LIBCPP_CXX03_LANG)
+
+// Some platforms don't implement <uchar.h> and we don't want to give a hard
+// error on those platforms. When the platform doesn't provide <uchar.h>, at
+// least include <stddef.h> so we get the declaration for size_t.
+#if __has_include_next(<uchar.h>)
+# include_next <uchar.h>
+#else
+# include <stddef.h>
+#endif
+
+#endif // _LIBCPP_CXX03_LANG
+
+#endif // _LIBCPP_UCHAR_H
diff --git a/libcxx/test/libcxx/clang_tidy.sh.cpp b/libcxx/test/libcxx/clang_tidy.sh.cpp
index 8895719aba55..98cdbcd93bb2 100644
--- a/libcxx/test/libcxx/clang_tidy.sh.cpp
+++ b/libcxx/test/libcxx/clang_tidy.sh.cpp
@@ -74,6 +74,7 @@
#include <ctgmath>
#include <ctime>
#include <ctype.h>
+#include <cuchar>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
# include <cwchar>
#endif
@@ -188,6 +189,7 @@
#include <type_traits>
#include <typeindex>
#include <typeinfo>
+#include <uchar.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
diff --git a/libcxx/test/libcxx/double_include.sh.cpp b/libcxx/test/libcxx/double_include.sh.cpp
index b0ef43a2f289..54547c870c00 100644
--- a/libcxx/test/libcxx/double_include.sh.cpp
+++ b/libcxx/test/libcxx/double_include.sh.cpp
@@ -13,6 +13,9 @@
// RUN: %{cxx} -o %t.exe %t.first.o %t.second.o %{flags} %{link_flags}
// RUN: %{run}
+// The system-provided <uchar.h> seems to be broken on AIX
+// XFAIL: LIBCXX-AIX-FIXME
+
// Prevent <ext/hash_map> from generating deprecated warnings for this test.
#if defined(__DEPRECATED)
# undef __DEPRECATED
@@ -75,6 +78,7 @@
#include <ctgmath>
#include <ctime>
#include <ctype.h>
+#include <cuchar>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
# include <cwchar>
#endif
@@ -189,6 +193,7 @@
#include <type_traits>
#include <typeindex>
#include <typeinfo>
+#include <uchar.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
diff --git a/libcxx/test/libcxx/min_max_macros.compile.pass.cpp b/libcxx/test/libcxx/min_max_macros.compile.pass.cpp
index 70b8b141a1c4..b99b7aa30404 100644
--- a/libcxx/test/libcxx/min_max_macros.compile.pass.cpp
+++ b/libcxx/test/libcxx/min_max_macros.compile.pass.cpp
@@ -9,6 +9,9 @@
// Test that headers are not tripped up by the surrounding code defining the
// min() and max() macros.
+// The system-provided <uchar.h> seems to be broken on AIX
+// XFAIL: LIBCXX-AIX-FIXME
+
// Prevent <ext/hash_map> from generating deprecated warnings for this test.
#if defined(__DEPRECATED)
# undef __DEPRECATED
@@ -114,6 +117,8 @@ TEST_MACROS();
TEST_MACROS();
#include <ctype.h>
TEST_MACROS();
+#include <cuchar>
+TEST_MACROS();
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
# include <cwchar>
TEST_MACROS();
@@ -296,6 +301,8 @@ TEST_MACROS();
TEST_MACROS();
#include <typeinfo>
TEST_MACROS();
+#include <uchar.h>
+TEST_MACROS();
#include <unordered_map>
TEST_MACROS();
#include <unordered_set>
diff --git a/libcxx/test/libcxx/nasty_macros.compile.pass.cpp b/libcxx/test/libcxx/nasty_macros.compile.pass.cpp
index 263daabf3b75..88eef5c470e1 100644
--- a/libcxx/test/libcxx/nasty_macros.compile.pass.cpp
+++ b/libcxx/test/libcxx/nasty_macros.compile.pass.cpp
@@ -9,6 +9,9 @@
// Test that headers are not tripped up by the surrounding code defining various
// alphabetic macros.
+// The system-provided <uchar.h> seems to be broken on AIX
+// XFAIL: LIBCXX-AIX-FIXME
+
// Prevent <ext/hash_map> from generating deprecated warnings for this test.
#if defined(__DEPRECATED)
# undef __DEPRECATED
@@ -185,6 +188,7 @@
#include <ctgmath>
#include <ctime>
#include <ctype.h>
+#include <cuchar>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
# include <cwchar>
#endif
@@ -299,6 +303,7 @@
#include <type_traits>
#include <typeindex>
#include <typeinfo>
+#include <uchar.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
diff --git a/libcxx/test/libcxx/no_assert_include.compile.pass.cpp b/libcxx/test/libcxx/no_assert_include.compile.pass.cpp
index d99c261f0e11..ee0a3bfa5b57 100644
--- a/libcxx/test/libcxx/no_assert_include.compile.pass.cpp
+++ b/libcxx/test/libcxx/no_assert_include.compile.pass.cpp
@@ -9,6 +9,9 @@
// Ensure that none of the standard C++ headers implicitly include cassert or
// assert.h (because assert() is implemented as a macro).
+// The system-provided <uchar.h> seems to be broken on AIX
+// XFAIL: LIBCXX-AIX-FIXME
+
// Prevent <ext/hash_map> from generating deprecated warnings for this test.
#if defined(__DEPRECATED)
# undef __DEPRECATED
@@ -70,6 +73,7 @@
#include <ctgmath>
#include <ctime>
#include <ctype.h>
+#include <cuchar>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
# include <cwchar>
#endif
@@ -184,6 +188,7 @@
#include <type_traits>
#include <typeindex>
#include <typeinfo>
+#include <uchar.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
diff --git a/libcxx/test/libcxx/strings/c.strings/version_cuchar.pass.cpp b/libcxx/test/libcxx/strings/c.strings/version_cuchar.pass.cpp
index 5ded5e70ba3f..2c62af8db279 100644
--- a/libcxx/test/libcxx/strings/c.strings/version_cuchar.pass.cpp
+++ b/libcxx/test/libcxx/strings/c.strings/version_cuchar.pass.cpp
@@ -5,13 +5,11 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
-//
-// XFAIL: *
-// Skip this test on windows. If built on top of the MSVC runtime, the
-// <cuchar> header actually does exist (although not provided by us).
-// This should be removed once D97870 has landed.
-// UNSUPPORTED: windows
+// UNSUPPORTED: c++03
+
+// The system-provided <uchar.h> seems to be broken on AIX
+// XFAIL: LIBCXX-AIX-FIXME
// <cuchar>
diff --git a/libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp
new file mode 100644
index 000000000000..f031ed11a899
--- /dev/null
+++ b/libcxx/test/std/depr/depr.c.headers/uchar_h.compile.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03
+
+// Apple platforms don't provide <uchar.h> yet, so these tests fail.
+// XFAIL: target={{.+}}-apple-{{.+}}
+
+// The system-provided <uchar.h> seems to be broken on AIX
+// XFAIL: LIBCXX-AIX-FIXME
+
+// <uchar.h>
+
+#include <uchar.h>
+
+#include "test_macros.h"
+
+// __STDC_UTF_16__ may or may not be defined by the C standard library
+// __STDC_UTF_32__ may or may not be defined by the C standard library
+
+ASSERT_SAME_TYPE(size_t, decltype(mbrtoc16((char16_t*)0, (const char*)0, (size_t)0, (mbstate_t*)0)));
+ASSERT_SAME_TYPE(size_t, decltype(c16rtomb((char*)0, (char16_t)0, (mbstate_t*)0)));
+
+ASSERT_SAME_TYPE(size_t, decltype(mbrtoc32((char32_t*)0, (const char*)0, (size_t)0, (mbstate_t*)0)));
+ASSERT_SAME_TYPE(size_t, decltype(c16rtomb((char*)0, (char32_t)0, (mbstate_t*)0)));
diff --git a/libcxx/test/std/depr/depr.c.headers/uchar_h.pass.cpp b/libcxx/test/std/depr/depr.c.headers/uchar_h.pass.cpp
deleted file mode 100644
index c333370153c1..000000000000
--- a/libcxx/test/std/depr/depr.c.headers/uchar_h.pass.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-//
-// XFAIL: suse-linux-enterprise-server-11
-// XFAIL: darwin
-// XFAIL: netbsd
-// XFAIL: LIBCXX-AIX-FIXME
-
-// <uchar.h>
-
-#include <uchar.h>
-
-int main(int, char**)
-{
-
- return 0;
-}
diff --git a/libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp b/libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp
new file mode 100644
index 000000000000..388aa20ac0c4
--- /dev/null
+++ b/libcxx/test/std/strings/c.strings/cuchar.compile.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03
+
+// Apple platforms don't provide <uchar.h> yet, so these tests fail.
+// XFAIL: target={{.+}}-apple-{{.+}}
+
+// The system-provided <uchar.h> seems to be broken on AIX
+// XFAIL: LIBCXX-AIX-FIXME
+
+// <cuchar>
+
+#include <cuchar>
+
+#include "test_macros.h"
+
+// TODO: Implement mbrtoc8 and c8rtomb, and add tests for those
+
+// __STDC_UTF_16__ may or may not be defined by the C standard library
+// __STDC_UTF_32__ may or may not be defined by the C standard library
+
+ASSERT_SAME_TYPE(size_t, decltype(std::mbrtoc16((char16_t*)0, (const char*)0, (size_t)0, (mbstate_t*)0)));
+ASSERT_SAME_TYPE(size_t, decltype(std::c16rtomb((char*)0, (char16_t)0, (mbstate_t*)0)));
+
+ASSERT_SAME_TYPE(size_t, decltype(std::mbrtoc32((char32_t*)0, (const char*)0, (size_t)0, (mbstate_t*)0)));
+ASSERT_SAME_TYPE(size_t, decltype(std::c16rtomb((char*)0, (char32_t)0, (mbstate_t*)0)));
diff --git a/libcxx/test/std/strings/c.strings/cuchar.pass.cpp b/libcxx/test/std/strings/c.strings/cuchar.pass.cpp
deleted file mode 100644
index b63df56c4295..000000000000
--- a/libcxx/test/std/strings/c.strings/cuchar.pass.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// 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
-//
-//===----------------------------------------------------------------------===//
-//
-// XFAIL: stdlib=libc++
-
-// Skip this test on windows. If built on top of the MSVC runtime, the
-// <cuchar> header actually does exist (although not provided by us).
-// This should be removed once D97870 has landed.
-// UNSUPPORTED: windows
-
-// <cuchar>
-
-#include <cuchar>
-
-#include "test_macros.h"
-
-int main(int, char**)
-{
-
- return 0;
-}
diff --git a/libcxx/utils/generate_header_inclusion_tests.py b/libcxx/utils/generate_header_inclusion_tests.py
index 00f6b0aa8765..01a9deeac8b7 100755
--- a/libcxx/utils/generate_header_inclusion_tests.py
+++ b/libcxx/utils/generate_header_inclusion_tests.py
@@ -67,6 +67,7 @@ new_in_version = {
"compare": "20",
"concepts": "20",
"coroutine": "20",
+ "cuchar": "11",
"filesystem": "17",
"initializer_list": "11",
"optional": "17",
@@ -76,6 +77,7 @@ new_in_version = {
"system_error": "11",
"thread": "11",
"tuple": "11",
+ "uchar.h": "11",
"unordered_map": "11",
"unordered_set": "11",
"variant": "17",