Author: rsmith Date: Fri Oct 9 14:56:37 2015 New Revision: 249889 URL: http://llvm.org/viewvc/llvm-project?rev=249889&view=rev Log: Split <wchar.h> out of <cwchar>.
Added: libcxx/trunk/include/wchar.h - copied, changed from r249736, libcxx/trunk/include/cwchar Modified: libcxx/trunk/include/cwchar libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp Modified: libcxx/trunk/include/cwchar URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cwchar?rev=249889&r1=249888&r2=249889&view=diff ============================================================================== --- libcxx/trunk/include/cwchar (original) +++ libcxx/trunk/include/cwchar Fri Oct 9 14:56:37 2015 @@ -106,9 +106,6 @@ size_t wcsrtombs(char* restrict dst, con #include <__config> #include <cwctype> #include <wchar.h> -#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) -#include <support/win32/support.h> // pull in *swprintf defines -#endif // _LIBCPP_MSVCRT #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -161,16 +158,13 @@ using ::wcscoll; using ::wcsncmp; using ::wcsxfrm; -#if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_) - +#ifdef _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS using ::wcschr; using ::wcspbrk; using ::wcsrchr; using ::wcsstr; using ::wmemchr; - #else - inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return ::wcschr(__s, __c);} inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return ::wcschr(__s, __c);} @@ -185,7 +179,6 @@ inline _LIBCPP_INLINE_VISIBILITY w inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);} inline _LIBCPP_INLINE_VISIBILITY wchar_t* wmemchr( wchar_t* __s, wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);} - #endif using ::wcscspn; Copied: libcxx/trunk/include/wchar.h (from r249736, libcxx/trunk/include/cwchar) URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/wchar.h?p2=libcxx/trunk/include/wchar.h&p1=libcxx/trunk/include/cwchar&r1=249736&r2=249889&rev=249889&view=diff ============================================================================== --- libcxx/trunk/include/cwchar (original) +++ libcxx/trunk/include/wchar.h Fri Oct 9 14:56:37 2015 @@ -1,5 +1,5 @@ // -*- C++ -*- -//===--------------------------- cwchar -----------------------------------===// +//===--------------------------- wchar.h ----------------------------------===// // // The LLVM Compiler Infrastructure // @@ -8,11 +8,19 @@ // //===----------------------------------------------------------------------===// -#ifndef _LIBCPP_CWCHAR -#define _LIBCPP_CWCHAR +#if defined(__need_wint_t) || defined(__need_mbstate_t) + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +#include_next <wchar.h> + +#elif !defined(_LIBCPP_WCHAR_H) +#define _LIBCPP_WCHAR_H /* - cwchar synopsis + wchar.h synopsis Macros: @@ -21,9 +29,6 @@ Macros: WCHAR_MIN WEOF -namespace std -{ - Types: mbstate_t @@ -99,127 +104,33 @@ size_t mbsrtowcs(wchar_t* restrict dst, size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, mbstate_t* restrict ps); -} // std - */ #include <__config> -#include <cwctype> -#include <wchar.h> -#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) -#include <support/win32/support.h> // pull in *swprintf defines -#endif // _LIBCPP_MSVCRT #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif -_LIBCPP_BEGIN_NAMESPACE_STD - -using ::mbstate_t; -using ::size_t; -using ::tm; -using ::wint_t; -using ::FILE; -using ::fwprintf; -using ::fwscanf; -using ::swprintf; -using ::vfwprintf; -using ::vswprintf; -#ifndef _LIBCPP_MSVCRT -using ::swscanf; -using ::vfwscanf; -using ::vswscanf; -#endif // _LIBCPP_MSVCRT -using ::fgetwc; -using ::fgetws; -using ::fputwc; -using ::fputws; -using ::fwide; -using ::getwc; -using ::putwc; -using ::ungetwc; -using ::wcstod; -#ifndef _LIBCPP_MSVCRT -using ::wcstof; -using ::wcstold; -#endif // _LIBCPP_MSVCRT -using ::wcstol; -#ifndef _LIBCPP_HAS_NO_LONG_LONG -using ::wcstoll; -#endif // _LIBCPP_HAS_NO_LONG_LONG -using ::wcstoul; -#ifndef _LIBCPP_HAS_NO_LONG_LONG -using ::wcstoull; -#endif // _LIBCPP_HAS_NO_LONG_LONG -using ::wcscpy; -using ::wcsncpy; -using ::wcscat; -using ::wcsncat; -using ::wcscmp; -using ::wcscoll; -using ::wcsncmp; -using ::wcsxfrm; - -#if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_) - -using ::wcschr; -using ::wcspbrk; -using ::wcsrchr; -using ::wcsstr; -using ::wmemchr; - -#else - -inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcschr(const wchar_t* __s, wchar_t __c) {return ::wcschr(__s, __c);} -inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcschr( wchar_t* __s, wchar_t __c) {return ::wcschr(__s, __c);} - -inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcspbrk(const wchar_t* __s1, const wchar_t* __s2) {return ::wcspbrk(__s1, __s2);} -inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcspbrk( wchar_t* __s1, const wchar_t* __s2) {return ::wcspbrk(__s1, __s2);} - -inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcsrchr(const wchar_t* __s, wchar_t __c) {return ::wcsrchr(__s, __c);} -inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcsrchr( wchar_t* __s, wchar_t __c) {return ::wcsrchr(__s, __c);} - -inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wcsstr(const wchar_t* __s1, const wchar_t* __s2) {return ::wcsstr(__s1, __s2);} -inline _LIBCPP_INLINE_VISIBILITY wchar_t* wcsstr( wchar_t* __s1, const wchar_t* __s2) {return ::wcsstr(__s1, __s2);} - -inline _LIBCPP_INLINE_VISIBILITY const wchar_t* wmemchr(const wchar_t* __s, wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);} -inline _LIBCPP_INLINE_VISIBILITY wchar_t* wmemchr( wchar_t* __s, wchar_t __c, size_t __n) {return ::wmemchr(__s, __c, __n);} - +#ifdef __cplusplus +#define __CORRECT_ISO_CPP_WCHAR_H_PROTO #endif -using ::wcscspn; -using ::wcslen; -using ::wcsspn; -using ::wcstok; -using ::wmemcmp; -using ::wmemcpy; -using ::wmemmove; -using ::wmemset; -using ::wcsftime; -using ::btowc; -using ::wctob; -using ::mbsinit; -using ::mbrlen; -using ::mbrtowc; -using ::wcrtomb; -using ::mbsrtowcs; -using ::wcsrtombs; - -#ifndef _LIBCPP_HAS_NO_STDIN -using ::getwchar; -#ifndef _LIBCPP_MSVCRT -using ::vwscanf; -#endif // _LIBCPP_MSVCRT -using ::wscanf; -#endif +#include_next <wchar.h> -#ifndef _LIBCPP_HAS_NO_STDOUT -using ::putwchar; -using ::vwprintf; -using ::wprintf; +// Let <cwchar> know if we have const-correct overloads for wcschr and friends. +#if defined(_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_) +# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1 +#elif defined(__GLIBC_PREREQ) +# if __GLIBC_PREREQ(2, 10) +# define _LIBCPP_WCHAR_H_HAS_CONST_OVERLOADS 1 +# endif #endif -_LIBCPP_END_NAMESPACE_STD +#if defined(__cplusplus) && (defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)) +extern "C++" { +#include <support/win32/support.h> // pull in *swprintf defines +} // extern "C++" +#endif // __cplusplus && _LIBCPP_MSVCRT -#endif // _LIBCPP_CWCHAR +#endif // _LIBCPP_WCHAR_H Modified: libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp?rev=249889&r1=249888&r2=249889&view=diff ============================================================================== --- libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp (original) +++ libcxx/trunk/test/std/depr/depr.c.headers/wchar_h.pass.cpp Fri Oct 9 14:56:37 2015 @@ -28,13 +28,9 @@ #error WEOF not defined #endif -#if defined(__clang__) -#pragma clang diagnostic ignored "-Wmissing-braces" -#endif - int main() { - mbstate_t mb = {}; + mbstate_t mb = {0}; size_t s = 0; tm *tm = 0; wint_t w = 0; @@ -54,19 +50,13 @@ int main() static_assert((std::is_same<decltype(vfwscanf(fp, L"", va)), int>::value), ""); static_assert((std::is_same<decltype(vswprintf(ws, s, L"", va)), int>::value), ""); static_assert((std::is_same<decltype(vswscanf(L"", L"", va)), int>::value), ""); - static_assert((std::is_same<decltype(vwprintf(L"", va)), int>::value), ""); - static_assert((std::is_same<decltype(vwscanf(L"", va)), int>::value), ""); - static_assert((std::is_same<decltype(wprintf(L"")), int>::value), ""); - static_assert((std::is_same<decltype(wscanf(L"")), int>::value), ""); static_assert((std::is_same<decltype(fgetwc(fp)), wint_t>::value), ""); static_assert((std::is_same<decltype(fgetws(ws, 0, fp)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(fputwc(L' ', fp)), wint_t>::value), ""); static_assert((std::is_same<decltype(fputws(L"", fp)), int>::value), ""); static_assert((std::is_same<decltype(fwide(fp, 0)), int>::value), ""); static_assert((std::is_same<decltype(getwc(fp)), wint_t>::value), ""); - static_assert((std::is_same<decltype(getwchar()), wint_t>::value), ""); static_assert((std::is_same<decltype(putwc(L' ', fp)), wint_t>::value), ""); - static_assert((std::is_same<decltype(putwchar(L' ')), wint_t>::value), ""); static_assert((std::is_same<decltype(ungetwc(L' ', fp)), wint_t>::value), ""); static_assert((std::is_same<decltype(wcstod(L"", (wchar_t**)0)), double>::value), ""); static_assert((std::is_same<decltype(wcstof(L"", (wchar_t**)0)), float>::value), ""); @@ -83,14 +73,19 @@ int main() static_assert((std::is_same<decltype(wcscoll(L"", L"")), int>::value), ""); static_assert((std::is_same<decltype(wcsncmp(L"", L"", s)), int>::value), ""); static_assert((std::is_same<decltype(wcsxfrm(ws, L"", s)), size_t>::value), ""); + static_assert((std::is_same<decltype(wcschr((const wchar_t*)0, L' ')), const wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcschr((wchar_t*)0, L' ')), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcscspn(L"", L"")), size_t>::value), ""); static_assert((std::is_same<decltype(wcslen(L"")), size_t>::value), ""); + static_assert((std::is_same<decltype(wcspbrk((const wchar_t*)0, L"")), const wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcspbrk((wchar_t*)0, L"")), wchar_t*>::value), ""); + static_assert((std::is_same<decltype(wcsrchr((const wchar_t*)0, L' ')), const wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsrchr((wchar_t*)0, L' ')), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsspn(L"", L"")), size_t>::value), ""); + static_assert((std::is_same<decltype(wcsstr((const wchar_t*)0, L"")), const wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcsstr((wchar_t*)0, L"")), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wcstok(ws, L"", (wchar_t**)0)), wchar_t*>::value), ""); + static_assert((std::is_same<decltype(wmemchr((const wchar_t*)0, L' ', s)), const wchar_t*>::value), ""); static_assert((std::is_same<decltype(wmemchr((wchar_t*)0, L' ', s)), wchar_t*>::value), ""); static_assert((std::is_same<decltype(wmemcmp(L"", L"", s)), int>::value), ""); static_assert((std::is_same<decltype(wmemcpy(ws, L"", s)), wchar_t*>::value), ""); @@ -105,4 +100,16 @@ int main() static_assert((std::is_same<decltype(wcrtomb(ns, L' ', &mb)), size_t>::value), ""); static_assert((std::is_same<decltype(mbsrtowcs(ws, (const char**)0, s, &mb)), size_t>::value), ""); static_assert((std::is_same<decltype(wcsrtombs(ns, (const wchar_t**)0, s, &mb)), size_t>::value), ""); + +#ifndef _LIBCPP_HAS_NO_STDIN + static_assert((std::is_same<decltype(getwchar()), wint_t>::value), ""); + static_assert((std::is_same<decltype(vwscanf(L"", va)), int>::value), ""); + static_assert((std::is_same<decltype(wscanf(L"")), int>::value), ""); +#endif + +#ifndef _LIBCPP_HAS_NO_STDOUT + static_assert((std::is_same<decltype(putwchar(L' ')), wint_t>::value), ""); + static_assert((std::is_same<decltype(vwprintf(L"", va)), int>::value), ""); + static_assert((std::is_same<decltype(wprintf(L"")), int>::value), ""); +#endif } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits