summaryrefslogtreecommitdiffstats
path: root/libcxx/include/functional
Commit message (Collapse)AuthorAgeFilesLines
* Revert "Suppress -Wctad-maybe-unsupported on types w/o deduction guides."Eric Fiselier2019-08-041-2/+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-031-1/+2
| | | | | | | | | | | 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
* [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
* Apply new meta-programming traits throughout the library.Eric Fiselier2019-06-231-3/+3
| | | | | | The new meta-programming primitives are lower cost than the old versions. This patch removes those old versions and switches libc++ to use the new ones. llvm-svn: 364160
* Apply [[nodebug]] to typedefs throughout the STL.Eric Fiselier2019-06-121-3/+3
| | | | | | | | | | | | | | | | When applied to a typedef or alias template, the [[nodebug]] attribute makes the typedef transparent to the debugger, so instead of seeing `std::__function::__alloc_func<remove_reference<void(&)()>::type, allocator<remove_reference<void(&)()>, void()>::_Target` you see `void(&)()` as the type of the variable in your debugger. Removing all this SFINAE noise from debug info has huge binary size wins, in addition to improving the readability. For now this change is on by default. Users can override it by specifying -D_LIBCPP_NODEBUG_TYPE= llvm-svn: 363117
* Substantially reduce instantiations and debug size of std::functionEric Fiselier2019-06-081-19/+87
| | | | | | | | | | | | | | | | | std::function uses a standard allocator to manage its memory, however standard allocators are templates and using them correctly requires a stupid amount of instantiations. This leads to a substantial increase in debug info and object sizes. This patch addresses the issue by dropping the allocator when possible and using raw new and delete to get memory. This change decreases the object file size for the test func.wrap.func.con/F.pass.cpp by 33% and the final binary by 29% (when compiled with -g -ggnu-pubnames -gpubnames). It also roughly halfs the number of entries in the pubnames and pubtype sections. llvm-svn: 362865
* [libc++] Use std::is_nothrow_callable for std::invoke according to LWG 2807Louis Dionne2019-04-031-2/+6
| | | | | | | Thanks to Zoe Carver for the patch. Differential Revision: https://reviews.llvm.org/D58097 llvm-svn: 357616
* [libc++] Fix Windows build error in <functional>Thomas Anderson2019-01-291-5/+6
| | | | | | | | | | | | On my Windows system, __allocator is defined to nothing. This change fixes build errors of the below form: In file included from algorithm:644: functional(1492,31): error: expected member name or ';' after declaration specifiers const _Alloc& __allocator() const { return __f_.second(); } Differential Revision: https://reviews.llvm.org/D57355 llvm-svn: 352561
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | | to reflect the new license. These used slightly different spellings that defeated my regular expressions. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351648
* Move internal usages of `alignof`/`__alignof` to use `_LIBCPP_ALIGNOF`. Eric Fiselier2019-01-161-1/+1
| | | | | | | | | | | | | | | | | | | | | Summary: Starting in Clang 8.0 and GCC 8.0, `alignof` and `__alignof` return different values in same cases. Specifically `alignof` and `_Alignof` return the minimum alignment for a type, where as `__alignof` returns the preferred alignment. libc++ currently uses `__alignof` but means to use `alignof`. See llvm.org/PR39713 This patch introduces the macro `_LIBCPP_ALIGNOF` so we can control which spelling gets used. This patch does not introduce any ABI guard to provide the old behavior with newer compilers. However, if we decide that is needed, this patch makes it trivial to implement. I think we should commit this change immediately, and decide what we want to do about the ABI afterwards. Reviewers: ldionne, EricWF Reviewed By: ldionne, EricWF Subscribers: jyknight, christof, libcxx-commits Differential Revision: https://reviews.llvm.org/D54814 llvm-svn: 351289
* Implement P1209 - Adopt Consistent Container Erasure from Library ↵Marshall Clow2018-12-141-0/+12
| | | | | | Fundamentals 2 for C++20. Reviewed as https://reviews.llvm.org/D55532 llvm-svn: 349178
* Add a version of std::function that includes a few optimizations in ABI V2.Eric Fiselier2018-12-111-0/+303
| | | | | | | | | | Patch by Jordan Soyke (jsoyke@google.com) Reviewed as D55045 The result of running the benchmarks and comparing them can be found here: https://gist.github.com/EricWF/a77fd42ec87fc98da8039e26d0349498 llvm-svn: 348812
* Refactor std::function to more easily support alternative implementations.Eric Fiselier2018-12-101-200/+310
| | | | | | | | | | | | Patch from Jordan Soyke (jsoyke@google.com) Reviewed as D55520 This change adds a new internal class, called __value_func, that adds a minimal subset of value-type semantics to the internal __func interface. The change is NFC, and is cleanup for the upcoming ABI v2 function implementation (D55045). llvm-svn: 348778
* [libcxx] Implement P0318: unwrap_ref_decay and unwrap_referenceLouis Dionne2018-12-031-0/+13
| | | | | | | | | | | | | | | | | | Summary: This was voted into C++20 in San Diego. Note that there was a revision D0318R2 which did include unwrap_reference_t, but we mistakingly voted P0318R1 into the C++20 Working Draft (which does not include unwrap_reference_t). This patch implements D0318R2, which is what we'll end up with in the Working Draft once this mistake has been fixed. Reviewers: EricWF, mclow.lists Subscribers: christof, dexonsmith, libcxx-commits Differential Revision: https://reviews.llvm.org/D54485 llvm-svn: 348138
* [libc++] Add deprecated attributes to many deprecated componentsLouis Dionne2018-09-231-32/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [NFC][libcxx] Rename helpers with 4 underscores to something more reasonableLouis Dionne2018-09-231-14/+14
| | | | llvm-svn: 342840
* Implement the infrastructure for feature-test macros. Very few actual ↵Marshall Clow2018-09-121-2/+1
| | | | | | feature test macros, though. Reviewed as: https://reviews.llvm.org/D51955 llvm-svn: 342073
* [NFC][libc++] Consistently use spaces to indentLouis Dionne2018-08-031-4/+4
| | | | | | rdar://problem/19988944 llvm-svn: 338933
* [libc++] Remove _LIBCPP_BUILDING_XXX macros, which are redundant since ↵Louis Dionne2018-08-011-2/+2
| | | | | | | | | | | | | | _LIBCPP_BUILDING_LIBRARY Summary: As suggested by Marshall in https://reviews.llvm.org/D49914 Reviewers: mclow.lists, EricWF Subscribers: christof, dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D50008 llvm-svn: 338475
* [libc++] Take 2: Replace uses of _LIBCPP_ALWAYS_INLINE by ↵Louis Dionne2018-07-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | _LIBCPP_INLINE_VISIBILITY Summary: We never actually mean to always inline a function -- all the uses of the macro I could find are actually attempts to control the visibility of symbols. This is better described by _LIBCPP_INLINE_VISIBILITY, which is actually always defined the same. This change is orthogonal to the decision of what we're actually going to do with _LIBCPP_INLINE_VISIBILITY -- it just simplifies things by having one canonical way of doing things. Note that this commit had originally been applied in r336369 and then reverted in r336382 because of unforeseen problems. Both of these problems have now been fixed. Reviewers: EricWF, mclow.lists Subscribers: christof, dexonsmith, erikvanderpoel Differential Revision: https://reviews.llvm.org/D48892 llvm-svn: 336866
* Revert "[libc++] Replace uses of _LIBCPP_ALWAYS_INLINE by ↵Louis Dionne2018-07-051-1/+1
| | | | | | | | | | | | | | | _LIBCPP_INLINE_VISIBILITY" This reverts commit r336369. The commit had two problems: 1. __pbump was marked as _LIBCPP_EXTERN_TEMPLATE_INLINE_VISIBILITY instead of _LIBCPP_INLINE_VISIBILITY, which lead to two symbols being added in the dylib and the check-cxx-abilist failing. 2. The LLDB tests started failing because they undefine `_LIBCPP_INLINE_VISIBILITY`. I need to figure out why they do that and fix the tests before we can go forward with this change. llvm-svn: 336382
* [libc++] Replace uses of _LIBCPP_ALWAYS_INLINE by _LIBCPP_INLINE_VISIBILITYLouis Dionne2018-07-051-1/+1
| | | | | | | | | | | | | | | | | | | | Summary: We never actually mean to always inline a function -- all the uses of the macro I could find are actually attempts to control the visibility of symbols. This is better described by _LIBCPP_INLINE_VISIBILITY, which is actually always defined the same. This change is orthogonal to the decision of what we're actually going to do with _LIBCPP_INLINE_VISIBILITY -- it just simplifies things by having one canonical way of doing things. Reviewers: EricWF Subscribers: christof, llvm-commits, dexonsmith, erikvanderpoel, mclow.lists Differential Revision: https://reviews.llvm.org/D48892 llvm-svn: 336369
* [libcxx] func.wrap.func.con: Unset function before destroying anythingVolodymyr Sapsai2018-04-251-9/+6
| | | | | | | | | | | | | | | | | | | | Be defensive against a reentrant std::function::operator=(nullptr_t), in case the held function object has a non-trivial destructor. Destroying the function object in-place can lead to the destructor being called twice. Patch by Duncan P. N. Exon Smith. C++03 support by Volodymyr Sapsai. rdar://problem/32836603 Reviewers: EricWF, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits, arphaman Differential Revision: https://reviews.llvm.org/D34331 llvm-svn: 330885
* Put type attributes after class keywordDimitry Andric2018-02-131-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Compiling `<functional>` in C++17 or higher mode results in: ``` functional:2500:1: warning: attribute '__visibility__' is ignored, place it after "class" to apply attribute to type declaration [-Wignored-attributes] _LIBCPP_TYPE_VIS ^ __config:701:46: note: expanded from macro '_LIBCPP_TYPE_VIS' # define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default"))) ^ 1 warning generated. ``` Fix it by putting the attribute after the `class` keyword. Reviewers: EricWF, mclow.lists Reviewed By: EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D43209 llvm-svn: 325027
* More constexpr algorithms from P0202. search/search_nMarshall Clow2018-01-161-1/+1
| | | | llvm-svn: 322566
* Add the C++17 extensions to std::search. Include the default searcher, but ↵Marshall Clow2018-01-081-0/+112
| | | | | | not the Boyer-Moore or Boyer-Moore-Horspool searcher (yet). BUT put the BM and BMH tests in place, marked to XFAIL. The other searchers will follow soon llvm-svn: 322019
* Un-inline a few more variables that are exported from the dylib.Marshall Clow2018-01-021-10/+10
| | | | llvm-svn: 321664
* Implement most of P0607: Inline Variables for the Standard Library. This ↵Marshall Clow2018-01-021-14/+14
| | | | | | involved marking a lot of variables as inline (but only for C++17 and later). llvm-svn: 321658
* Fix PR34298 - Allow std::function with an incomplete return type.Eric Fiselier2017-09-101-22/+14
| | | | | | | | | | | | | This patch fixes llvm.org/PR34298. Previously libc++ incorrectly evaluated the __invokable trait via the converting constructor `function(Tp)` [with Tp = std::function] whenever the copy constructor or copy assignment operator was required. This patch further constrains that constructor to short circut before evaluating the troublesome SFINAE when `Tp` matches std::function. The original patch is from Alex Lorenz. llvm-svn: 312892
* Revert "Fix PR34298 - Allow std::function with an incomplete return type."Eric Fiselier2017-09-101-14/+22
| | | | | | | | | | | This reverts commit r312890 because the test case fails to compile for older versions of Clang that reject initializing a const object without a user defined constructor. Since this patch should go into 5.0.1, I want to keep it an atomic change, and will re-commit it with a fixed test case. llvm-svn: 312891
* Fix PR34298 - Allow std::function with an incomplete return type.Eric Fiselier2017-09-101-22/+14
| | | | | | | | | | | | | This patch fixes llvm.org/PR34298. Previously libc++ incorrectly evaluated the __invokable trait via the converting constructor `function(Tp)` [with Tp = std::function] whenever the copy constructor or copy assignment operator was required. This patch further constrains that constructor to short circut before evaluating the troublesome SFINAE when `Tp` matches std::function. The original patch is from Alex Lorenz. llvm-svn: 312890
* Add some const_casts in places where we were implicitly casting away ↵Marshall Clow2017-06-141-3/+3
| | | | | | constness. No functional change, but now they're explicit llvm-svn: 305410
* Qualify calls to __invoke, __apply_fuctor, and __muEric Fiselier2017-05-031-3/+3
| | | | llvm-svn: 302082
* Cleanup remaining usages of _LIBCPP_HAS_NO_<c++11-feature> in the functional ↵Eric Fiselier2017-04-191-5/+5
| | | | | | library llvm-svn: 300646
* Remove the binders from C++17. Reviewed as https://reviews.llvm.org/D31769Marshall Clow2017-04-131-24/+26
| | | | llvm-svn: 300232
* [libc++] Add a key function for bad_function_callShoaib Meenai2017-03-281-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: bad_function_call is currently an empty class, so any object files using that class will end up with their own copy of its typeinfo, typeinfo name and vtable, leading to unnecessary duplication that has to be resolved by the dynamic linker. Instead, give bad_function_call a key function and put a definition for that key function in libc++ itself, to centralize the typeinfo and vtable. This is consistent with the behavior for other exception classes. The key functions are defined in libc++ rather than libc++abi since the class is defined in the libc++ versioning namespace, so ABI compatibility with libstdc++ is not a concern. Guard this change behind an ABI macro, since it isn't backwards compatible (i.e., clients built against the new libc++ headers wouldn't be able to run against an older libc++ library). Reviewers: mclow.lists, EricWF Subscribers: mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D27387 llvm-svn: 298937
* Can't test for noexcept on C++03; std::hash<nullptr_t> isn't available until ↵Marshall Clow2017-03-231-0/+1
| | | | | | C++17 llvm-svn: 298580
* Implement P0513R0 - "Poisoning the Hash"Eric Fiselier2017-01-211-241/+1
| | | | | | | | | | | | | | | | | | | | | Summary: Exactly what the title says. This patch also adds a `std::hash<nullptr_t>` specialization in C++17, but it was not added by this paper and I can't find the actual paper that adds it. See http://wg21.link/P0513R0 for more info. If there are no comments in the next couple of days I'll commit this Reviewers: mclow.lists, K-ballo, EricWF Reviewed By: EricWF Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28938 llvm-svn: 292684
* [NFC] Rename _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VISEric Fiselier2017-01-041-78/+78
| | | | | | | | | | | | | The name _LIBCPP_TYPE_VIS_ONLY is no longer accurate because both _LIBCPP_TYPE_VIS and _LIBCPP_TYPE_VIS_ONLY expand to __attribute__((__type_visibility__)) with Clang. The only remaining difference is that _LIBCPP_TYPE_VIS_ONLY can be applied to templates whereas _LIBCPP_TYPE_VIS cannot (due to dllimport/dllexport not being allowed on templates). This patch renames _LIBCPP_TYPE_VIS_ONLY to _LIBCPP_TEMPLATE_VIS. llvm-svn: 291035
* Fix PR31489 - std::function self-swap segfaultsEric Fiselier2016-12-291-0/+2
| | | | llvm-svn: 290721
* Remove _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONSEric Fiselier2016-11-181-55/+0
| | | | | | | | libc++ no longer supports C++11 compilers that don't implement `= default`. This patch removes all instances of the feature test macro _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS as well as the potentially dead code it hides. llvm-svn: 287321
* Add void_t and invoke feature test macrosEric Fiselier2016-10-141-0/+2
| | | | llvm-svn: 284209
* Implement http://wg21.link/p0302r1: Removing Allocator Support in ↵Marshall Clow2016-10-131-5/+13
| | | | | | std::function. These functions never worked, and as far as I know, no one ever called them. llvm-svn: 284164
* Add whitespace to make not_fn_impl more clear. NFC.Marshall Clow2016-10-101-8/+8
| | | | llvm-svn: 283757
* Add missing _v traits. is_bind_expression_v, is_placeholder_v and ↵Marshall Clow2016-09-221-0/+17
| | | | | | uses_allocator_v llvm-svn: 282126
* Add an _LIBCPP_NORETURN inline function named __throw_XXX for each exception ↵Marshall Clow2016-08-251-3/+11
| | | | | | type we define. They either construct and throw the exception, or abort() (if exceptions are disabled). Use these functions everywhere instead of assert()ing when exceptions are disabled. WARNING: This is a behavior change - but only with exceptions disabled. Reviewed as: https://reviews.llvm.org/D23855. llvm-svn: 279744
* Implement LWG 2148: Make non-enum default hash specialization well-formedEric Fiselier2016-08-101-4/+14
| | | | | | | | | | | | | | | | | Summary: This patch removes the static_assert for non-enum types in the primary hash template. Instead non-enum types create a hash<T> specialization that is not constructible nor callable. See also: * http://cplusplus.github.io/LWG/lwg-active.html#2543 * https://llvm.org/bugs/show_bug.cgi?id=28917 Reviewers: mclow.lists, EricWF Subscribers: mehdi_amini, cfe-commits Differential Revision: https://reviews.llvm.org/D23331 llvm-svn: 278300
* Move std::function constructor SFINAE into template parameter list. Fixes ↵Eric Fiselier2016-07-201-19/+10
| | | | | | | | | PR20002. Although inheriting constructors have already been fixed in Clang 3.9 I still choose to fix std::function so users can derive from it with older compilers. llvm-svn: 276090
* Implement P0358r1. Fixes for not_fn.Eric Fiselier2016-06-271-2/+17
| | | | llvm-svn: 273837
* Implement LWG 2488 - Make the placeholders constexpr.Eric Fiselier2016-06-261-10/+23
| | | | | | | | | | | | | | | | | | | This patch makes the bind placeholders in std::placeholders both (1) const and (2) constexpr (See below). This is technically a breaking change for any code using the placeholders outside of std::bind and depending on them being non-const. However I don't think this will break any real world code. (1) Previously the placeholders were non-const extern globals in all dialects. This patch changes these extern globals to be const in all dialects. Since the cv-qualifiers don't participate in name mangling for globals this is an ABI compatible change. (2) Make the placeholders constexpr in C++11 and beyond. Although LWG 2488 only applies to C++17 I don't see any reason not to backport this change. llvm-svn: 273824
OpenPOWER on IntegriCloud