Commit Graph

2338 Commits

Author SHA1 Message Date
Louis Dionne d1ad7b31ee [NFC] Fix incorrect comment in std::list
llvm-svn: 346072
2018-11-03 17:51:09 +00:00
Louis Dionne e0a724ef9c 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.

llvm-svn: 345893
2018-11-01 21:24:32 +00:00
Reid Kleckner 60cce5c782 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

llvm-svn: 345870
2018-11-01 18:24:03 +00:00
Louis Dionne 8df1d5a546 [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.

llvm-svn: 345834
2018-11-01 14:41:37 +00:00
Erik Pilkington 5c4e07ae5c 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

llvm-svn: 345744
2018-10-31 17:31:35 +00:00
Eric Fiselier fe13c13cc2 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

llvm-svn: 345657
2018-10-30 21:44:53 +00:00
Eric Fiselier 2f3e8b3d2e Unify definition of _LIBCPP_BEGIN/END_NAMESPACE_STD
llvm-svn: 345561
2018-10-30 02:02:00 +00:00
Eric Fiselier 8c40d81d4f 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

llvm-svn: 345525
2018-10-29 19:25:02 +00:00
Louis Dionne e9d85264ac [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

llvm-svn: 345516
2018-10-29 17:30:04 +00:00
Eric Fiselier e503a1c3b8 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

llvm-svn: 345434
2018-10-26 22:54:46 +00:00
Eric Fiselier 43245b1f3b Fix incorrect use of aligned allocation in get_temporary_buffer.
llvm-svn: 345403
2018-10-26 17:12:32 +00:00
Marshall Clow 27e9fdb2ff Run the min/max tests agaist the header <charconv>. Fix that header so it passes. NFC.
llvm-svn: 345352
2018-10-26 01:00:56 +00:00
Eric Fiselier 8622e866a6 fix incorrect placement of _LIBCPP_ALWAYS_INLINE in valarray
llvm-svn: 345289
2018-10-25 17:43:26 +00:00
Eric Fiselier f25b75b91b 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

llvm-svn: 345281
2018-10-25 17:21:30 +00:00
Louis Dionne 9b3222f613 [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

llvm-svn: 345260
2018-10-25 12:13:43 +00:00
Eric Christopher 9ecdb5a711 Revert "Fix use of __libcpp_deallocate in dynarray"
This reverts commit r345234 as it depended on the sized deallocation commit.

llvm-svn: 345240
2018-10-25 06:43:56 +00:00
Eric Christopher 9bbee38db3 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.

llvm-svn: 345239
2018-10-25 06:20:12 +00:00
Eric Fiselier 46493ac9b5 Fix use of __libcpp_deallocate in dynarray
llvm-svn: 345234
2018-10-25 02:36:31 +00:00
Eric Fiselier 7e6448bb02 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

llvm-svn: 345214
2018-10-24 22:44:01 +00:00
Petr Hosek 76ccec07b4 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

llvm-svn: 345199
2018-10-24 21:29:15 +00:00
Marshall Clow 5ac28a0cfd Off-by-one errors strike again. Thank goodness for ASAN and the bots.
llvm-svn: 345076
2018-10-23 20:07:45 +00:00
Marshall Clow 55fb053f57 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.
llvm-svn: 345067
2018-10-23 18:38:15 +00:00
Marshall Clow 2d7bde547f Update commnents to reflect the changes for LWG#3127. NFC
llvm-svn: 344953
2018-10-22 20:50:06 +00:00
Marshall Clow 05fe329687 Update commnents to reflect the changes for LWG#3122. NFC
llvm-svn: 344950
2018-10-22 20:44:37 +00:00
Louis Dionne 4084df0040 [libcxx] Avoid repeating the definition of std:: namespaces
This reduces code duplication a tiny bit.

llvm-svn: 344642
2018-10-16 20:02:59 +00:00
Louis Dionne 7833b88ad8 [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.

llvm-svn: 344641
2018-10-16 19:26:23 +00:00
Marshall Clow 5b08c1742a Recommit <chrono> changes with a couple xtra tests marked to fail on apple's clang. Reviewed as D51762
llvm-svn: 344627
2018-10-16 17:27:54 +00:00
Marshall Clow 69067f2bfd Partial fix for PR38964. (<string> can't be built with gcc -std=c++03) Reviewed as https://reviews.llvm.org/D52240
llvm-svn: 344616
2018-10-16 16:02:18 +00:00
Artem Dergachev a9bc0face5 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.

llvm-svn: 344580
2018-10-16 02:40:42 +00:00
Marshall Clow 323e01d46f 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
llvm-svn: 344535
2018-10-15 17:33:20 +00:00
Marshall Clow 06ba9f5246 Implement the first part of the calendar support for C++20. This is still incomplete; there will be more patches coming. Reviewed as D51762
llvm-svn: 344529
2018-10-15 16:06:37 +00:00
Marshall Clow c83d283a2e Revert commit r344254; does not work with C++03
llvm-svn: 344261
2018-10-11 17:28:57 +00:00
Marshall Clow e98be18311 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.
llvm-svn: 344254
2018-10-11 15:38:07 +00:00
Eric Fiselier 33e402ae2b 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.

llvm-svn: 344214
2018-10-11 01:48:00 +00:00
Eric Fiselier 42f9868cd8 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.

llvm-svn: 344207
2018-10-11 00:17:24 +00:00
Aaron Puchert 7f208f02db 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

llvm-svn: 344096
2018-10-09 23:42:29 +00:00
Marshall Clow 2dd5335204 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.
llvm-svn: 343996
2018-10-08 20:20:34 +00:00
Louis Dionne 98faa3976d [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

llvm-svn: 343725
2018-10-03 21:36:16 +00:00
Eric Fiselier b6f4d445f0 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.

llvm-svn: 343441
2018-10-01 04:08:06 +00:00
Eric Fiselier a0e23576b8 Fix Shadowing warning on Windows
llvm-svn: 343439
2018-10-01 02:54:08 +00:00
Eric Fiselier 0b485f3e91 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.

llvm-svn: 343438
2018-10-01 01:59:37 +00:00
Louis Dionne f9a52903ef [libc++] Remove Fuchsia-specific knowledge to pick the ABI version
Summary:
The ABI version used by libc++ is a configuration option just like any other
configuration option. It is a knob that can be used by vendors to customize
the libc++ that they ship. As such, we should not be hardcoding vendor-specific
configuration choices in libc++.

When building libc++ for Fuchsia, Fuchsia's build scripts should simply define
the libc++ ABI version to 2 -- this will result in the _LIBCPP_ABI_VERSION
macro being defined in the __config header that is generated when libc++ is
built and installed, which is the correct way to customize libc++'s behavior
for specific vendors.

Reviewers: phosek, EricWF

Subscribers: mgorny, christof, dexonsmith, cfe-commits, libcxx-commits

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

llvm-svn: 343079
2018-09-26 08:24:51 +00:00
Louis Dionne ea5cd3b476 [libc++] Add deprecated attributes to many deprecated components
Summary:
These deprecation warnings are opt-in: they are only enabled when the
_LIBCXX_DEPRECATION_WARNINGS macro is defined, which is not the case
by default. Note that this is a first step in the right direction, but
I wasn't able to get an exhaustive list of all deprecated components
per standard, so there's certainly stuff that's missing. The list of
components this commit marks as deprecated is:

in C++11:
- auto_ptr, auto_ptr_ref
- binder1st, binder2nd, bind1st(), bind2nd()
- pointer_to_unary_function, pointer_to_binary_function, ptr_fun()
- mem_fun_t, mem_fun1_t, const_mem_fun_t, const_mem_fun1_t, mem_fun()
- mem_fun_ref_t, mem_fun1_ref_t, const_mem_fun_ref_t, const_mem_fun1_ref_t, mem_fun_ref()

in C++14:
- random_shuffle()

in C++17:
- unary_negate, binary_negate, not1(), not2()

<rdar://problem/18168350>

Reviewers: mclow.lists, EricWF

Subscribers: christof, dexonsmith, llvm-commits

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

llvm-svn: 342843
2018-09-23 18:35:00 +00:00
Louis Dionne 0805a4fa9c [NFC][libcxx] Rename helpers with 4 underscores to something more reasonable
llvm-svn: 342840
2018-09-23 16:44:50 +00:00
Roman Lebedev c65d39a464 [libc++] Add _LIBCPP_ENABLE_NODISCARD and _LIBCPP_NODISCARD_EXT to allow pre-C++2a [[nodiscard]]
Summary:
The `[[nodiscard]]` attribute is intended to help users find bugs where
function return values are ignored when they shouldn't be. After C++17 the
C++ standard has started to declared such library functions as `[[nodiscard]]`.
However, this application is limited and applies only to dialects after C++17.
Users who want help diagnosing misuses of STL functions may desire a more
liberal application of `[[nodiscard]]`.

For this reason libc++ provides an extension that does just that! The
extension must be enabled by defining `_LIBCPP_ENABLE_NODISCARD`. The extended
applications of `[[nodiscard]]` takes two forms:

1. Backporting `[[nodiscard]]` to entities declared as such by the
   standard in newer dialects, but not in the present one.

2. Extended applications of `[[nodiscard]]`, at the libraries discretion,
   applied to entities never declared as such by the standard.

Users may also opt-out of additional applications `[[nodiscard]]` using
additional macros.

Applications of the first form, which backport `[[nodiscard]]` from a newer
dialect may be disabled using macros specific to the dialect it was added. For
example `_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17`.

Applications of the second form, which are pure extensions, may be disabled
by defining `_LIBCPP_DISABLE_NODISCARD_EXT`.

This patch was originally written by me (Roman Lebedev),
then but then reworked by Eric Fiselier.

Reviewers: mclow.lists, thakis, EricWF

Reviewed By: thakis, EricWF

Subscribers: llvm-commits, mclow.lists, lebedev.ri, EricWF, rjmccall, Quuxplusone, cfe-commits, christof

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

llvm-svn: 342808
2018-09-22 17:54:48 +00:00
Volodymyr Sapsai 8d6ac8f689 Revert "Implement LWG 2221 - No formatted output operator for nullptr."
This reverts r342566 as it causes on bots linker errors like

> Undefined symbols for architecture i386:
>   "std::__1::basic_ostream<char, std::__1::char_traits<char> >::operator<<(std::nullptr_t)", referenced from:

llvm-svn: 342599
2018-09-19 23:31:34 +00:00
Marshall Clow 4a71f9cfcc Implement LWG 2221 - No formatted output operator for nullptr. Reviewed as https://reviews.llvm.org/D44263
llvm-svn: 342566
2018-09-19 18:29:57 +00:00
Eric Fiselier 7dca3127c2 Don't require relops on variant alternatives to all return the same
type.

Libc++ correctly asserts that a set of visitors for a variant all
return the same type. However, we use the visitation machinary to
perform relational operations. This causes a static assertion when
some of the alternatives relops return a UDT which is implicitly
convertible to bool instead of 'bool' exactly.

llvm-svn: 342560
2018-09-19 17:53:21 +00:00
Fangrui Song cac6d21731 Fix typo
llvm-svn: 342361
2018-09-17 07:40:42 +00:00
Marshall Clow f56972e224 Implement the infrastructure for feature-test macros. Very few actual feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955
llvm-svn: 342073
2018-09-12 19:41:40 +00:00