Commit Graph

1195 Commits

Author SHA1 Message Date
Eric Fiselier 07b9cd36fa [libcxx] Fix undefined behavior in forward_list
Summary:
This patch is similar to the <list> fix but it has a few differences. This patch doesn't use a `__link_pointer` typedef because we don't need to change the linked list pointers because `forward_list` never stores a  `__forward_begin_node` in the linked list itself. 

The issue with `forward_list` is that the iterators store pointers to `__forward_list_node` and not `__forward_begin_node`. This is incorrect because `before_begin()` and `cbefore_begin()` return iterators that point to a `__forward_begin_node`. This means we incorrectly downcast the `__forward_begin_node` pointer to a `__node_pointer`. This downcast itself is sometimes UB but it cannot be safely removed until ABI v2. The more common cause of UB is when we deference the downcast pointer. (for example `__ptr_->__next_`). This can be fixed without an ABI break by upcasting `__ptr_` before accessing it.

The fix is as follows:

1. Introduce a `__iter_node_pointer` typedef that works  similar to `__link_pointer` in the last patch. In ABI v2 it is always a typedef for `__begin_node_pointer`.
2. Change the `__before_begin()` method to return the correct pointer type (`__begin_node_pointer`),
    Previously it incorrectly downcasted  the  `__forward_begin_node` to a `__node_pointer`  so it could be used to constructor the iterator types.
3. Change `__forward_list_iterator` and `__forward_list_const_iterator`  in the following way:
    1. Change `__node_pointer __ptr_;` member to  have the `__iter_node_pointer` type instead. 
    2. Add additional private constructors that accept `__begin_node_pointer` in addition to `__node_pointer` and then correctly cast them to the stored `__iter_node_pointer` type. 
    3. Add  `__get_begin()` and `__get_node_unchecked()` accessor methods that correctly cast `__ptr_` to the expected pointer type. `__get_begin()` is always safe to use and should be 
       preferred. `__get_node_unchecked()` can only be used on a deferencible iterator.
4. Replace direct access to `__forward_list_iterator::__ptr_`  with the safe accessor methods.
  


Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D15836

llvm-svn: 258888
2016-01-27 00:11:54 +00:00
Eric Fiselier 060cc200d0 Fix PR26103 - Error calling is_convertible with incomplete type. Patch from Michael Daniels.
llvm-svn: 258852
2016-01-26 20:24:30 +00:00
Marshall Clow 0aa1ccb0d9 Implement LWG#2385; remove the allocator-aware std::function::assign call. It was useless, and didn't actually *do anything* with the allocator. Now it's gone. On the off chance that someone is mistakenly calling it, it's only gone in C++1z
llvm-svn: 258697
2016-01-25 17:29:55 +00:00
Marshall Clow c38568f660 Fix test to pass in C++03
llvm-svn: 258593
2016-01-23 01:02:29 +00:00
Marshall Clow fcdb19904c Implement LWG#2101 'Some transformation types can produce impossible types' Introduced a new (internal) type trait '__is_referenceable' with tests. Use that trait in add_lvalue_reference, add_rvalue_reference and add_pointer.
llvm-svn: 258418
2016-01-21 18:22:43 +00:00
Daniel Sanders 61c115f32c [libcxx] Add appropriate 'REQUIRE' directives to tests that require en_US.UTF-8.
Reviewers: mclow.lists, hans

Subscribers: bcraig, cfe-commits

Differential Revision: http://reviews.llvm.org/D16406

