summaryrefslogtreecommitdiffstats
path: root/libcxx/test/support
Commit message (Collapse)AuthorAgeFilesLines
...
* Update container_test_types.h and cleanup the related testsEric Fiselier2016-03-311-118/+78
| | | | llvm-svn: 264985
* Missed this file in previous checkinMarshall Clow2016-03-141-6/+33
| | | | llvm-svn: 263507
* Fix LWG issue 2469 - Use piecewise construction in unordered_map::operator[].Eric Fiselier2016-02-111-0/+5
| | | | | | | | | | | | | unordered_map's allocator may only be used to construct objects of 'value_type', or in this case 'pair<const Key, Value>'. In order to respect this requirement in operator[], which requires default constructing the 'mapped_type', we have to use pair's piecewise constructor with '(tuple<Kep>, tuple<>)'. Unfortunately we still need to provide a fallback implementation for C++03 since we don't have <tuple>. Even worse this fallback is the last remaining user of '__hash_map_node_destructor' and '__construct_node_with_key'. llvm-svn: 260601
* Revert r260514 because it has a bogus commit message.Eric Fiselier2016-02-111-5/+0
| | | | llvm-svn: 260556
* separate nested >>Eric Fiselier2016-02-111-1/+1
| | | | llvm-svn: 260516
* Teach __hash_table how to handle unordered_map's __hash_value_type.Eric Fiselier2016-02-111-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is fairly large and contains a number of changes. The main change is teaching '__hash_table' how to handle '__hash_value_type'. Unfortunately this change is a rampant layering violation, but it's required to make unordered_map conforming without re-writing all of __hash_table. After this change 'unordered_map' can delegate to '__hash_table' in almost all cases. The major changes found in this patch are: * Teach __hash_table to differentiate between the true container value type and the node value type by introducing the "__container_value_type" and "__node_value_type" typedefs. In the case of unordered_map '__container_value_type' is 'pair<const Key, Value>' and '__node_value_type' is '__hash_value_type'. * Switch almost all overloads in '__hash_table' previously taking 'value_type' (AKA '__node_value_type) to take '__container_value_type' instead. Previously 'pair<K, V>' would be implicitly converted to '__hash_value_type<K, V>' because of the function signature. * Add '__get_key', '__get_value', '__get_ptr', and '__move' static functions to '__key_value_types'. These functions allow '__hash_table' to unwrap '__node_value_type' objects into '__container_value_type' and its sub-parts. * Pass '__hash_value_type::__value_' to 'a.construct(p, ...)' instead of '__hash_value_type' itself. The C++14 standard requires that 'a.construct()' and 'a.destroy()' are only ever instantiated for the containers value type. * Remove '__hash_value_type's constructors and destructors. We should never construct an instance of this type. (TODO this is UB but we already do it in plenty of places). * Add a generic "try-emplace" function to '__hash_table' called '__emplace_unique_key_args(Key const&, Args...)'. The following changes were done as cleanup: * Introduce the '_LIBCPP_CXX03_LANG' macro to be used in place of '_LIBCPP_HAS_NO_VARIADICS' or '_LIBCPP_HAS_NO_RVALUE_REFERENCE'. * Cleanup C++11 only overloads that assume an incomplete C++11 implementation. For example this patch removes the __construct_node overloads that do manual pack expansion. * Forward 'unordered_map::emplace' to '__hash_table' and remove dead code resulting from the change. This includes almost all 'unordered_map::__construct_node' overloads. The following changes are planed for future revisions: * Fix LWG issue #2469 by delegating 'unordered_map::operator[]' to use '__emplace_unique_key_args'. * Rewrite 'unordered_map::try_emplace' in terms of '__emplace_unique_key_args'. * Optimize '__emplace_unique' to call '__emplace_unique_key_args' when possible. This prevent unneeded allocations when inserting duplicate entries. The additional follow up work needed after this patch: * Respect the lifetime rules for '__hash_value_type' by actually constructing it. * Make '__insert_multi' act similar to '__insert_unique' for objects of type 'T&' and 'T const &&' with 'T = __container_value_type'. llvm-svn: 260514
* Teach __hash_table how to handle unordered_map's __hash_value_type.Eric Fiselier2016-02-111-0/+522
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is fairly large and contains a number of changes. The main change is teaching '__hash_table' how to handle '__hash_value_type'. Unfortunately this change is a rampant layering violation, but it's required to make unordered_map conforming without re-writing all of __hash_table. After this change 'unordered_map' can delegate to '__hash_table' in almost all cases. The major changes found in this patch are: * Teach __hash_table to differentiate between the true container value type and the node value type by introducing the "__container_value_type" and "__node_value_type" typedefs. In the case of unordered_map '__container_value_type' is 'pair<const Key, Value>' and '__node_value_type' is '__hash_value_type'. * Switch almost all overloads in '__hash_table' previously taking 'value_type' (AKA '__node_value_type) to take '__container_value_type' instead. Previously 'pair<K, V>' would be implicitly converted to '__hash_value_type<K, V>' because of the function signature. * Add '__get_key', '__get_value', '__get_ptr', and '__move' static functions to '__key_value_types'. These functions allow '__hash_table' to unwrap '__node_value_type' objects into '__container_value_type' and its sub-parts. * Pass '__hash_value_type::__value_' to 'a.construct(p, ...)' instead of '__hash_value_type' itself. The C++14 standard requires that 'a.construct()' and 'a.destroy()' are only ever instantiated for the containers value type. * Remove '__hash_value_type's constructors and destructors. We should never construct an instance of this type. (TODO this is UB but we already do it in plenty of places). * Add a generic "try-emplace" function to '__hash_table' called '__emplace_unique_key_args(Key const&, Args...)'. The following changes were done as cleanup: * Introduce the '_LIBCPP_CXX03_LANG' macro to be used in place of '_LIBCPP_HAS_NO_VARIADICS' or '_LIBCPP_HAS_NO_RVALUE_REFERENCE'. * Cleanup C++11 only overloads that assume an incomplete C++11 implementation. For example this patch removes the __construct_node overloads that do manual pack expansion. * Forward 'unordered_map::emplace' to '__hash_table' and remove dead code resulting from the change. This includes almost all 'unordered_map::__construct_node' overloads. The following changes are planed for future revisions: * Fix LWG issue #2469 by delegating 'unordered_map::operator[]' to use '__emplace_unique_key_args'. * Rewrite 'unordered_map::try_emplace' in terms of '__emplace_unique_key_args'. * Optimize '__emplace_unique' to call '__emplace_unique_key_args' when possible. This prevent unneeded allocations when inserting duplicate entries. The additional follow up work needed after this patch: * Respect the lifetime rules for '__hash_value_type' by actually constructing it. * Make '__insert_multi' act similar to '__insert_unique' for objects of type 'T&' and 'T const &&' with 'T = __container_value_type'. llvm-svn: 260513
* Got the test backwards in r258279. Fixed that and de-tabbedMarshall Clow2016-01-201-166/+166
| | | | llvm-svn: 258281
* Fix up the tests I added for string exceptions to be skipped when exceptions ↵Marshall Clow2016-01-201-0/+21
| | | | | | are disabled llvm-svn: 258279
* Add missing license headersEric Fiselier2016-01-197-0/+58
| | | | llvm-svn: 258196
* Fix PR#25973 : 'basic_string::assign(InputIt, InputIt) doesn't provide the ↵Marshall Clow2016-01-131-0/+199
| | | | | | strong exception safety guarantee'. This turned out to be a pervasive problem in <string>, which required a fair amount of rework. Add in an optimization for when iterators provide noexcept increment/comparison/assignment/dereference (which covers many of the iterators in libc++). Reviewed as http://reviews.llvm.org/D15862 llvm-svn: 257682
* Remove some test scaffolding that I added and then didn't need. No ↵Marshall Clow2016-01-051-29/+0
| | | | | | functional change llvm-svn: 256861
* First half of LWG#2354: 'Unnecessary copying when inserting into maps with ↵Marshall Clow2016-01-051-0/+30
| | | | | | braced-init syntax' llvm-svn: 256859
* Use __make_integer_seq builtin for std::make_integer_sequence. Patch by K-ballo.Eric Fiselier2015-12-091-0/+6
| | | | llvm-svn: 255162
* Our test allocators support move/copy construction; they should support ↵Marshall Clow2015-10-061-1/+7
| | | | | | move/copy assignment as well llvm-svn: 249458
* Attempt to prevent flaky thread.mutex tests by once again increasing timing ↵Eric Fiselier2015-10-011-0/+5
| | | | | | tolerances llvm-svn: 248993
* Suppress array initialization warnings in std::experimental::apply testsEric Fiselier2015-10-011-0/+8
| | | | llvm-svn: 248987
* Fix bug in test_allocator<void> that used the wrong value to represent ↵Eric Fiselier2015-08-281-2/+2
| | | | | | object state llvm-svn: 246270
* Remove test_atomic.h headerEric Fiselier2015-08-191-109/+0
| | | | | | | Because <atomic> can now be used in C++03 there is no need for the test_atomic.h header. This commit removes the header and converts all usages to use <atomic> instead. llvm-svn: 245468
* [libcxx] Allow use of <atomic> in C++03. Try 3.Eric Fiselier2015-08-191-0/+2
| | | | | | | | | | | | | | | | | | | | | | | Summary: After putting this question up on cfe-dev I have decided that it would be best to allow the use of `<atomic>` in C++03. Although static initialization is a concern the syntax required to get it is C++11 only. Meaning that C++11 constant static initialization cannot silently break in C++03, it will always cause a syntax error. Furthermore `ATOMIC_VAR_INIT` and `ATOMIC_FLAG_INIT` remain defined in C++03 even though they cannot be used because C++03 usages will cause better error messages. The main change in this patch is to replace `__has_feature(cxx_atomic)`, which only returns true when C++ >= 11, to `__has_extension(c_atomic)` which returns true whenever clang supports the required atomic builtins. This patch adds the following macros: * `_LIBCPP_HAS_C_ATOMIC_IMP` - Defined on clang versions which provide the C `_Atomic` keyword. * `_LIBCPP_HAS_GCC_ATOMIC_IMP` - Defined on GCC > 4.7. We must use the fallback atomic implementation. * `_LIBCPP_HAS_NO_ATOMIC_HEADER` - Defined when it is not safe to include `<atomic>`. `_LIBCPP_HAS_C_ATOMIC_IMP` and `_LIBCPP_HAS_GCC_ATOMIC_IMP` are mutually exclusive, only one should be defined. If neither is defined then `<atomic>` is not implemented and including `<atomic>` will issue an error. Reviewers: chandlerc, jroelofs, mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D11555 llvm-svn: 245463
* [libcxx] Add Atomic test helper and fix TSAN failures.Eric Fiselier2015-08-181-0/+109
| | | | | | | | | | | | | | | | | | | Summary: This patch attempts to fix the last 3 TSAN failures on the libc++ bot (http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-tsan/builds/143). This patch also adds a `Atomic` test type that can be used where `<atomic>` cannot. `wait.exception.pass.cpp` and `wait_for.exception.pass.cpp` were failing because the test replaced `std::terminate` with `std::exit`. `std::exit` would asynchronously run the TLS and static destructors and this would cause a race condition. See PR22606 and D8802 for more details. This is fixed by using `_Exit` to prevent cleanup. `notify_all_at_thread_exit.pass.cpp` exercises the same race condition but for different reasons. I fixed this test by manually joining the thread before beginning program termination. Reviewers: EricWF, mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D11046 llvm-svn: 245389
* [libcxx] Add <experimental/any> v2.Eric Fiselier2015-07-313-0/+375
| | | | | | | | | | | | | | | | Summary: This patch adds the second revision of <experimental/any>. I've been working from the LFTS draft found at this link. https://rawgit.com/cplusplus/fundamentals-ts/v1/fundamentals-ts.html#any Reviewers: danalbert, jroelofs, K-ballo, mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6762 llvm-svn: 243728
* Forgot the support include file in r241091Marshall Clow2015-06-301-0/+73
| | | | llvm-svn: 241092
* Fix std::function allocator constructors in C++03.Eric Fiselier2015-06-141-6/+6
| | | | | | | | | The C++03 version of function tried to default construct the allocator in the uses allocator constructors when no allocation was performed. These constructors would fail to compile when used with allocators that had no default constructor. llvm-svn: 239708
* More of N4258 implementation. Mark all of our test_allocators as noexcept ↵Marshall Clow2015-06-033-24/+30
| | | | | | constructible. Make the constructors for basic_string noexcept all the time (under C++14). Update tests to reflect the new world order. More to come. llvm-svn: 238957
* Add test macros header to remove dependance on __config macros.Eric Fiselier2015-05-271-0/+83
| | | | llvm-svn: 238267
* Add option to disable access to the global filesystem namespace.Ed Schouten2015-03-121-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Systems like FreeBSD's Capsicum and Nuxi CloudABI apply the concept of capability-based security on the way processes can interact with the filesystem API. It is no longer possible to interact with the VFS through calls like open(), unlink(), rename(), etc. Instead, processes are only allowed to interact with files and directories to which they have been granted access. The *at() functions can be used for this purpose. This change adds a new config switch called _LIBCPP_HAS_NO_GLOBAL_FILESYSTEM_NAMESPACE. If set, all functionality that requires the global filesystem namespace will be disabled. More concretely: - fstream's open() function will be removed. - cstdio will no longer pull in fopen(), rename(), etc. - The test suite's get_temp_file_name() will be removed. This will cause all tests that use the global filesystem namespace to break, but will at least make all the other tests run (as get_temp_file_name will not build anyway). It is important to mention that this change will make fstream rather useless on those systems for now. Still, I'd rather not have fstream disabled entirely, as it is of course possible to come up with an extension for fstream that would allow access to local filesystem namespaces (e.g., by adding an openat() member function). Differential revision: http://reviews.llvm.org/D8194 Reviewed by: jroelofs (thanks!) llvm-svn: 232049
* Use generic feature name for sanitizers that replace new and deleteEric Fiselier2015-03-101-1/+2
| | | | llvm-svn: 231841
* Add TrackedValue to test/support. Thanks to Louis DionneEric Fiselier2015-03-091-0/+50
| | | | llvm-svn: 231674
* Add CloudABI locale names to platform_support.h.Ed Schouten2015-03-091-0/+10
| | | | | | | | On CloudABI we should append the timezone name to the end of the locale (e.g., nl_NL.UTF-8@Europe/Amsterdam). By fixing the locale names we can already let a lot of locale related tests pass. llvm-svn: 231649
* Fix error checking in get_temp_file_name().Dan Albert2015-02-131-4/+7
| | | | | | | | | | Checking errno without first checking that the call failed means that if some other call prior to mkstemp failed with EINVAL prior to this, the assert would fire even if mkstemp succeeded. If something failed with EEXIST, it would go in to an infinite loop. Change-Id: I3f140a3e15fe08664a38a8c9a950c4ed547eb481 llvm-svn: 229035
* Add pragma system header to some experimental headers and add newlines to files.Eric Fiselier2015-02-101-1/+1
| | | | llvm-svn: 228712
* [libcxx] Properly convert the count arguments to the *_n algorithms before use.Eric Fiselier2015-02-101-0/+44
| | | | | | | | | | | | | | | | | Summary: The requirement on the `Size` type passed to *_n algorithms is that it is convertible to an integral type. This means we can't use a variable of type `Size` directly. Instead we need to convert it to an integral type first. The problem is finding out what integral type to convert it to. `__convert_to_integral` figures out what integral type to convert it to and performs the conversion, It also promotes the resulting integral type so that it is at least as big as an integer. `__convert_to_integral` also has a special case for converting enums. This should only work on non-scoped enumerations because it does not apply an explicit conversion from the enum to its underlying type. Reviewers: chandlerc, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D7449 llvm-svn: 228704
* Fix use of C++11 extensions in C++03 code.Eric Fiselier2015-02-101-9/+9
| | | | llvm-svn: 228698
* Remove use of _[A-Z] identifiers and poison them to detect usageEric Fiselier2015-02-051-0/+32
| | | | llvm-svn: 228353
* We had two identical files named 'MoveOnly.h' in the test suite. Move one to ↵Marshall Clow2015-01-281-0/+50
| | | | | | support/, remove the other, and update all the tests that included them. No functionality change. llvm-svn: 227370
* Fix PR22366. When move-constructing an associative container and explicitly ↵Marshall Clow2015-01-281-0/+52
| | | | | | passing an allocator that compares different, we were not calling the destructor of the elements in the moved-from container. llvm-svn: 227359
* Fix definition of __has_feature in r227263Eric Fiselier2015-01-271-1/+1
| | | | llvm-svn: 227264
* Ensure __has_feature is defined in test/support/count_new.hppEric Fiselier2015-01-271-0/+4
| | | | llvm-svn: 227263
* [libcxx] Consolidate new/delete replacement in tests and disable it when ↵Eric Fiselier2014-12-221-0/+201
| | | | | | | | | | | | | | | | | | | | using sanitizers. Summary: MSAN and ASAN also replace new/delete which leads to a link error in these tests. Currently they are unsupported but I think it would be useful if these tests could run with sanitizers. This patch creates a support header that consolidates the new/delete replacement functionality and checking. When we are using sanitizers new and delete are no longer replaced and the checks always return true. Reviewers: mclow.lists, danalbert, jroelofs, EricWF Reviewed By: EricWF Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6562 llvm-svn: 224741
* Fix platform_support.h's get_temp_file_name() on Newlib under __STRICT_ANSI__Jonathan Roelofs2014-12-111-0/+7
| | | | llvm-svn: 224057
* Since Eric poisoned the comma operator on all our test iterators, we no ↵Marshall Clow2014-11-181-105/+0
| | | | | | longer need 'comma_iterator'. Remove it from the test suite. llvm-svn: 222238
* Fix use of operator comma in is_permutation and delete comma operator for ↵Eric Fiselier2014-10-271-5/+13
| | | | | | | | | test iterators. The comma operators in the test iterators give better error messages when they are deleted as opposed to not defined. Delete these functions when possible. llvm-svn: 220715
* [libcxx] Fix use of operator comma where the types can be user definedEric Fiselier2014-10-271-0/+15
| | | | | | | | | | | | | | | | Summary: An evil user might overload operator comma. Use a void cast to make sure any user overload is not selected. Modify all the test iterators to define operator comma. Reviewers: danalbert, mclow.lists Reviewed By: mclow.lists Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D5929 llvm-svn: 220706
* Whitespace maintenance. Remove a bunch of tabs that snuck in. No ↵Marshall Clow2014-10-181-19/+19
| | | | | | functionality change llvm-svn: 220142
* Add include of <cassert> for the operator commaMarshall Clow2014-09-171-0/+1
| | | | llvm-svn: 217938
* Create a 'comma_iterator' class that overloads operator, and asserts when ↵Marshall Clow2014-09-161-0/+105
| | | | | | it's called. Add tests to mismatch to make sure it can't be blindsided by such an evil iterator. More tests for other algorithms forthcoming. Thanks to STL for pointing this out at CppCon and Yakov Galka for opening LWG issue #2133 llvm-svn: 217902
* PR20546: Fix tests for compare_exchange_weak.Dan Albert2014-09-061-0/+51
| | | | | | | | | | | | | | | | | | | | | | | | These calls are allowed to fail spuriously. 29.6.5.25: Remark: A weak compare-and-exchange operation may fail spuriously. That is, even when the contents of memory referred to by expected and object are equal, it may return false and store back to expected the same memory contents that were originally there. [ Note: This spurious failure enables implementation of compare and-exchange on a broader class of machines, e.g., load-locked store-conditional machines. A consequence of spurious failure is that nearly all uses of weak compare-and-exchange will be in a loop. To fix this, we replace any assert() that expects std::atomic::compare_exchange_weak() to return true with a loop. If the call does not return true within N runs (with N currently equal to 10), then the test fails. http://llvm.org/bugs/show_bug.cgi?id=20546 llvm-svn: 217319
* [asan] Make vector asan annotations exception-friendlyKostya Serebryany2014-09-021-2/+2
| | | | | | | | | Fix vector asan annotations with RAII. Add a test. Also, remove one dead function. Review: http://reviews.llvm.org/D4170 llvm-svn: 216995
* fix missing include for ::close in platform_support.hEric Fiselier2014-08-191-0/+2
| | | | llvm-svn: 215998
OpenPOWER on IntegriCloud