[PATCH] D12747: Implement [depr.c.headers]
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 9 18:24:53 PDT 2015
rsmith created this revision.
rsmith added reviewers: mclow.lists, EricWF, chandlerc.
rsmith added a subscriber: cfe-commits.
rsmith set the repository for this revision to rL LLVM.
This patch provides the <foo.h> headers required by [depr.c.headers]. Previously, libc++ would rely on the underlying C library to provide these files, but it provides the C versions of the headers which typically miss some overloads required for a C++ standard library, and define macros that the C++ headers are not permitted to define.
I also removed some code which did this:
#ifdef isxdigit
inline _LIBCPP_INLINE_VISIBILITY int __libcpp_isxdigit(int __c) {return isxdigit(__c);}
#undef isxdigit
inline _LIBCPP_INLINE_VISIBILITY int isxdigit(int __c) {return __libcpp_isxdigit(__c);}
#endif // isxdigit
This doesn't work when defining the function in the global namespace (there already is a function named `isxdigit` in that scope), and is not necessary for correctness -- the C standard requires that these symbols are defined as functions, even if there's a macro present. So instead we just use this:
#undef isxdigit
This theoretically produces slower code, in that the macro may do something that's faster than a function call. However, in at least glibc, the libc function is defined as an inline function anyway (when building at -O1 or above), so there is no actual difference.
Repository:
rL LLVM
http://reviews.llvm.org/D12747
Files:
include/__nullptr
include/cctype
include/cerrno
include/cfloat
include/cinttypes
include/cmath
include/csetjmp
include/cstddef
include/cstdio
include/cstdlib
include/cstring
include/ctype.h
include/cwchar
include/cwctype
include/deque
include/errno.h
include/float.h
include/inttypes.h
include/math.h
include/module.modulemap
include/setjmp.h
include/stddef.h
include/stdio.h
include/stdlib.h
include/string.h
include/wchar.h
include/wctype.h
lib/buildit
test/std/depr/depr.c.headers/inttypes_h.pass.cpp
test/std/depr/depr.c.headers/math_h.pass.cpp
test/std/depr/depr.c.headers/math_h_isinf.pass.cpp
test/std/depr/depr.c.headers/math_h_isnan.pass.cpp
test/std/depr/depr.c.headers/setjmp_h.pass.cpp
test/std/depr/depr.c.headers/stddef_h.pass.cpp
test/std/depr/depr.c.headers/stdio_h.pass.cpp
test/std/depr/depr.c.headers/stdlib_h.pass.cpp
test/std/depr/depr.c.headers/wchar_h.pass.cpp
test/std/strings/c.strings/cctype.pass.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12747.34397.patch
Type: text/x-patch
Size: 285979 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150910/1d972263/attachment-0001.bin>
More information about the cfe-commits
mailing list