1207 Commits

Author SHA1 Message Date
Evgeniy Stepanov
4f01aa8fb8 ABI versioning macros for libc++.
C++ macros and CMake options that specify the default ABI version of
the library, and can be overridden to pick up new ABI-changing
features.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@250254 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-13 23:48:28 +00:00
Richard Smith
b3b00818e5 Fix use of libc++ <foo.h> headers from within an 'extern "C"' context in C++98.
Previously, this resulted in us declaring a template for static_assert emulation within the 'extern "C"' context, which is ill-formed.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@250247 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-13 23:12:22 +00:00
Richard Smith
44d1476b6d Remove __config module to avoid #include cycle when libc headers include libc++'s <foo.h> headers.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@250236 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-13 22:13:33 +00:00
Eric Fiselier
73ffc78616 [libcxx] Capture configuration information when installing the libc++ headers
Summary:
Hi all,

This patch is a successor to D11963. However it has changed dramatically and I felt it would be best to start a new review thread.

Please read the design documentation added in this patch for a description of how it works.

Reviewers: mclow.lists, danalbert, jroelofs, EricWF

Subscribers: vkalintiris, rnk, ed, espositofulvio, asl, eugenis, cfe-commits

Differential Revision: http://reviews.llvm.org/D13407

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@250235 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-13 22:12:02 +00:00
Richard Smith
de66c515de Unrevert r249889, and XFAIL the test for Darwin, where the libc apparently doesn't provide a correct overload set for some functions.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249932 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-10 01:39:51 +00:00
Richard Smith
9f4f08db91 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.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249929 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-10 01:25:31 +00:00
Manman Ren
e35e663f73 Revert r249889 due to bot failure.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249926 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-10 01:03:55 +00:00
Richard Smith
f2b3629dbf Split <wctype.h> out of <cwctype>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249890 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-09 19:57:37 +00:00
Richard Smith
26a70eccf2 Split <wchar.h> out of <cwchar>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249889 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-09 19:56:37 +00:00
Richard Smith
f650ea7131 Split <stdlib.h> out of <cstdlib>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249800 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-09 01:41:45 +00:00
Richard Smith
ff7ba4da7d Split <stdio.h> out of <cstdio>.
As with <stddef.h>, skip our custom header if __need_FILE or __need___FILE is defined.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249798 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-09 01:29:09 +00:00
Richard Smith
45bae0b7dc PR25118: move system_header pragma before uses of include_next to avoid extension warnings for people finding libc++ headers via -I paths.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249788 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-09 00:26:50 +00:00
Richard Smith
759cd0e86b Split <stddef.h> out of <cstddef>.
There are a bunch of macros (__need_size_t etc) that request just one piece of
<stddef.h>; if any one of these is defined, we just directly include the
underlying header.

Note that <stddef.h> provides a ::nullptr_t. We don't want that available to
includers of <cstddef>, so instead of following the usual pattern where <cfoo>
includes <foo.h> then pulls things from :: into std:: with using-declarations,
we implement <stddef.h> and <cstddef> separately; both include <__nullptr> for
the definition of std::nullptr_t.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249761 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08 22:25:27 +00:00
Richard Smith
4ccd90dd42 Fix incorrect file header. This is <cfenv> not <cctype>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249749 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08 21:17:21 +00:00
Richard Smith
ddbf08114a Split <setjmp.h> out of <csetjmp>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249743 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08 20:41:26 +00:00
Richard Smith
4faa3944c6 Split <math.h> out of <cmath>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249742 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08 20:40:34 +00:00
Richard Smith
325c37a20f Split <inttypes.h> out of <cinttypes>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249741 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08 20:38:53 +00:00
Richard Smith
f82f4f3f07 Split <float.h> out of <cfloat>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249740 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08 20:37:44 +00:00
Richard Smith
1bbbd60ea7 Split <errno.h> out of <cerrno>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249739 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08 20:37:11 +00:00
Richard Smith
ceeace9a60 Split <ctype.h> out of <cctype>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249738 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08 20:36:30 +00:00
Richard Smith
72d7577b34 Factor definition of std::nullptr_t out of <cstddef> into a header that can also be used by <stddef.h>.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249737 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-08 20:34:11 +00:00
Richard Smith
d8b2456344 Remove unnecessary inline functions capturing the contents of C library macros.
The C standard requires that these be provided as functions even if they're
also provided as macros, and a strict reading of the C++ standard library rules
suggests that (for instance) &::isdigit == &::std::isdigit, so these wrappers
are technically non-conforming.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249475 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-06 22:03:22 +00:00
Marshall Clow
7ed093bde7 Implement LWG#2063, and update the issues links to point to the github generated pages
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249325 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-05 16:17:34 +00:00
Eric Fiselier
423ca20f24 [libcxx] Attempt to fix __throw_future_error in C++03
Summary:
Hi Marshall,