llvm-svn: 258403
2016-01-21 15:35:15 +00:00
Eric Fiselier 48c3483f45 Use TEST_STD_VER instead of __has_feature to detect noexcept. This fixes the test with GCC.
llvm-svn: 258292
2016-01-20 05:44:11 +00:00
Marshall Clow e612a8877a More string fixes for noexcept cases. Apparently I didn't get them all in r258281.
llvm-svn: 258291
2016-01-20 05:41:24 +00:00
Eric Fiselier 6469c3ec17 Mark some test XFAIL for GCC 4.9 due to missing is_trivial* traits
llvm-svn: 258287
2016-01-20 04:59:57 +00:00
Marshall Clow 64ca6868f5 Got the test backwards in r258279. Fixed that and de-tabbed
llvm-svn: 258281
2016-01-20 03:37:46 +00:00
Marshall Clow 9d10d27c67 Fix up the tests I added for string exceptions to be skipped when exceptions are disabled
llvm-svn: 258279
2016-01-20 03:19:15 +00:00
Eric Fiselier c467208791 Fix enviroment variables when running shell scripts
llvm-svn: 258217
2016-01-19 23:06:29 +00:00
Eric Fiselier 38236b5750 Add missing license headers
llvm-svn: 258196
2016-01-19 21:52:04 +00:00
Eric Fiselier 8132bdc8e1 Mark slow ASAN/MSAN tests as XFAIL for now.
llvm-svn: 258195
2016-01-19 21:51:07 +00:00
Marshall Clow b414b2f54b Fix PR#26175. Thanks to Josh Petrie for the report and the patch. Reviewed as http://reviews.llvm.org/D16262
llvm-svn: 258107
2016-01-19 00:50:37 +00:00
Marshall Clow a015d39239 Better comments in test. NFC
llvm-svn: 257702
2016-01-13 23:05:15 +00:00
Marshall Clow 3dd0ff3b62 Fix test for C++03 - lacking noexcept
llvm-svn: 257696
2016-01-13 22:52:36 +00:00
Marshall Clow 76b4afc040 Fix PR#25973 : 'basic_string::assign(InputIt, InputIt) doesn't provide the 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
2016-01-13 21:54:34 +00:00
Dan Gohman 4a9e173e08 [WebAssembly] Set std::numeric_limits's traps field for WebAssembly.
WebAssembly's integer division instruction traps on division by zero; set the
traps field of integral std::numeric_limits to true.

llvm-svn: 257612
2016-01-13 16:32:00 +00:00
Marshall Clow df5ddf2c7a One more missing std:: qualification from Jonathan
llvm-svn: 257506
2016-01-12 19:15:10 +00:00
Marshall Clow 8d113d430f Add a bunch of missing includes in the test suite to make it more portable. Fixes bugs #26120 and #26121. Thanks to Jonathan Wakely for the reports and the patches.
llvm-svn: 257474
2016-01-12 14:51:04 +00:00
Ahmed Bougacha 812d65a26a [libcxx] Set LC_ALL rather than LC_COLLATE to override collation.
r251131 replaced LANG with LC_COLLATE. But LC_ALL has precedence
over both, so the test still fails when LC_ALL=C.

llvm-svn: 257018
2016-01-07 02:36:09 +00:00
Marshall Clow 652a2ce191 Add explicit include directives; the file was getting implicitly included already. NFC
llvm-svn: 256864
2016-01-05 19:53:31 +00:00
Marshall Clow fd495892d6 Remove some test scaffolding that I added and then didn't need. No functional change
llvm-svn: 256861
2016-01-05 19:44:58 +00:00
Marshall Clow afc9ff99ec First half of LWG#2354: 'Unnecessary copying when inserting into maps with braced-init syntax'
llvm-svn: 256859
2016-01-05 19:32:41 +00:00
Ahmed Bougacha 4d315f1300 [libcxx] Fix typo in darwin target_info.py introduced by r256621.
llvm-svn: 256772
2016-01-04 19:35:40 +00:00
Eric Fiselier 67ac709e4c Print stacktrace with UBSAN
llvm-svn: 256729
2016-01-04 03:54:58 +00:00
Eric Fiselier d57bcda1cb Fix locale feature testing in test suite.
llvm-svn: 256621
2015-12-30 04:45:42 +00:00
Eric Fiselier 7481ac43a5 Fix test failure in 32 bit mode
llvm-svn: 256598
2015-12-29 23:19:00 +00:00
Ben Craig d38f60270c [libcxx] Fixing the Mac / Darwin build
llvm-svn: 256594
2015-12-29 23:01:07 +00:00
Ben Craig 8de2f0cf01 [libcxx] Fixing silly mistake from last commit.
Tested on Linux x86_64 targeting Linux x86_64.

llvm-svn: 256592
2015-12-29 22:55:55 +00:00
Ben Craig e238372258 [libcxx] Fixing the Linux sanitizer builds
llvm-svn: 256591
2015-12-29 22:43:17 +00:00
Ben Craig 90bee6354d [libcxx] Refactoring target_info.py
This patch makes it easier to support running the lit tests for new and
unusual platforms. It will break existing users that set
LIBCXX_TARGET_INFO to anything other than the default. I think this is
fine, because the old LIBCXX_TARGET_INFO wasn't terribly useful.

The old way of supporting the different test platforms was to have
conditional code scattered throughout config.py. New platforms would need
to add conditionals there. Alternatively, the new platform could set
no_default_flags to true, and reconstitue almost the entire compile and
link line, including things that don't vary across platforms.

The new way of supporting new platforms is to create a new target info
class, and have make_target_info return an instance of it. For platforms
supported in-tree, that will be done by modifying make_target_info. For
out-of-tree platforms, users can set LIBCXX_TARGET_INFO at cmake configure
time.

