summaryrefslogtreecommitdiffstats
path: root/libcxx/include
Commit message (Collapse)AuthorAgeFilesLines
...
* [libc++] Take 2: Integrate the PSTL into libc++Louis Dionne2019-08-057-0/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This commit allows specifying LIBCXX_ENABLE_PARALLEL_ALGORITHMS when configuring libc++ in CMake. When that option is enabled, libc++ will assume that the PSTL can be found somewhere on the CMake module path, and it will provide the C++17 parallel algorithms based on the PSTL (that is assumed to be available). The commit also adds support for running the PSTL tests as part of the libc++ test suite. The first attempt to commit this failed because it exposed a bug in the tests for modules. Now that this has been fixed, it should be safe to commit this. Reviewers: EricWF Subscribers: mgorny, christof, jkorous, dexonsmith, libcxx-commits, mclow.lists, EricWF Tags: #libc Differential Revision: https://reviews.llvm.org/D60480 llvm-svn: 367903
* Revert "Suppress -Wctad-maybe-unsupported on types w/o deduction guides."Eric Fiselier2019-08-047-18/+1
| | | | | | | | | Some modules builds are issuing buggy diagnostics. The cause of which is TBD. This reverts commit r@367770. llvm-svn: 367777
* Suppress -Wctad-maybe-unsupported on types w/o deduction guides.Eric Fiselier2019-08-037-1/+18
| | | | | | | | | | | There are a handful of standard library types that are intended to support CTAD but don't need any explicit deduction guides to do so. This patch adds a dummy deduction guide to those types to suppress -Wctad-maybe-unsupported (which gets emitted in user code). llvm-svn: 367770
* Revert accidental change to __member_pointer_traits_imp.Eric Fiselier2019-08-031-1/+3
| | | | | | | A previous patch accidentally made the primary template an incomplete type. This broke some C++03 constructs. llvm-svn: 367762
* Simplify <type_traits> implementations.Eric Fiselier2019-08-031-67/+36
| | | | | | | | | | | | This patch rewrites a number of old meta-function implementations that assumed const/volatile could not be safely applied to all types. This is no longer the case, though for some types (Ex function types), the const qualifier can be ignored. The largest improvement in this patch is the reduction of is_function. Thanks to Matt Calabrese for the improved implementation. llvm-svn: 367749
* Refactor deque to centralize handling of spare blocks.Eric Fiselier2019-08-011-48/+50
| | | | | | | | I have upcoming changes that modify how deque handles spare blocks. This cleanup is intended to make those changes easier to review and understand. This patch should have NFC. llvm-svn: 367631
* Change default bucket count in hash_set/hash_map.Eric Fiselier2019-08-012-13/+12
| | | | | | | | | | | Previously these types rehashed to a table of 193 elements upon construction. But this is non-ideal, first because default constructors should not allocate unless necessary, and second because 193 is big and can waste a bunch of memory. This number had previously been chosen to match GCC's implementation. llvm-svn: 367605
* libcxx: Define __STDCPP_THREADS__ to 1, not to __cplusplus.Nico Weber2019-07-302-4/+8
| | | | | | | | | | | | | | | | | | | [cpp.predefined]p2: __STDCPP_THREADS__ Defined, and has the value integer literal 1, if and only if a program can have more than one thread of execution . Also define it only if it's not defined already, since it's supposed to be defined by the compiler. Also move it from thread to __config (which requires setting it only if _LIBCPP_HAS_NO_THREADS is not defined). Part of PR33230. The intent is to eventually make the compiler define this instead. llvm-svn: 367316
* Fix PR35637: suboptimal codegen for `vector<unsigned char>`.Eric Fiselier2019-07-281-95/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The optimizer is petulant and temperamental. In this case LLVM failed to lower the the "insert at end" loop used by`vector<unsigned char>` to a `memset` despite `memset` being substantially faster over a range of bytes. LLVM has the ability to lower loops to `memset` whet appropriate, but the odd nature of libc++'s loops prevented the optimization from taking places. This patch addresses the issue by rewriting the loops from the form `do [ ... --__n; } while (__n > 0);` to instead use a for loop over a pointer range (For example: `for (auto *__i = ...; __i < __e; ++__i)`). This patch also rewrites the asan annotations to unposion all additional memory at the start of the loop instead of once per iterations. This could potentially permit false negatives where the constructor of element N attempts to access element N + 1 during its construction. The before and after results for the `BM_ConstructSize/vector_byte/5140480_mean` benchmark (run 5 times) are: -------------------------------------------------------------------------------------------- Benchmark Time CPU Iterations -------------------------------------------------------------------------------------------- Before ------ BM_ConstructSize/vector_byte/5140480_mean 12530140 ns 12469693 ns N/A BM_ConstructSize/vector_byte/5140480_median 12512818 ns 12445571 ns N/A BM_ConstructSize/vector_byte/5140480_stddev 106224 ns 107907 ns 5 ----- After ----- BM_ConstructSize/vector_byte/5140480_mean 167285 ns 166500 ns N/A BM_ConstructSize/vector_byte/5140480_median 166749 ns 166069 ns N/A BM_ConstructSize/vector_byte/5140480_stddev 3242 ns 3184 ns 5 llvm-svn: 367183
* Fix a bug in std::chrono::abs where it would fail when the duration's period ↵Marshall Clow2019-07-261-1/+1
| | | | | | had not been reduced.s llvm-svn: 367120
* [NFC][libcxx] Add comments about making mutex/condition_variable trivial on ↵Louis Dionne2019-07-251-3/+13
| | | | | | | | | Apple platforms Leaving some comments behind so that we avoid re-having that discussion in the future. llvm-svn: 367048
* Implement change #4 of P1466: Change weekday to accept both 0 and 7 as ↵Marshall Clow2019-07-251-6/+7
| | | | | | Sunday. Add accessors 'c_encoding' and 'iso_encoding' to provide different interpretations of the weekday. Remove 'operator unsigned' llvm-svn: 366981
* Implement most of P1612R1: Relocate endian. Moves the std::endian ↵Marshall Clow2019-07-232-15/+21
| | | | | | functionality from 'type-traits' to 'bit'. No other change. The reason that this is 'partial' is that P1621 also recommends a feature-test macro, but I don't have the value for that one yet. In a month or so, I'll add that llvm-svn: 366776
* [NFC][libc++] Add missing EXPLICIT to pair and tuple synopsisLouis Dionne2019-07-222-16/+16
| | | | | | | The constructors for std::pair and std::tuple have been made conditionally explicit, however the synopsis in the headers do not reflect that. llvm-svn: 366735
* [libc++] Set __file_ to 0 in basic_filebuf::close() even if fclose failsPetr Hosek2019-07-221-3/+2
| | | | | | | | | | | | | | | | | | | | This issue was detected by ASan in one of our tests. This test manually invokes basic_filebuf::cloe(). fclose(__h.release() returned a non-zero exit status, so __file_ wasn't set to 0. Later when basic_filebuf destructor ran, we would enter the if (__file_) block again leading to heap-use-after-free error. The POSIX specification for fclose says that independently of the return value, fclose closes the underlying file descriptor and any further access (including another call to fclose()) to the stream results in undefined behavior. This is exactly what happened in our test case. To avoid this issue, we have to always set __file_ to 0 independently of the fclose return value. Differential Revision: https://reviews.llvm.org/D64979 llvm-svn: 366730
* Revert "[libc++] Integrate the PSTL into libc++"Louis Dionne2019-07-197-37/+0
| | | | | | | This reverts r366593, which caused unforeseen breakage on the build bots. I'm reverting until the problems have been figured out and fixed. llvm-svn: 366603
* [libc++] Use _EnableIf instead of std::enable_if in deduction guides for map ↵Louis Dionne2019-07-192-24/+24
| | | | | | and set llvm-svn: 366594
* [libc++] Integrate the PSTL into libc++Louis Dionne2019-07-197-0/+37
| | | | | | | | | | | | | | | | | | | | | | Summary: This commit allows specifying LIBCXX_ENABLE_PARALLEL_ALGORITHMS when configuring libc++ in CMake. When that option is enabled, libc++ will assume that the PSTL can be found somewhere on the CMake module path, and it will provide the C++17 parallel algorithms based on the PSTL (that is assumed to be available). The commit also adds support for running the PSTL tests as part of the libc++ test suite. Reviewers: rodgert, EricWF Subscribers: mgorny, christof, jkorous, dexonsmith, libcxx-commits, mclow.lists, EricWF Tags: #libc Differential Revision: https://reviews.llvm.org/D60480 llvm-svn: 366593
* [libc++] Fix link error with _LIBCPP_HIDE_FROM_ABI_PER_TU and std::stringLouis Dionne2019-07-191-10/+0
| | | | | | | | | | | | | | | | | | | | | Summary: This is effectively a revert of r344616, which was a partial fix for PR38964 (compilation of <string> with GCC in C++03 mode). However, that configuration is explicitly not supported anymore and that partial fix breaks compilation with Clang when per-TU insulation is provided. PR42676 rdar://52899715 Reviewers: mclow.lists, EricWF Subscribers: christof, jkorous, dexonsmith, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D64941 llvm-svn: 366567
* [libc++] Add C++17 deduction guides for std::functionLouis Dionne2019-07-181-0/+54
| | | | | | | | | | | | Summary: http://llvm.org/PR39606 Reviewers: Quuxplusone Subscribers: christof, dexonsmith, libcxx-commits Differential Revision: https://reviews.llvm.org/D54410 llvm-svn: 366484
* Bump the trunk version to 10.0.0svnHans Wennborg2019-07-182-2/+2
| | | | | | and clear the release notes. llvm-svn: 366427
* Add contains method to associative containers. This patch implements ↵Zoe Carver2019-07-164-5/+50
| | | | | | P0458R2, adding contains to map, multimap, unordered_map, unordered_multimap, set, multiset, unordered_set, and unordered_multiset. llvm-svn: 366170
* [libc++] Implement P0433: deduction guides for <unordered_map>Louis Dionne2019-07-151-6/+140
| | | | | | | | Thanks to Arthur O'Dwyer for the patch. Differential Revision: https://reviews.llvm.org/D58590 llvm-svn: 366124
* Improve compile time of variant.Eric Fiselier2019-07-141-31/+36
| | | | | | | | | | In particular, improve the compile time of the overload set builder that variant uses to determine which alternative to construct. Instead of having the __overload type construct itself recursively, this patch uses a flat construction for the overload set. llvm-svn: 366033
* Cleanup whitespace in <variant>. NFC.Eric Fiselier2019-07-141-11/+7
| | | | llvm-svn: 366026
* Avoid eager template instantiation caused by the variant narrowing checks.Eric Fiselier2019-07-141-8/+28
| | | | | | | | | | | | | | | | | | The standard disallows narrowing conversions when constructing a variant. This is checked by attempting to perform braced initialization of the destination type from the argument type. However, braced initialization can force the compiler (mostly clang) to eagerly instantiate the constructors of the destintation type -- which can lead to errors in a non-immediate context. However, as variant is currently specified, the narrowing checks only observably apply when the destination type is arithmetic. Meaning we can skip the check for class types. Hense avoiding the hard errors. In order to cause fewer build breakages, this patch avoids the narrowing check except when the destination type is arithmetic. llvm-svn: 366022
* Fix non-conformance it `std::tuple`.Eric Fiselier2019-07-121-20/+31
| | | | | | | | | | | | | | Previously we implemented all one trillion tuple-like constructors using a single generic overload. This worked fairly well, except that it differed in behavior from the standard version because it didn't consider both T&& and T const&. This was observable for certain types. This patch addresses that issue by splitting the generic constructor in two. We now provide both T&& and T const& versions of the tuple-like constructors (sort of). llvm-svn: 365973
* Add option to disable variant narrowing conversion changes.Eric Fiselier2019-07-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The paper P0608R3 - "A sane variant converting constructor" disallows narrowing conversions in variant. It was meant to address this surprising problem: std::variant<std::string, bool> v = "abc"; assert(v.index() == 1); // constructs a bool. However, it also disables every potentially narrowing conversion. For example: variant<unsigned> v = 0; // ill-formed variant<string, double> v2 = 42; // ill-formed (int -> double narrows) These latter changes break code. A lot of code. Within Google it broke on the order of a hundred thousand target with thousands of root causes responsible for the breakages. Of the breakages related to the narrowing restrictions, none of them exposed outstanding bugs. However, the breakages caused by boolean conversions (~13 root causes), all but one of them were bugs. For this reasons, I am adding a flag to disable the narrowing conversion changes but not the boolean conversions one. One purpose of this flag is to allow users to opt-out of breaking changes in variant until the offending code can be cleaned up. For non-trivial variant usages the amount of cleanup may be significant. This flag is also required to support automated tooling, such as clang-tidy, that can automatically fix code broken by this change. In order for clang-tidy to know the correct alternative to construct, it must know what alternative was being constructed previously, which means running it over the old version of std::variant. Because this change breaks so much code, I will be implementing the aforementioned clang-tidy check in the very near future. Additionally I'm plan present this new information to the committee so they can re-consider if this is a breaking change we want to make. I think libc++ should very seriously consider pulling this change before the 9.0 release branch is cut. But that's a separate discussion that I will start on the lists. For now this is the minimal first step. llvm-svn: 365960
* Reorganize the 'bit' header to make most of the facilities available for ↵Marshall Clow2019-07-124-117/+193
| | | | | | internal use pre-C++20. NFC for external users llvm-svn: 365854
* Fix memory leak in set and map.Eric Fiselier2019-07-111-118/+76
| | | | | | | | When assigning an initializer list into set/map, libc++ would leak memory if the initializer list contained equivalent keys because we failed to check if the insertion was successful. llvm-svn: 365840
* [libc++] Implement deduction guides for <unordered_set>Louis Dionne2019-07-111-6/+116
| | | | | | | Thanks to Arthur O'Dwyer for the patch. Differential Revision: https://reviews.llvm.org/D58617 llvm-svn: 365788
* Make forward_list::remove/remove_if/unique all return void before C++20; ↵Marshall Clow2019-07-082-20/+28
| | | | | | undoes that bit of D58332. Thanks to Mikhail Maltsev for pointing this out llvm-svn: 365290
* Make ~mutex and ~condition_variable trivial on Windows.Eric Fiselier2019-07-072-15/+18
| | | | | | | | | The implementations of __libcpp_mutex_destroy and __libcpp_condvar_destroy are already NOPs, so this optimization is safe to perform. See r365273 and PR27658 for more information. llvm-svn: 365281
* Fix PR27658 - Make ~mutex trivial when possible.Eric Fiselier2019-07-072-13/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently std::mutex has a constexpr constructor, but a non-trivial destruction. The constexpr constructor is required to ensure the construction of a mutex with static storage duration happens at compile time, during constant initialization, and not during dynamic initialization. This means that static mutex's are always initialized and can be used safely during dynamic initialization without the "static initialization order fiasco". A trivial destructor is important for similar reasons. If a mutex is used during dynamic initialization it might also be used during program termination. If a static mutex has a non-trivial destructor it will be invoked during termination. This can introduce the "static deinitialization order fiasco". Additionally, function-local statics emit a guard variable around non-trivially destructible types. This results in horrible codegen and adds a runtime cost to every call to that function. non-local static's also result in slightly worse codegen but it's not as big of a problem. Example codegen can be found here: https://goo.gl/3CSzbM Note: This optimization is not safe with every pthread implementation. Some implementations allocate on the first call to pthread_mutex_lock and free the allocation in pthread_mutex_destroy. Also, changing the triviality of the destructor is not an ABI break. At least to the best of my knowledge :-) llvm-svn: 365273
* Make list::remove/remove_if/unique all return void before C++20; undoes that ↵Marshall Clow2019-07-061-14/+19
| | | | | | bit of D58332. Thanks to Mikhail Maltsev for pointing this out llvm-svn: 365261
* This patch makes swap functions constexpr. Both swap overloads, swap_ranges ↵Zoe Carver2019-07-052-4/+5
| | | | | | and iter_swap are updated (with tests). llvm-svn: 365238
* Fix tuple's conditionally explicit constructors for very weird userEric Fiselier2019-07-031-1/+10
| | | | | | | | | | | | types. It seems some people like to write types that can explicitly convert to anything, but cannot be used to explicitly construct anything. This patch makes tuple tolerate such types, as is required by the standard. llvm-svn: 365074
* [libc++] Update availability markup for Filesystem on Apple platformsLouis Dionne2019-07-031-8/+8
| | | | llvm-svn: 365068
* Use new '__libcpp_is_constant_evaluated' call to remove an '#ifdef' from the ↵Marshall Clow2019-07-021-6/+2
| | | | | | bit code. NFC llvm-svn: 364884
* Mark the newly added '__libcpp_is_constant_evaluated' as 'inline', since it ↵Marshall Clow2019-07-021-2/+4
| | | | | | can be included multiple times by multiple headers, and we don't want 'duplicate definition' errors. llvm-svn: 364879
* Add a private call '__libcpp_is_constant_evaluated' which 'works' for old ↵Marshall Clow2019-07-011-1/+6
| | | | | | language versions and w/o any compiler support. 'Working', in this case, means that it returns false in those cases. llvm-svn: 364873
* Bit Operations: P0556, P0553 and P1355. Reviewed as: ↵Marshall Clow2019-07-011-18/+254
| | | | | | https://reviews.llvm.org/D51262 llvm-svn: 364862
* Ensure bitset's string constructor doesn't poison the overload set.Eric Fiselier2019-07-012-2/+6
| | | | llvm-svn: 364842
* Implement P0646R1: Erase-Like Algorithms Should Return size_type. Reviewed ↵Marshall Clow2019-07-012-34/+43
| | | | | | as https://reviews.llvm.org/D58332, and then updated because I rewrote a couple of those routines to eliminate some UB. Thanks to Zoe for tghe patch. llvm-svn: 364840
* Implement LWG2221: 'Formatted output for nullptr_t' Reviewed as: ↵Marshall Clow2019-07-011-0/+5
| | | | | | https://reviews.llvm.org/D63053 llvm-svn: 364802
* __threading_support: Remove (void) in favor of ().Bruce Mitchener2019-07-011-2/+2
| | | | | | | | | | | | | | Summary: This fixes a clang-tidy warning when building something that uses this file. Reviewers: mclow.lists, EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43226 llvm-svn: 364799
* Fix -Wdouble-promotion warnings.Bruce Mitchener2019-07-012-3/+3
| | | | | | | | | | Reviewers: mclow.lists Subscribers: christof, ldionne, cfe-commits, libcxx-commits Differential Revision: https://reviews.llvm.org/D62782 llvm-svn: 364798
* Add a missing '__uncvref_t' to the SFINAE constraints for optional's ↵Marshall Clow2019-06-271-1/+1
| | | | | | assignment operator. Fixes PR38638. Thanks to Jonathan Wakely for the report llvm-svn: 364574
* Provide hashers for string_view only if they are using the default ↵Marshall Clow2019-06-271-4/+4
| | | | | | char_traits. Seen on SO: test/std/strings/string.view/string.view.hash/char_type.hash.fail.cpp llvm-svn: 364545
* Revert "Change the ABI version and ABI namespace to be `_LIBCPP_VERSION`"Eric Fiselier2019-06-261-12/+5
| | | | | | | | | There are some suspicious bot failures that I want to ensure aren't caused by this patch. I'll recommit tomorrow. llvm-svn: 364363
OpenPOWER on IntegriCloud