Commit Graph

2497 Commits

Author SHA1 Message Date
Louis Dionne
7aa4878d6f [NFC] Reformat availability #defines in __config
Aligning everything makes what we're doing more obvious.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@347363 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-20 23:18:25 +00:00
Louis Dionne
33f9849b15 [libcxx] Fix threads detection on GNU/Hurd
GNU/Hurd provides standard Posix threads

Reviewed as https://reviews.llvm.org/D54339.
Thanks to Samuel Thibault for the patch.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@347347 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-20 21:14:05 +00:00
Louis Dionne
13b7f7b500 [libcxx] Add availability markup for bad_optional_access, bad_variant_access and bad_any_cast
Reviewers: dexonsmith, EricWF

Subscribers: christof, arphaman, libcxx-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@347219 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-19 15:37:04 +00:00
Marshall Clow
98d4ace735 Implement P0972R0: <chrono> zero(), min(), and max() should be noexcept. Reviewed as https://reviews.llvm.org/D53828
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@346766 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-13 17:22:41 +00:00
Louis Dionne
52ddb5e2b8 [libcxx] Implement http://wg21.link/p1006, constexpr in pointer_traits
Summary:
P1006 adds support for constexpr in the specialization of pointer_traits
for raw pointers. This is necessary in order to use pointer_traits in
the upcoming constexpr containers. We expect P1006 to be voted into the
working draft for C++20 at the San Diego meeting.

Reviewers: mclow.lists, EricWF

Subscribers: christof, dexonsmith, libcxx-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@346764 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-13 17:04:05 +00:00
Marshall Clow
3870a97d86 Fix PR39619 - iterator_traits isn't SFINAE-friendly enough. Thanks to Eric for the report
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@346738 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-13 05:33:31 +00:00
Louis Dionne
0a36edc613 [NFC] Fix typo in <tuple>
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@346629 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-12 01:28:07 +00:00
Petr Hosek
cc73b180eb [libcxx] Provide thread annotations for shared_mutex
shared_mutex was introduced in C++17 but its implementation currently
doesn't use Clang's thread annotations like regular mutex. This change
adds those.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@346567 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-09 23:32:25 +00:00
Fangrui Song
d46349516c Fix -Wimplicit-fallthrough warning
Reviewers: EricWF, ldionne, mclow.lists

Reviewed By: ldionne

