[libc++] Remove libc++'s own ctype.h (#194615)

Our own `ctype.h` only `#undef`s macros which the C header might define.
None of the libcs we support define any of these functions as macros, so
we can simply drop the header.
This commit is contained in:
Nikolas Klauser 2026-05-04 08:28:24 +02:00 committed by GitHub
parent d38d8c6226
commit be8e0842a1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 10 additions and 196 deletions

View file

@ -1009,7 +1009,6 @@ set(files
cstring
ctgmath
ctime
ctype.h
cuchar
cwchar
cwctype

View file

@ -36,13 +36,11 @@ int toupper(int c);
#include <__cxx03/__config>
#include <ctype.h>
#ifndef _LIBCPP_CTYPE_H
# error <cctype> tried including <ctype.h> but didn't find libc++'s <ctype.h> header. \
This usually means that your header search paths are not configured properly. \
The header search paths should contain the C++ Standard Library headers before \
any C Standard Library.
#if __has_include(<ctype.h>)
# include <ctype.h>
# ifdef _LIBCPP_CTYPE_H
# error "If libc++ starts defining <ctype.h>, the __has_include check should move to libc++'s <ctype.h>"
# endif
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@ -51,62 +49,6 @@ int toupper(int c);
_LIBCPP_BEGIN_NAMESPACE_STD
#ifdef isalnum
# undef isalnum
#endif
#ifdef isalpha
# undef isalpha
#endif
#ifdef isblank
# undef isblank
#endif
#ifdef iscntrl
# undef iscntrl
#endif
#ifdef isdigit
# undef isdigit
#endif
#ifdef isgraph
# undef isgraph
#endif
#ifdef islower
# undef islower
#endif
#ifdef isprint
# undef isprint
#endif
#ifdef ispunct
# undef ispunct
#endif
#ifdef isspace
# undef isspace
#endif
#ifdef isupper
# undef isupper
#endif
#ifdef isxdigit
# undef isxdigit
#endif
#ifdef tolower
# undef tolower
#endif
#ifdef toupper
# undef toupper
#endif
using ::isalnum _LIBCPP_USING_IF_EXISTS;
using ::isalpha _LIBCPP_USING_IF_EXISTS;
using ::isblank _LIBCPP_USING_IF_EXISTS;

View file

@ -39,13 +39,11 @@ int toupper(int c);
#else
# include <__config>
# include <ctype.h>
# ifndef _LIBCPP_CTYPE_H
# error <cctype> tried including <ctype.h> but didn't find libc++'s <ctype.h> header. \
This usually means that your header search paths are not configured properly. \
The header search paths should contain the C++ Standard Library headers before \
any C Standard Library.
# if __has_include(<ctype.h>)
# include <ctype.h>
# ifdef _LIBCPP_CTYPE_H
# error "If libc++ starts defining <ctype.h>, the __has_include check should move to libc++'s <ctype.h>"
# endif
# endif
# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
@ -54,62 +52,6 @@ int toupper(int c);
_LIBCPP_BEGIN_NAMESPACE_STD
# ifdef isalnum
# undef isalnum
# endif
# ifdef isalpha
# undef isalpha
# endif
# ifdef isblank
# undef isblank
# endif
# ifdef iscntrl
# undef iscntrl
# endif
# ifdef isdigit
# undef isdigit
# endif
# ifdef isgraph
# undef isgraph
# endif
# ifdef islower
# undef islower
# endif
# ifdef isprint
# undef isprint
# endif
# ifdef ispunct
# undef ispunct
# endif
# ifdef isspace
# undef isspace
# endif
# ifdef isupper
# undef isupper
# endif
# ifdef isxdigit
# undef isxdigit
# endif
# ifdef tolower
# undef tolower
# endif
# ifdef toupper
# undef toupper
# endif
using ::isalnum _LIBCPP_USING_IF_EXISTS;
using ::isalpha _LIBCPP_USING_IF_EXISTS;
using ::isblank _LIBCPP_USING_IF_EXISTS;

View file

@ -1,65 +0,0 @@
// -*- 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_CTYPE_H
#define _LIBCPP_CTYPE_H
/*
ctype.h synopsis
int isalnum(int c);
int isalpha(int c);
int isblank(int c); // C99
int iscntrl(int c);
int isdigit(int c);
int isgraph(int c);
int islower(int c);
int isprint(int c);
int ispunct(int c);
int isspace(int c);
int isupper(int c);
int isxdigit(int c);
int tolower(int c);
int toupper(int c);
*/
#if defined(__cplusplus) && __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
# include <__cxx03/__config>
#else
# include <__config>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
#if __has_include_next(<ctype.h>)
# include_next <ctype.h>
#endif
#ifdef __cplusplus
# undef isalnum
# undef isalpha
# undef isblank
# undef iscntrl
# undef isdigit
# undef isgraph
# undef islower
# undef isprint
# undef ispunct
# undef isspace
# undef isupper
# undef isxdigit
# undef tolower
# undef toupper
#endif
#endif // _LIBCPP_CTYPE_H

View file

@ -2445,10 +2445,6 @@ module std_complex_h [system] {
header "complex.h"
export *
}
module std_ctype_h [system] {
header "ctype.h"
export *
}
module std_errno_h [system] {
header "errno.h"
export *