Commit Graph

1901 Commits

Author SHA1 Message Date
Eric Fiselier 5b8ab693ab Remove non-standard basic_string_view::clear() member.
This patch removes the clear() member from <string_view>. The
modifier was removed from the TS before it ever landed in the standard.
There is no reason libc++ should be providing this method.

llvm-svn: 302869
2017-05-12 03:35:53 +00:00
Marshall Clow 7e154cdca7 Replace a nested namespace used for overload resolution with a struct. Richard Smith says that using the namespace results in an ODR violation, but I disagree. Nevertheless, the struct works just as well.
llvm-svn: 302800
2017-05-11 14:00:54 +00:00
Michael Park 215f55f526 Fix `std::visit` for the zero variants case.
Summary:
The following code is broken:

```
    std::visit([]{});
```

Reviewers: EricWF

Reviewed By: EricWF

Differential Revision: https://reviews.llvm.org/D33090

llvm-svn: 302773
2017-05-11 07:17:12 +00:00
Eric Fiselier 0c6e7ae4cc Remove usages of _LIBCPP_MSVC which is never defined
llvm-svn: 302736
2017-05-10 21:40:58 +00:00
Eric Fiselier a1bc823a59 Fix MinGW build to use Pthread when the header is available.
Some MinGW configurations use WinPThread instead of the native
threading interfaces. When this happens libc++ doesn't build because
it tries to use the wrong threading API.

This patch attempts to correctly detect and enable pthreads; Selecting
them when __MINGW32__ is defined and __has_include(<pthread.h>) is true.
I'm not sure if this works correctly 100% of the time but it seemed
like the most correct approach available.

llvm-svn: 302734
2017-05-10 21:34:58 +00:00
Eric Fiselier 80f8cfb37f Don't interfere with the __builtin_foo namespace under MSVC
This patch follows up on feedback received in the review for
D32988. Specifically that libc++ should not mess with the
__builtin namespace, and that libc++ should use __popcnt to implement
__pop_count under MSVC.

llvm-svn: 302731
2017-05-10 21:30:04 +00:00
Eric Fiselier 5d50aa3204 [libc++] Refactor Windows support headers.
Summary:
This patch refactors and tries to remove as much of the Windows support headers as possible. This is needed because they currently introduce super weird include cycles and dependencies between STL and libc headers.

The changes in this patch are:

* remove `support/win32/support.h` completely. The required parts have either been moved into `support/win32/msvc_support.h` (for `MSVC` only helpers not needed by Clang), or directly into their respective `foo.h` headers.

* Combine `locale_win32.h` and `locale_mgmt_win32.h` into a single headers, this header should only be included within `__locale` or `locale` to avoid include cycles.

* Remove the unneeded parts of `limits_win32.h` and re-name it to `limits_msvc_win32.h` since it's only needed by Clang.

I've tested this patch using Clang on Windows, but I suspect it might technically regress our non-existent support for MSVC. Is somebody able to double check?

This refactor is needed to support upcoming fixes to `<locale>` on Windows.



Reviewers: bcraig, rmaprath, compnerd, EricWF

Reviewed By: EricWF

Subscribers: majnemer, cfe-commits

Differential Revision: https://reviews.llvm.org/D32988

llvm-svn: 302727
2017-05-10 20:57:45 +00:00
Eric Fiselier f09df77236 [libc++] Fix PR32979 - types with a private std::enable_shared_from_this base break shared_ptr
Summary:
This patch fixes bugs.llvm.org/PR32979.

[util.smartptr.shared.const] says:
> In the constructor definitions below, enables shared_from_this with p, for a pointer p of type Y*, means
> that if Y has an unambiguous and accessible base class that is a specialization of enable_shared_from_-
> this.

This means that libc++ needs to respect the access specifier of the base class, and not attempt to construct
and enabled_shared_from_this base if it is private. However access specifiers don't affect overload resolution
so our current implementation will attempt to construct the private base. 

This patch uses SFINAE to correctly detect if the shared_ptr input has an accessible enable_shared_from_this
base class.

Reviewers: mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D33033

