Author: Louis Dionne Date: 2021-08-26T13:34:30-04:00 New Revision: 34300c3c00f5c724b662fc228bac8df5196f75c9
URL: https://github.com/llvm/llvm-project/commit/34300c3c00f5c724b662fc228bac8df5196f75c9 DIFF: https://github.com/llvm/llvm-project/commit/34300c3c00f5c724b662fc228bac8df5196f75c9.diff LOG: [libc++] Fix incorrect bypassing of <wctype.h> Differential Revision: https://reviews.llvm.org/D108709 (cherry picked from commit a4357bc496d05fd16a7d3df7817b6c3161faab0b) Added: Modified: libcxx/include/cwctype libcxx/include/wctype.h Removed: ################################################################################ diff --git a/libcxx/include/cwctype b/libcxx/include/cwctype index 17c68d6d4544f..27eea2f15730d 100644 --- a/libcxx/include/cwctype +++ b/libcxx/include/cwctype @@ -59,6 +59,7 @@ wctrans_t wctrans(const char* property); _LIBCPP_BEGIN_NAMESPACE_STD +#if defined(_LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H) using ::wint_t _LIBCPP_USING_IF_EXISTS; using ::wctrans_t _LIBCPP_USING_IF_EXISTS; using ::wctype_t _LIBCPP_USING_IF_EXISTS; @@ -80,6 +81,7 @@ using ::towlower _LIBCPP_USING_IF_EXISTS; using ::towupper _LIBCPP_USING_IF_EXISTS; using ::towctrans _LIBCPP_USING_IF_EXISTS; using ::wctrans _LIBCPP_USING_IF_EXISTS; +#endif // _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/wctype.h b/libcxx/include/wctype.h index 1b4b1461496c0..3b614759ac6d1 100644 --- a/libcxx/include/wctype.h +++ b/libcxx/include/wctype.h @@ -50,8 +50,18 @@ wctrans_t wctrans(const char* property); #pragma GCC system_header #endif +// TODO: +// In the future, we should unconditionally include_next <wctype.h> here and instead +// have a mode under which the library does not need libc++'s <wctype.h> or <cwctype> +// at all (i.e. a mode without wchar_t). As it stands, we need to do that to completely +// bypass the using declarations in <cwctype> when we did not include <wctype.h>. +// Otherwise, a using declaration like `using ::wint_t` in <cwctype> will refer to +// nothing (with using_if_exists), and if we include another header that defines one +// of these declarations (e.g. <wchar.h>), the second `using ::wint_t` with using_if_exists +// will fail because it does not refer to the same declaration. #if __has_include_next(<wctype.h>) # include_next <wctype.h> +# define _LIBCPP_INCLUDED_C_LIBRARY_WCTYPE_H #endif #ifdef __cplusplus _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits