Commit Graph

5 Commits

Author SHA1 Message Date
Richard Smith b1220c04cc Instead of asking glibc to provide correct C++ signatures for <string.h>
functions, ask it whether it did provide them after the fact. Some versions of
glibc fail to compile if you make this request and don't also claim to be at
least GCC 4.3.

llvm-svn: 260622
2016-02-11 23:51:02 +00:00
Richard Smith 1b1c7e977f Work around regression in glibc 2.22: request that glibc provides the correct
prototypes for <string.h> functions that are converted into overload sets in
C++. This matches the existing workaround in <wchar.h>.

llvm-svn: 260570
2016-02-11 19:40:06 +00:00
Richard Smith 5fd17ab1b0 Fix overload sets of strchr, strpbrk, strrchr, memchr and strstr from
<string.h> and wcschr, wcspbrk, wcsrchr, wmemchr, and wcsstr from <wchar.h> to
provide a const-correct overload set even when the underlying C library does
not.

This change adds a new macro, _LIBCPP_PREFERRED_OVERLOAD, which (if defined)
specifies that a given overload is a better match than an otherwise equally
good function declaration without the overload. This is implemented in modern
versions of Clang via __attribute__((enable_if)), and not elsewhere.

We use this new macro to define overloads in the global namespace for these
functions that displace the overloads provided by the C library, unless we
believe the C library is already providing the correct signatures.

llvm-svn: 260337
2016-02-10 00:59:02 +00:00
Richard Smith 25cb32091c Revert r249929 ("Split <string.h> out of <cstring>").
This change caused problems when building code like povray that:
a) uses 'using namespace std;'
b) is built on an environment where the C library provides the "wrong"
   (non-const-correct) interface for the str* functions
c) makes an unqualified call to one of those str* functions

A patch is out for review to add a facility to fix this (and to give the
correct signatures for these functions whenever possible, even when the C
library does not do so). This revert is expected to be temporary.

llvm-svn: 251665
2015-10-29 23:32:29 +00:00
Richard Smith da231b4a3c Split <string.h> out of <cstring>.
Also fix the overload set for the five functions whose signatures change in the
case where we can fix it. This is already covered by existing tests for the
affected systems.

llvm-svn: 249929
2015-10-10 01:25:31 +00:00