Subscribers: christof, libcxx-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@346369 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-07 23:51:13 +00:00
Louis Dionne
048b34a304 [NFC] Fix incorrect comment in std::list
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@346072 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-03 17:51:09 +00:00
Louis Dionne
5dc37768e2 Revert "Bug 39129: Speeding up partition_point/lower_bound/upper_bound/ by using unsigned division by 2 when possible."
This reverts r345525. I'm reverting because that patch apparently caused
a regression on certain platforms (see https://reviews.llvm.org/D53994).
Since we don't fully understand the reasons for the regression, I'm
reverting until we can provide a fix we understand.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345893 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-01 21:24:32 +00:00
Reid Kleckner
6115b72f60 Use C++11 fallthrough attribute syntax when available and add a break
Summary:
This silences the two -Wimplicit-fallthrough warnings clang finds in
ItaniumDemangle.h in libc++abi.

Clang does not have a GNU attribute spelling for this attribute, so this
is necessary.

I will commit the same change to the LLVM demangler soon.

Reviewers: EricWF, ldionne

Subscribers: christof, erik.pilkington, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345870 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-01 18:24:03 +00:00
Louis Dionne
f10e0ac7b0 [libcxx] Fix usage of _C2, which is a "nasty macro" in some environments
The problem was pointed out in https://reviews.llvm.org/D48896#inline-475775.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345834 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-01 14:41:37 +00:00
Erik Pilkington
71ac96a43b Second half of C++17's splicing maps and sets
This commit adds a merge member function to all the map and set containers,
which splices nodes from the source container. This completes support for
P0083r3.

Differential revision: https://reviews.llvm.org/D48896

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345744 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-31 17:31:35 +00:00
Eric Fiselier
e6f91d8017 Make libc++'s versioning namespace customizable
Summary:
This patch makes the versioning namespace libc++ uses customizable by the user using `-DLIBCXX_ABI_NAMESPACE=__foo`. 

This allows users to build custom versions of libc++ which can be linked into binaries with other libc++ versions without causing symbol conflicts or ODR issues. 

Reviewers: mclow.lists, ldionne

Reviewed By: ldionne

Subscribers: kristina, smeenai, mgorny, phosek, libcxx-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345657 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-30 21:44:53 +00:00
Eric Fiselier
94ce26b410 Unify definition of _LIBCPP_BEGIN/END_NAMESPACE_STD
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345561 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-30 02:02:00 +00:00
Eric Fiselier
207b919735 Bug 39129: Speeding up partition_point/lower_bound/upper_bound/ by using unsigned division by 2 when possible.
Patch by Denis Yaroshevskiy (denis.yaroshevskij@gmail.com)

The rational and measurements can be found in the bug description: https://bugs.llvm.org/show_bug.cgi?id=39129

Reviewed as https://reviews.llvm.org/D52697


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345525 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-29 19:25:02 +00:00
Louis Dionne
640fa255b9 [libc++] Use exclude_from_explicit_instantiation instead of always_inline
Summary:
This commit adopts the exclude_from_explicit_instantiation attribute discussed
at [1] and reviewed in [2] in libc++ to supplant the use of __always_inline__
for visibility purposes.

This change means that users wanting to link together translation units built
with different versions of libc++'s headers into the same final linked image
MUST define the _LIBCPP_HIDE_FROM_ABI_PER_TU macro to 1 when building those
TUs. Doing otherwise will lead to ODR violations and ABI issues.

[1]: http://lists.llvm.org/pipermail/cfe-dev/2018-August/059024.html
[2]: https://reviews.llvm.org/D51789

Reviewers: rsmith, EricWF

Subscribers: dexonsmith, libcxx-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345516 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-29 17:30:04 +00:00
Eric Fiselier
293b83d6e6 Fix PR39458 _LIBCPP_DEBUG breaks heterogeneous compare.
The types/comparators passed to std::upper_bound and std::lower_bound
are not required to provided to provide an operator</comp(...) which
accepts the arguments in reverse order. Nor are the ranges required
to have a strict weak ordering.

However, in debug mode we attempted to check the result of a comparison
with the arguments reversed, which may not compiler.

This patch removes the use of the debug comparator for upper_bound
and lower_bound.

equal_range et al still use debug comparators when they call
__upper_bound and __lower_bound.

See llvm.org/PR39458

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345434 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-26 22:54:46 +00:00
Eric Fiselier
e69682670c Fix incorrect use of aligned allocation in get_temporary_buffer.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345403 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-26 17:12:32 +00:00
Marshall Clow
5be216356b Run the min/max tests agaist the header <charconv>. Fix that header so it passes. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345352 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-26 01:00:56 +00:00
Eric Fiselier
b3ae0c8902 fix incorrect placement of _LIBCPP_ALWAYS_INLINE in valarray
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345289 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-25 17:43:26 +00:00
Eric Fiselier
e09f85bbe5 Implement sized deallocation for std::allocator and friends.
Summary:
C++14 sized deallocation is disabled by default due to ABI concerns. However, when a user manually enables it then libc++ should take advantage of it since sized deallocation can provide a significant performance win depending on the underlying malloc implementation. (Note that libc++'s definitions of sized delete don't do anything special yet, but users are free to provide their own).

This patch updates __libcpp_deallocate to selectively call sized operator delete when it's available. `__libcpp_deallocate_unsized` should be used when the size of the allocation is unknown.

On Apple this patch makes no attempt to determine if the sized operator delete is unavailable, only that the language feature is enabled. This could cause a compile error when using `std::allocator`, but the same compile error would occur whenever the user calls `new`, so I don't think it's a problem.

Reviewers: ldionne, mclow.lists

Reviewed By: ldionne

Subscribers: rsmith, ckennelly, libcxx-commits, christof

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345281 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-25 17:21:30 +00:00
Louis Dionne
07f95bd10d [libc++] Make sure we can build libc++ with -fvisibility=hidden
Summary:
When building with -fvisibility=hidden, some symbols do not get exported from
libc++.dylib. This means that some entities are not explicitly given default
visibility in the source code, and that we rely on the fact -fvisibility=default
is the default. This commit explicitly gives default visibility to those
symbols to avoid being dependent on the command line flags used.

The commit also remove symbols from the dylib -- those symbols do not
actually need to be exported from the dylib and this should not be an
ABI break.

Finally, in the future, we may want to mark the whole std:: namespace as
having hidden visibility (to switch from opt-out to opt-in), in which
case the changes done in this commit will be required.

Reviewers: EricWF

Subscribers: mgorny, christof, dexonsmith, libcxx-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345260 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-25 12:13:43 +00:00
Eric Christopher
92d87364ff Revert "Fix use of __libcpp_deallocate in dynarray"
This reverts commit r345234 as it depended on the sized deallocation commit.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345240 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-25 06:43:56 +00:00
Eric Christopher
1b9ee84408 Temporarily Revert "Implement sized deallocation for std::allocator and friends."
This is breaking the bots here (and related): http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-asan/builds/1428

This reverts commit r345214.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345239 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-25 06:20:12 +00:00
Eric Fiselier
d03e037f46 Fix use of __libcpp_deallocate in dynarray
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345234 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-25 02:36:31 +00:00
Eric Fiselier
0cfdf55219 Implement sized deallocation for std::allocator and friends.
Summary:
C++14 sized deallocation is disabled by default due to ABI concerns. However, when a user manually enables it then libc++ should take advantage of it since sized deallocation can provide a significant performance win depending on the underlying malloc implementation. (Note that libc++'s definitions of sized delete don't do anything special yet, but users are free to provide their own).

This patch updates __libcpp_deallocate to selectively call sized operator delete when it's available. `__libcpp_deallocate_unsized` should be used when the size of the allocation is unknown.

On Apple this patch makes no attempt to determine if the sized operator delete is unavailable, only that the language feature is enabled. This could cause a compile error when using `std::allocator`, but the same compile error would occur whenever the user calls `new`, so I don't think it's a problem.

Reviewers: ldionne, mclow.lists

Reviewed By: ldionne

Subscribers: rsmith, ckennelly, libcxx-commits, christof

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345214 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-24 22:44:01 +00:00
Petr Hosek
842383f69c Revert "Teach __libcpp_is_floating_point that __fp16 and _Float16 are"
This reverts commits r333103 and r333108. _Float16 and __fp16 are C11
extensions and compilers other than Clang don't define these for C++.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345199 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-24 21:29:15 +00:00
Marshall Clow
ec22e35e69 Off-by-one errors strike again. Thank goodness for ASAN and the bots.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345076 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-23 20:07:45 +00:00
Marshall Clow
b994bfeaac When filling a vector<bool> with stuff, initialize the last word of the storage that you're touching. Otherwise, when we lay down the bits with operator&=, we get UB from reading uninitialized memory. Fixes Bug 39354. Thanks to David Wagner for the bug report.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@345067 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-23 18:38:15 +00:00
Marshall Clow
1f63d28c70 Update commnents to reflect the changes for LWG#3127. NFC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344953 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-22 20:50:06 +00:00
Marshall Clow
3d1d9230d8 Update commnents to reflect the changes for LWG#3122. NFC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344950 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-22 20:44:37 +00:00
Louis Dionne
d74c17e91a [libcxx] Avoid repeating the definition of std:: namespaces
This reduces code duplication a tiny bit.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344642 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-16 20:02:59 +00:00
Louis Dionne
3845a650ef [libcxx] Remove _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY
That macro has been defined to _LIBCPP_HIDE_FROM_ABI_AFTER_V1 for many
weeks now, so we're actually replacing uses of it for uses of
_LIBCPP_HIDE_FROM_ABI_AFTER_V1 directly.

This should not change or break anything since the two macros are
100% equivalent, unless somebody is (incorrectly!) relying on
_LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY being defined.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344641 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-16 19:26:23 +00:00
Marshall Clow
cc5c12d9de Recommit <chrono> changes with a couple xtra tests marked to fail on apple's clang. Reviewed as D51762
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344627 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-16 17:27:54 +00:00
Marshall Clow
7e3ab17c11 Partial fix for PR38964. (<string> can't be built with gcc -std=c++03) Reviewed as https://reviews.llvm.org/D52240
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344616 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-16 16:02:18 +00:00
Artem Dergachev
7f20dc6854 Revert r344529 "Implement the first part of the calendar support for C++20"
Revert r344535 "Wrap up the new chrono literals in an #ifdef..."
Revert r344546 "Mark a couple of test cases as 'C++17-only'..."

Some of the buildbot failures were masked by another error,
and this one was probably missed.


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344580 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-16 02:40:42 +00:00
Marshall Clow
1b8e200470 Wrap up the new chrono literals in an #ifdef so that old versions of clang don't complain. I'm looking at you, clang 5.0.1
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344535 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-15 17:33:20 +00:00
Marshall Clow
fc25eebcac Implement the first part of the calendar support for C++20. This is still incomplete; there will be more patches coming. Reviewed as D51762
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344529 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-15 16:06:37 +00:00
Marshall Clow
b233fda723 Revert commit r344254; does not work with C++03
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344261 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-11 17:28:57 +00:00
Marshall Clow
2199647acb Prefer to use the __is_XXX compiler intrinsics to the (old, busted) __has_XXX intrinsics when implementing type traits. Thanks to Richard Smith for the patch.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344254 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-11 15:38:07 +00:00
Eric Fiselier
f9c56dae68 Fix use of removed _LIBCPP_HAS_NO_BUILTIN_ALIGNED_OPERATOR_NEW_DELETE
It was replaced with the better named
_LIBCPP_HAS_NO_BUILTIN_OVERLOADED_OPERATOR_NEW_DELETE.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344214 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-11 01:48:00 +00:00
Eric Fiselier
657a13025c Distinguish between library and language support for aligned allocation.
There are two cases:
1. The library has all it needs to provide align_val_t and the
new/delete overloads needed to support aligned allocation.
2. The compiler has actually turned the language feature on.

There are times where libc++ needs to distinguish between the two.

This patch adds the additional macro
_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION which denotes when case (1)
does not hold. _LIBCPP_HAS_NO_ALIGNED_ALLOCATION is defined whenever
_LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION is defined, or when the
compiler has not enabled the language feature.

Additionally this patch cleans up a number of other macros related
to detection of aligned allocation machinery.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344207 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-11 00:17:24 +00:00
Aaron Puchert
f7d5bd26cd Annotate scoped_lock as with scoped_lockable attribute
Summary:
Scoped capabilities need to be annotated as such, otherwise the thread
safety analysis won't work as intended.

Fixes PR39234.

Reviewers: ldionne

Reviewed By: ldionne

Subscribers: christof, libcxx-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@344096 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-09 23:42:29 +00:00
Marshall Clow
c7cc66995c Do the math in uniform_int_distribution::operator() as unsigned to prevent UB when overflowing. Also add a UBSAN notification that we're ffine with unsigned overflow. This fixes PR#32617. Thanks to Vincent & Christoph for their help with this issue.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@343996 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-08 20:20:34 +00:00
Louis Dionne
072260345c [libc++][NFC] Add error messages to a couple of static_asserts in span
Summary:
Add error messages to a couple of static_asserts in span to match the
style used in the rest of the file. Also fix an extra paren typo in a
assert error message.

Committed on behalf of Jason Lovett.

Reviewers: ldionne

Subscribers: libcxx-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@343725 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-03 21:36:16 +00:00
Eric Fiselier
d545268777 Attempt to fix aligned allocation configuration under clang-cl
When we're using clang-cl and Microsoft's runtime implementation,
we don't provide align_val_t or aligned new/delete ourselves.

This patch updates the _LIBCPP_HAS_NO_ALIGNED_ALLOCATION macro
to reflect this.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@343441 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-01 04:08:06 +00:00
Eric Fiselier
1ef0f1032d Fix Shadowing warning on Windows
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@343439 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-01 02:54:08 +00:00
Eric Fiselier
f7fac08d5b Fix even more Clang warnings.
This patch disables shift-sign-overflow warnings for now. It also
fixes most -Wfloat-equal warnings and -Wextra-semi warnings.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@343438 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-01 01:59:37 +00:00