llvm-svn: 302709
2017-05-10 19:35:49 +00:00
Eric Fiselier e9ee517930 Support using MinGW POSIX threads on Windows
llvm-svn: 302617
2017-05-10 02:36:48 +00:00
Eric Fiselier 50d61da2e4 Fix GCC 7 test failures.
This patch fixes the test failures and unexpected passes that occur
when testing against GCC 7. Specifically:

* don't mark __gcd as always inline because it's a recursive function. GCC diagnoses this.
* don't XFAIL the aligned allocation tests. GCC 7 supports them but not the -faligned-allocation option.
* Work around gcc.gnu.org/PR78489 in variants constructors.

llvm-svn: 302488
2017-05-09 00:00:00 +00:00
Eric Fiselier b4ddab26bc Refactor <locale> RAII guards to aid upcoming Windows locale changes.
Previously <locale> used std::unique_ptr<remove_ptr<locale_t>, locale-mgmt-function>
as a scope guard for (A) creating new locales, and (B) setting the thread specific locale
in RAII safe manner.

However using unique_ptr has some problems, first it requires that locale_t is a pointer
type, which may not be the case (Windows will need a non-pointer locale_t type that emulates _locale_t).

The second problem is that users of the guards had to supply the locale management function to the custom
deleter at every call site. However these locale management functions don't exist natively Windows, making
a good Windows implementation of locale more difficult.

This patch creates distinct and simply RAII guards that replace unique_ptr. These guards handle calling
the correct locale management function so that callers don't have too. This simplification will
aid in upcoming Windows fixes.

llvm-svn: 302474
2017-05-08 22:02:43 +00:00
Eric Fiselier ef40748260 Fix shared_mutex dll import errors on Windows
llvm-svn: 302394
2017-05-08 01:31:50 +00:00
Eric Fiselier 3e254a6ece [libc++] Implement exception_ptr on Windows
Summary:
This patch implements exception_ptr on Windows using the `__ExceptionPtrFoo` functions provided by MSVC.

The `__ExceptionPtrFoo` functions are defined inside the C++ standard library, `msvcprt`, which is unfortunate because it requires libc++ to link to the MSVC STL. However this doesn't seem to cause any immediate problems. However to be safe I kept all usages within the libc++ dylib so that user programs wouldn't have to link to MSVCPRT as well.

Note there are still 2 outstanding exception_ptr/nested_exception test failures.

* `current_exception.pass.cpp` needs to be rewritten for the Windows exception_ptr semantics which copy the exception every time.
* `rethrow_if_nested.pass.cpp` need investigation. It hits a stack overflow, likely from recursion.

This patch also gets most of the `<future>` tests passing as well.

Reviewers: mclow.lists, compnerd, bcraig, rmaprath, majnemer, BillyONeal, STL_MSFT

Subscribers: mgorny, cfe-commits

Differential Revision: https://reviews.llvm.org/D32927

llvm-svn: 302393
2017-05-08 01:17:50 +00:00
Eric Fiselier 6d0dff294c Fix DLL import/export on Win32 locale helpers
llvm-svn: 302391
2017-05-08 00:37:31 +00:00
Eric Fiselier c04013f5f4 Fix DLL import for __time_get_c_storage member functions.
llvm-svn: 302390
2017-05-08 00:29:32 +00:00
Dimitry Andric 52844c83d0 Ensure showbase does not overflow do_put buffers
Summary:
In https://bugs.freebsd.org/207918, Daniel McRobb describes how using
std::showbase with ostreams can cause truncation of unsigned long long
when output format is octal.  In fact, this can even happen with
unsigned int and unsigned long.

To ensure this does not happen, add one additional character to the
do_put buffers if std::showbase is on.  Also add a test case.

Reviewers: EricWF, mclow.lists

Reviewed By: EricWF

Subscribers: cfe-commits, emaste

Differential Revision: https://reviews.llvm.org/D32670

llvm-svn: 302362
2017-05-06 20:58:50 +00:00
Eric Fiselier 28d89dbd3f Fix lgamma_r linking errors on Windows. It appears the normal lgamma function is thread safe anyway
llvm-svn: 302330
2017-05-06 02:58:43 +00:00
Eric Fiselier 0be6d5ba92 Fix condition_variable::wait_until and wait_for on Windows.
The ERROR_TIMEDOUT returned by the Windows API does not
have the same value as ETIMEDOUT. This caused condition_variable
to return timeouts as unknown errors.

