llvm-project/libc/src/ctype
Roland McGrath e7228062b2 [libc] Use #undef isascii in specific header
Standard C allows all standard headers to declare macros for all
their functions.  So after possibly including any standard header
like <ctype.h>, it's perfectly normal for any and all of the
functions it declares to be defined as macros.  Standard C requires
explicit `#undef` before using that identifier in a way that is not
compatible with function-like macro definitions.

The C standard's rules for this are extended to POSIX as well for
the interfaces it defines, and it's the expected norm for
nonstandard extensions declared by standard C library headers too.

So far the only place this has come up for llvm-libc's code is with
the isascii function in Fuchsia's libc.  But other cases can arise
for any standard (or common extension) function names that source
code in llvm-libc is using in nonstandard ways, i.e. as C++
identifiers.

The only correct and robust way to handle the possible inclusion of
standard C library headers when building llvm-libc source code is to
use `#undef` explicitly for each identifier before using it.  The
easy and obvious place to do that is in the per-function header.
This requires that all code, such as test code, that might include
any standard C library headers, e.g. via utils/UnitTest/Test.h, make
sure to include those *first* before the per-function header.

This change does that for isascii and its test.  But it should be
done uniformly for all the code and documented as a consistent
convention so new implementation files are sure to get this right.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D94642
2021-01-14 13:25:05 -08:00
..
CMakeLists.txt [libc] add isascii and toascii implementations 2021-01-12 23:41:20 +00:00
ctype_utils.h [libc] Add tolower, toupper implementation. 2020-08-06 15:21:38 -04:00
isalnum.cpp [libc] Switch to use a macro which does not insert a section for every libc function. 2021-01-08 23:52:35 +00:00
isalnum.h
isalpha.cpp [libc] Switch to use a macro which does not insert a section for every libc function. 2021-01-08 23:52:35 +00:00
isalpha.h
isascii.cpp [libc] add isascii and toascii implementations 2021-01-12 23:41:20 +00:00
isascii.h [libc] Use #undef isascii in specific header 2021-01-14 13:25:05 -08:00
isblank.cpp [libc][NFC] change isblank and iscntrl from implicit casting 2021-01-13 22:06:56 +00:00
isblank.h [libc] Add implementations for isblank, iscntrl, isgraph, ispunct. 2020-08-04 15:16:58 -04:00
iscntrl.cpp [libc][NFC] change isblank and iscntrl from implicit casting 2021-01-13 22:06:56 +00:00
iscntrl.h [libc] Add implementations for isblank, iscntrl, isgraph, ispunct. 2020-08-04 15:16:58 -04:00
isdigit.cpp [libc] Switch to use a macro which does not insert a section for every libc function. 2021-01-08 23:52:35 +00:00
isdigit.h
isgraph.cpp [libc] Switch to use a macro which does not insert a section for every libc function. 2021-01-08 23:52:35 +00:00
isgraph.h [libc] Add implementations for isblank, iscntrl, isgraph, ispunct. 2020-08-04 15:16:58 -04:00
islower.cpp [libc] Switch to use a macro which does not insert a section for every libc function. 2021-01-08 23:52:35 +00:00
islower.h [libc] Add islower and isupper implementation. 2020-07-31 14:05:27 -04:00
isprint.cpp [libc] Switch to use a macro which does not insert a section for every libc function. 2021-01-08 23:52:35 +00:00
isprint.h [libc] Add isspace, isprint, isxdigit implementations. 2020-08-05 10:51:43 -04:00
ispunct.cpp [libc] Switch to use a macro which does not insert a section for every libc function. 2021-01-08 23:52:35 +00:00
ispunct.h [libc] Add implementations for isblank, iscntrl, isgraph, ispunct. 2020-08-04 15:16:58 -04:00
isspace.cpp [libc] Switch to use a macro which does not insert a section for every libc function. 2021-01-08 23:52:35 +00:00
isspace.h [libc] Add isspace, isprint, isxdigit implementations. 2020-08-05 10:51:43 -04:00
isupper.cpp [libc] Switch to use a macro which does not insert a section for every libc function. 2021-01-08 23:52:35 +00:00
isupper.h [libc] Add islower and isupper implementation. 2020-07-31 14:05:27 -04:00
isxdigit.cpp [libc] Switch to use a macro which does not insert a section for every libc function. 2021-01-08 23:52:35 +00:00
isxdigit.h [libc] Add isspace, isprint, isxdigit implementations. 2020-08-05 10:51:43 -04:00
toascii.cpp [libc] add isascii and toascii implementations 2021-01-12 23:41:20 +00:00
toascii.h [libc] add isascii and toascii implementations 2021-01-12 23:41:20 +00:00
tolower.cpp [libc] Switch to use a macro which does not insert a section for every libc function. 2021-01-08 23:52:35 +00:00
tolower.h [libc] Add tolower, toupper implementation. 2020-08-06 15:21:38 -04:00
toupper.cpp [libc] Switch to use a macro which does not insert a section for every libc function. 2021-01-08 23:52:35 +00:00
toupper.h [libc] Add tolower, toupper implementation. 2020-08-06 15:21:38 -04:00