Could you please test this patch and see if you run into the same linker errors we talked about?
I can't reproduce on linux or OS X.

Hopefully you can't find any problems and we can fix the C++03 bot.

Reviewers: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D13337

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@249192 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-02 21:25:15 +00:00
Eric Fiselier
5289b0d698 Fix initialzation order in dynarray
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@248988 91177308-0d34-0410-b5e6-96231b3b80d8
2015-10-01 07:29:38 +00:00
Marshall Clow
6a85e8a355 Fix Typo in GCC no RTTI detection. Fixes PR#24901. Thanks to Bernhard Rosenkraenzer for the report and the patch.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@248329 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-22 21:58:30 +00:00
Eric Fiselier
514c831504 Remove possible trailing padding from aligned_storage. Patch from Yiran Wang
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@248309 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-22 18:37:03 +00:00
Marshall Clow
6b0e4195eb Change pair::swap(pair&) to call ADL swap instead of iter_swap; this fixes an obscure bug having to do with overloaded operator&. Fixes PR#24890
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@248304 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-22 17:50:11 +00:00
Eric Fiselier
0b4ab6f08a Fix <atomic> with -pedantic-errors
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@248240 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-22 03:15:35 +00:00
Dan Albert
2897e786b4 Add endianness configuration block for GCC.
Previously GCC using libc++ would just leak endian.h for every
include.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@247827 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-16 18:10:47 +00:00
Marshall Clow
af9a44f256 Implementation of Boyer-Moore and Boyer-Moore-Horspool searchers for the LFTS.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@247036 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-08 17:59:09 +00:00
Eric Fiselier
65a6f64221 make common_type SFINAE-friendly and support void. Patch from Agustin Berge.
This patch also fixes PR22135. (https://llvm.org/bugs/show_bug.cgi?id=22135)
See the review for more information: http://reviews.llvm.org/D6964


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246977 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-08 00:13:57 +00:00
Marshall Clow
a189974948 Make a helper routine __throw_future_error, and encapsulate the #ifdef _LIBCPP_NO_EXCEPTIONS there, instead of duplicating it throughout the code. No functionality change
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246772 91177308-0d34-0410-b5e6-96231b3b80d8
2015-09-03 15:11:32 +00:00
Marshall Clow
6d9da5891f Remove unused code. NFC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246445 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-31 14:43:41 +00:00
Eric Fiselier
cae4caba73 Move __lazy_* metafunctions to type traits and add tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246408 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-31 03:50:31 +00:00
Eric Fiselier
e2d4892682 Fix most GCC warnings during build. Only -Wattribute left.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246280 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-28 07:02:42 +00:00
Eric Fiselier
aff153a8cd [libcxx] Constrain unique_ptr::operator=(unique_ptr<Tp, Dp>) in C++03 mode
Summary:
This patch properly constrains the converting assignment operator in C++03. It also fixes a bug where std::forward was given the wrong type.
The following two tests begin passing in C++03:

* `unique_ptr.single.asgn/move_convert.pass.cpp`
* `unique_ptr.single.asgn/move_convert13.fail.cpp`

Reviewers: mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D12173

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246272 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-28 05:07:06 +00:00
Eric Fiselier
4f241823a2 [libcxx] Optimize away unneeded length calculation in basic_string::compare(const char*)
Summary:
This patch optimizes basic_string::compare to use strcmp when the default char_traits has been given.
See PR19900 for more information. https://llvm.org/bugs/show_bug.cgi?id=19900

Reviewers: mclow.lists

Subscribers: bkramer, cfe-commits

Differential Revision: http://reviews.llvm.org/D12355

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246266 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-28 03:02:37 +00:00
Jonathan Roelofs
044df63102 Do not include pthread.h and sched.h when threads are disabled
Patch by Philippe Daouadi!

http://reviews.llvm.org/D9639


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246168 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-27 17:47:34 +00:00
Marshall Clow
5ea443059f Remove a switch statement, and replace with a bunch of ifs to silence a warning about 'all the enumeration values covered'. No functional change.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246150 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-27 14:37:22 +00:00
Eric Fiselier
f1626ad28d [libcxx] Rewrite C++03 __invoke.
Summary:
This patch rewrites the C++03 `__invoke` and related meta-programming. There are a number of major changes.

`__invoke` in C++03 now has a fallback overload for when the invoke expression is ill-formed (similar to C++11). This means that the `__invoke_return` traits will return `__nat` when `__invoke(...)` is ill formed. This would previously cause a compile error.

Bullets 1-4 of `__invoke` have been rewritten. In the old version `__invoke` had 32 overloads for bullets 1 and 2,
one for each possible cv-qualified function signature with arities 0-3. 64 overloads would be needed to support member functions
with varargs. Currently these overloads were fundamentally broken. An example overload looked like:
```
template <class Rp, class Tp, class T1, class A0>
Rp __invoke(Rp (Tp::*pm)(A0) const, T1&, A0&)
```
Because `A0` appeared in two different deducible contexts it would have to deduce to be an exact match or the overload
would be rejected. This is made even worse because `A0` appears without a reference qualifier in the member function signature
and with a reference qualifier as an `__invoke` parameter. This means that only member functions that took all
of their arguments by value could be matched.

One possible fix would be to make the second occurrence of `A0` appear in a non-deducible context. This way
any type convertible to `A0` could be passed as the first parameter. The benefit of this approach is that the
signature of the member function enforces the arity and types taken by the `__invoke` signature it generates. However
nothing in the `INVOKE` specification requires this behavior.

My solution is to use a `__invoke_enable_if<PM_Type, Tp>`  metafunction to selectively enable the `__invoke` overloads for bullets 1, 2, 3 and 4.  It uses `__member_function_traits` to inspect and extract the return type and class type of the pointer to member. Using `__member_function_traits` to inspect `PM_Type` also allows us to reduce the number of `__invoke` overloads from 32 to 8 and add
varargs support at the same time.

Because `__invoke_enable_if` knows the exact return type of `__invoke` for bullets 1-4 we no longer need to use `decltype(__invoke(...))` to
compute the return type in the `__invoke_return*` traits. This will reduce the problems caused by `#define decltype(X) __typeof__(X)` in C++03.

Tests for this change have already been committed. All tests in `test/std/utilities/function.objects` now pass in C++03, previously there were 20 failures.

Reviewers: K-ballo, howard.hinnant, mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D11553

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@246068 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-26 20:15:02 +00:00
Marshall Clow
70e8f59884 Fix a crasher found by libFuzzer
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245849 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-24 15:57:09 +00:00
Eric Fiselier
bb2f28e15d Recommit rL245802: Cleanup fancy pointer rebinding in list using __rebind_pointer.
Currently we need an #ifdef branch every time we use pointer traits to rebind a pointer because
it is done differently in C++11 and C++03. This patch introduces the __rebind_pointer utility to
clean this up.

Also add a test that list and it's iterators can be instantiated with incomplete element types.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245806 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-23 02:56:05 +00:00
Eric Fiselier
d686dda62e Revert r245802. It violates the incomplete type requirements.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245805 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-23 02:39:20 +00:00
Eric Fiselier
a276cb01be Cleanup fancy pointer rebinding in list using __rebind_pointer.
Currently we need an #ifdef branch every time we use pointer traits to rebind a pointer because
it is done differently in C++11 and C++03. This patch introduces the __rebind_pointer utility to
clean this up. 

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245802 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-23 02:34:18 +00:00
Eric Fiselier
de56f74611 [libcxx] Add "install-libcxx" target.
Summary: Currently you can't install libc++ from within the LLVM tree without installing all of LLVM. This patch adds an install rule for libc++.

Reviewers: mclow.lists, danalbert, jroelofs, EricWF

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D11697

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245470 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 17:41:53 +00:00
Eric Fiselier
00f4a49b0b [libcxx] Allow use of <atomic> in C++03. Try 3.
Summary:
After putting this question up on cfe-dev I have decided that it would be best to allow the use of `<atomic>` in C++03. Although static initialization is a concern the syntax required to get it is C++11 only. Meaning that C++11 constant static initialization cannot silently break in C++03, it will always cause a syntax error. Furthermore `ATOMIC_VAR_INIT` and `ATOMIC_FLAG_INIT` remain defined in C++03 even though they cannot be used because C++03 usages will cause better error messages.

The main change in this patch is to replace `__has_feature(cxx_atomic)`, which only returns true when C++ >= 11, to `__has_extension(c_atomic)` which returns true whenever clang supports the required atomic builtins.


This patch adds the following macros:
* `_LIBCPP_HAS_C_ATOMIC_IMP`      - Defined on clang versions which provide the C `_Atomic` keyword.
* `_LIBCPP_HAS_GCC_ATOMIC_IMP` - Defined on GCC > 4.7. We must use the fallback atomic implementation.
* `_LIBCPP_HAS_NO_ATOMIC_HEADER` - Defined when it is not safe to include `<atomic>`.

`_LIBCPP_HAS_C_ATOMIC_IMP` and `_LIBCPP_HAS_GCC_ATOMIC_IMP` are mutually exclusive, only one should be defined. If neither is defined then `<atomic>` is not implemented and including `<atomic>` will issue an error.

Reviewers: chandlerc, jroelofs, mclow.lists

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D11555

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245463 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 17:21:46 +00:00
Dimitry Andric
8966350d61 Fix warnings about pessimizing return moves for C++11 and higher
Summary:
Throughout the libc++ headers, there are a few instances where
_VSTD::move() is used to return a local variable.  Howard commented in
r189039 that these were there "for non-obvious reasons such as to help
things limp along in C++03 language mode".

However, when compiling these headers with warnings on, and in C++11 or
higher mode (like we do in FreeBSD), they cause the following complaints
about pessimizing moves:

    In file included from tests.cpp:26:
    In file included from tests.hpp:29:
    /usr/include/c++/v1/map:1368:12: error: moving a local object in a return statement prevents copy elision [-Werror,-Wpessimizing-move]
        return _VSTD::move(__h);  // explicitly moved for C++03
               ^
    /usr/include/c++/v1/__config:368:15: note: expanded from macro '_VSTD'
    #define _VSTD std::_LIBCPP_NAMESPACE
                  ^

Attempt to fix this by adding a _LIBCPP_EXPLICIT_MOVE() macro to
__config, which gets defined to _VSTD::move for pre-C++11, and to
nothing for C++11 and later.

I am not completely satisfied with the macro name (I also considered
_LIBCPP_COMPAT_MOVE and some other variants), so suggestions are
welcome. :)

Reviewers: mclow.lists, howard.hinnant, EricWF

Subscribers: arthur.j.odwyer, cfe-commits

Differential Revision: http://reviews.llvm.org/D11394

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245421 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 06:43:33 +00:00
Eric Fiselier
a8dca5f978 Remove commented out TODOs. They defined unneeded methods.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245411 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 03:48:08 +00:00
Eric Fiselier
f99b59c784 Fix use of static_assert macro with nested commas
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@245410 91177308-0d34-0410-b5e6-96231b3b80d8
2015-08-19 03:38:41 +00:00