llvm-svn: 302297
2017-05-05 21:31:22 +00:00
Eric Fiselier 1a5733af6a Fix detection for [[fallthrough]] with GCC
llvm-svn: 302285
2017-05-05 20:50:24 +00:00
Eric Fiselier 807790a09b Fix new warnings emitted by GCC 7
llvm-svn: 302280
2017-05-05 20:32:26 +00:00
Mehdi Amini e9c66ad9fa Add markup for libc++ dylib availability
Libc++ is used as a system library on macOS and iOS (amongst others). In order
for users to be able to compile a binary that is intended to be deployed to an
older version of the platform, clang provides the
availability attribute <https://clang.llvm.org/docs/AttributeReference.html#availability>_
that can be placed on declarations to describe the lifecycle of a symbol in the
library.

See docs/DesignDocs/AvailabilityMarkup.rst for more information.

Differential Revision: https://reviews.llvm.org/D31739

llvm-svn: 302172
2017-05-04 17:08:54 +00:00
Marshall Clow d6d22fe916 Use lgamma_r instead of lgamma in binomial_distribution, because freakin' POSIX took a perfectly fine call and made it not thread safe.
llvm-svn: 302168
2017-05-04 16:36:39 +00:00
Eric Fiselier 9c973b9f62 Use nullptr instead of the literal 0
llvm-svn: 302100
2017-05-04 01:06:56 +00:00
Eric Fiselier 6b88dae046 Fix macro redefinition warnings for _LIBCPP_NO_RTTI
llvm-svn: 302099
2017-05-04 01:06:54 +00:00
Eric Fiselier 1f8b73d15c Qualify calls to __invoke, __apply_fuctor, and __mu
llvm-svn: 302082
2017-05-03 21:02:19 +00:00
Justin Lebar dd9a4b9ae8 Add missing acquire_load to call_once overload.
Summary: Seemed to have been overlooked in D24028.

This bug was found and brought to my attention by Paul Wankadia.

Reviewers: kubamracek, EricWF, dvyukov

Differential Revision: https://reviews.llvm.org/D32402

llvm-svn: 301132
2017-04-23 16:58:48 +00:00
Duncan P. N. Exon Smith 42f8eee150 cmath: Skip Libc for integral types in isinf, etc.
For std::isinf, the standard requires effectively calling isinf as
double from Libc for integral types. But integral types are never
infinite; we don't need to call Libc to return false.

Also short-circuit other functions where Libc won't have interesting
answers: signbit, fpclassify, isfinite, isnan, and isnormal.

I added correctness tests for integral types since we're no longer
deferring to Libc.

In review it was pointed out that in future revisions of the C++
standard we may add more types to std::is_arithmetic (e.g.,
std::is_fixed_point).  I'll leave it to a future commit to hack this to
allow using math functions on those.  We'll need to change things like
__libcpp_fpclassify anyway, so I'm not sure anything here would really
be future-proof.

https://reviews.llvm.org/D31561
rdar://problem/31361223

llvm-svn: 301060
2017-04-21 23:14:55 +00:00
Eric Fiselier c411225462 Fix ATOMIC_<TYPE>_LOCK_FREE macros on Windows.
Previously the ATOMIC_<TYPE>_LOCK_FREE macros were implemented
using __GCC_ATOMIC_<TYPE>_LOCK_FREE but GCC specific macros
are defined when -fms-compatibility is specified.

To avoid this Libc++ now tries to use the newly added
__CLANG_ATOMIC_<TYPE>_LOCK_FREE macros instead, and only falls
back to the GCC versions when the Clang ones aren't available.