The target info sub-classes can provide fine-grained information back to
config.py. The hooks that will most commonly be provided will be
add_cxx_compile_flags and add_cxx_link_flags. These hooks can provide the
platform specific flags, while letting config.py handle all the invariant
flags.

Target info hooks were added for each area that the existing config.py had
platform specific behavior. config.py is now mostly free of platform
specific conditionals.

This patch was tested on Linux x86_64. I both targeted Linux x86_64, and
an out-of-tree platform with a custom target_info. In both cases I was
able to run libcxx and libcxxabi tests. I do not have access to FreeBSD,
Darwin, or Windows machines that are set up for lit testing.

llvm-svn: 256588
2015-12-29 22:21:38 +00:00
Eric Fiselier 7a608aa232 [libcxx] Fix LWG Issue #2367 - Fixing std::tuple and std::pair's default constructors.
Summary: This patch implements the solution for LWG Issue #2367. See http://cplusplus.github.io/LWG/lwg-active.html#2367

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D13750

llvm-svn: 256325
2015-12-23 08:20:26 +00:00
Eric Fiselier 51b9de4c7c Fix type in tuple test. Sorry for the noise
llvm-svn: 255944
2015-12-18 01:04:36 +00:00
Eric Fiselier 545b8861fc [libcxx] LWG2485: get() should be overloaded for const tuple&&. Patch from K-Ballo.
Review: http://reviews.llvm.org/D14839
llvm-svn: 255941
2015-12-18 00:36:55 +00:00
Eric Fiselier 831c112954 Fix various GCC mis-configurations for newer versions.
This patch goes through and enables C++11 and C++14 features for newer GCC's.
The main changes are:

1. Turn on variable templates. (Uses __cpp_variable_templates)
2. Assert atomic<Tp> is trivially copyable (Uses _GNUC_VER >= 501).
3. Turn on trailing return support for GCC. (Uses _GNUC_VER >= 404)
4. XFAIL void_t test for GCC 5.1 and 5.2. Fixed in GCC 6.

llvm-svn: 255585
2015-12-15 00:32:21 +00:00
Eric Fiselier d5262627eb Update how libc++/libc++abi link the tests. Follow up on r255559.
llvm-svn: 255560
2015-12-14 22:24:19 +00:00
Marshall Clow 6e07ccdfe1 K-Ballo pointed out a mistake in the add_lvalue_ref tests I checked in; now more of them are passing. Thanks
llvm-svn: 255519
2015-12-14 18:11:51 +00:00
Marshall Clow 94b5bc4263 Fix a corner case that involved calling rethrow_if_nested with a type that had a deleted operator&. Added a test to catch this as well. Thanks to Ville for the heads-up.
llvm-svn: 255517
2015-12-14 18:01:56 +00:00
Marshall Clow 161eae2daa Add add_lvalue_ref tests for a few function types, with a note why not more
llvm-svn: 255513
2015-12-14 17:34:03 +00:00
Eric Fiselier fff5ec035b Use __make_integer_seq builtin for std::make_integer_sequence. Patch by K-ballo.
llvm-svn: 255162
2015-12-09 22:03:06 +00:00
Marshall Clow b8427293df Last bit of P0006; mark it as complete
llvm-svn: 254290
2015-11-30 05:39:30 +00:00
Marshall Clow 12dff9e66a Fix bugs in alignment_of_v, etc. Re-enable the newly added tests
llvm-svn: 254289
2015-11-30 05:20:00 +00:00
Marshall Clow 00b6b01592 Temporarily disable new tests while I figure out what's going on
llvm-svn: 254288
2015-11-30 05:15:10 +00:00
Marshall Clow c8f3816e63 Fix bad macros
llvm-svn: 254287
2015-11-30 05:10:10 +00:00
Marshall Clow 4ddfaea773 Implement more of P0006; Type Traits Variable Templates. <ratio>
llvm-svn: 254285
2015-11-30 05:04:22 +00:00
Marshall Clow 803a8bb105 Fix bad macros in tests
llvm-svn: 254284
2015-11-30 05:03:35 +00:00
Marshall Clow e12a536d76 Implement more of P0006; Type Traits Variable Templates.
llvm-svn: 254283
2015-11-30 04:30:02 +00:00
Marshall Clow 94f89aeec5 Add static_assert to set/multiset/map/multimap/forward_list/deque that the allocator's value_type match the container's value_type. vector/unordered/list/string already do this. Add tests for all the containers to verify this.
llvm-svn: 254119
2015-11-26 01:24:04 +00:00