llvm-svn: 300920
2017-04-20 23:22:46 +00:00
Eric Fiselier 77ad0d7089 Fix dllimport on a class template
llvm-svn: 300808
2017-04-20 01:45:15 +00:00
Eric Fiselier 6ded58e279 Cleanup usages of _LIBCPP_HAS_NO_<c++11-feature> in <exception>
llvm-svn: 300649
2017-04-19 01:35:58 +00:00
Eric Fiselier 046492b932 Cleanup usages of _LIBCPP_HAS_NO_<c++11-feature> in <bitset>, <ios>, <locale>, and <iterator>
llvm-svn: 300648
2017-04-19 01:34:08 +00:00
Eric Fiselier 7e23afcb60 Cleanup remaining usages of _LIBCPP_HAS_NO_<c++11-feature> in the functional library
llvm-svn: 300646
2017-04-19 01:28:47 +00:00
Eric Fiselier 2987087182 Cleanup remaining usages of _LIBCPP_HAS_NO_<c++11-feature> in tuple and utility
llvm-svn: 300644
2017-04-19 01:23:39 +00:00
Eric Fiselier afa7a957bd Cleanup remaining _LIBCPP_HAS_NO_<c++11-feature> usages in container headers
llvm-svn: 300643
2017-04-19 01:23:04 +00:00
Eric Fiselier 414d17c67c Cleanup _LIBCPP_HAS_NO_<c++11-feature> in the string library.
llvm-svn: 300633
2017-04-19 00:28:44 +00:00
Eric Fiselier 69154d6e07 Cleanup _LIBCPP_HAS_NO_<c++11-feature> macros in the numeric tests and headers
llvm-svn: 300632
2017-04-19 00:23:45 +00:00
Eric Fiselier 9f7cc58f81 Cleanup _LIBCPP_HAS_NO_<c++11-features> macro usage in regex
llvm-svn: 300627
2017-04-18 23:42:15 +00:00
Eric Fiselier f0aca21e09 Cleanup _LIBCPP_HAS_NO_<c++11-feature> in the input.output library
llvm-svn: 300626
2017-04-18 23:38:41 +00:00
Eric Fiselier ddda456a76 Cleanup _LIBCPP_HAS_NO_<c++11-feature> in algorithm
llvm-svn: 300625
2017-04-18 23:26:47 +00:00
Eric Fiselier 94b2bde631 Cleanup _LIBCPP_HAS_NO_<c++11-feature> macros for std::initializer_list
llvm-svn: 300623
2017-04-18 23:09:36 +00:00
Eric Fiselier e11fb13b60 Cleanup _LIBCPP_HAS_NO_<c++11-feature> macros in thread.
llvm-svn: 300622
2017-04-18 23:05:08 +00:00
Eric Fiselier 6a470bcb6d Cleanup _LIBCPP_HAS_NO_<c++11-feature> in std::unordered_map and std::unordered_multimap
This completes the cleanup of the containers, at least within the tests.

llvm-svn: 300620
2017-04-18 22:50:56 +00:00
Eric Fiselier f0f86ef96f Cleanup _LIBCPP_HAS_NO_<c++11-feature> macros in std::unordered_set and std::unordered_multiset
llvm-svn: 300619
2017-04-18 22:37:32 +00:00
Eric Fiselier f5427b26d3 Cleanup _LIBCPP_HAS_NO_<c++11-feature> for std::queue and std::priority_queue.
llvm-svn: 300604
2017-04-18 21:23:18 +00:00
Eric Fiselier 7196ee3175 Cleanup _LIBCPP_HAS_NO_<c++11-feature> macro uses in std::stack.
llvm-svn: 300602
2017-04-18 21:16:26 +00:00
Eric Fiselier 1829311665 Cleanup _LIBCPP_HAS_NO_<c++11-feature> macros in std::map and std::multimap
llvm-svn: 300600
2017-04-18 21:08:06 +00:00
Eric Fiselier 922940b627 Cleanup _LIBCPP_HAS_NO_<c++11-feature> for std::set and std::multiset
llvm-svn: 300595
2017-04-18 20:58:03 +00:00
Eric Fiselier 8948264ed7 Work around GCC 4.9 bug regarding default initialization of const variables
llvm-svn: 300510
2017-04-17 22:32:02 +00:00
Eric Fiselier 86321b2bc8 Fix passing incorrectly value-category when constructing unique_ptr's deleter
llvm-svn: 300489
2017-04-17 20:20:27 +00:00
Casey Carter e3bdfe639c [optional] Update synopsis for LWG2934
(comment-only change)

llvm-svn: 300488
2017-04-17 20:15:16 +00:00