Commit Graph

2991 Commits

Author SHA1 Message Date
Eric Fiselier 7d402732c2 force the bots to cycle
llvm-svn: 360306
2019-05-09 02:34:37 +00:00
Nico Weber 30649ce09b Mark is_trivially_destructible as unsupported with apple-clang-9
See discussion on https://reviews.llvm.org/D48292

llvm-svn: 359907
2019-05-03 17:26:17 +00:00
Casey Carter b574e11217 [libc++][test] Remove non-portable assumption that thread's constructor allocates with ::new
Drive-by:
* Fix potential race between check and update of `throw_one` in `operator new`
* Fix latent bug in `operator delete`, which shouldn't decrement `outstanding_new` when passed a null pointer
* Specifically catch the expected `bad_alloc` in `main` instead of `...`

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

llvm-svn: 359827
2019-05-02 21:19:41 +00:00
Dan Albert dfa7af5b6b Add missing locale requirement to test.
Linux is failing even though the test runner does report this locale
is available, but the test still isn't expected to work on platforms
without the locale (like Android).

llvm-svn: 359726
2019-05-01 21:02:32 +00:00
Dan Gohman 3efd6e37e4 [WebAssembly] WASI support for libcxx
This adds explicit support for the WASI platform to libcxx.

WASI libc uses some components from musl, however it's not fully compatible
with musl, so we're planning to stop using _LIBCPP_HAS_MUSL_LIBC and
customize for WASI libc specifically.

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

Reviewers: sbc100, ldionne
llvm-svn: 359703
2019-05-01 16:47:30 +00:00
Marshall Clow ccbe567f46 Get rid of a bunch of 'unused variable' warnings in test when run with debug_level set. NFC
llvm-svn: 359672
2019-05-01 11:25:58 +00:00
Marshall Clow 3740ca1e7f Fix a bunch of unordered container tests that were failing when _LIBCPP_DEBUG was set.
llvm-svn: 359642
2019-05-01 01:52:51 +00:00
Eric Fiselier 71aa67506b Support overaligned types in `aligned_storage`.
Summary:
The current implementation of aligned storage was written before we had `alignas`, so it used a list of builtin types to force the alignment. But this doesn't work overaligned requests.

This patch adds a fallback case supporting over-alignment. It only affects case that were previously ill-formed.

Reviewers: rsmith, ldionne, dlj, mclow.lists

Reviewed By: mclow.lists

Subscribers: mclow.lists, dexonsmith, libcxx-commits

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

llvm-svn: 359596
2019-04-30 18:44:45 +00:00
Marshall Clow 39084db328 Implement LWG 2960: nonesuch is insufficiently useless
llvm-svn: 359526
2019-04-30 00:54:38 +00:00
Marshall Clow 8a02f8d928 Add tests specifically for LWG2164. We already did this; but now we have tests. NFC
llvm-svn: 359458
2019-04-29 15:38:07 +00:00
Marshall Clow c29db2d83e Add '_LIBCPP_ASSERT(ready())' to several match_results method that have this precondtion. Fix several tests which did not honor this precondition. Thanks to Andrey Maksimov for pointing this out.
llvm-svn: 359324
2019-04-26 17:10:03 +00:00
Louis Dionne f30f261dc5 [libc++] Relax libc++-only test on regex_constants
The standard requires the following for the std::regex_constants::error_type
values: "The type error_type is an implementation-defined enumerated type."

The values of this enumerated type are not required to be non-zero.
This patch makes such checks in tests libc++-specific to let the tests
pass for other conforming implementations.

Thanks to Andrey Maksimov for the patch.
Differential Revision: https://reviews.llvm.org/D61195

llvm-svn: 359320
2019-04-26 16:46:37 +00:00
Eric Fiselier eea2287f83 add tuple_cat test for const T
llvm-svn: 359256
2019-04-26 01:06:32 +00:00
Eric Fiselier 7e528bc4ce Fix return type of std::tuple_cat.
When the arguments to tuple cat were const, the const was incorrectly
propagated into the type of the resulting tuple. For example:

const std::tuple<int> t(42);
auto r = std::tuple_cat(t, t);
// Incorrect! should be std::tuple<int, int>.
static_assert(is_same_v<decltype(r), std::tuple<const int, const int>>);

llvm-svn: 359255
2019-04-26 01:02:18 +00:00
Casey Carter 413732354d [libc++][test] Fix noexcept assertions in variant's get tests
All constant expressions are non-potentially-throwing in C++14, but that is *not* the case in C++17. Change these tests of the `variant`-flavored overloads of `std::get` to expect the correct behavior when the compiler is not GCC or is GCC 9+.

Credit to Jonathan Wakely for providing an improved version of my initial change that validates the incorrect behavior on GCC < 9 as well as validating the correct behavior on other compilers.

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

llvm-svn: 359220
2019-04-25 18:36:29 +00:00
Marshall Clow b0e2daf64b Implement 'lerp'; which is the last bit of P0811. Mark that paper as complete.
llvm-svn: 359211
2019-04-25 17:44:18 +00:00
Marshall Clow d3d0ecbfd5 Implement midpoint for floating point types. Reviewed as https://reviews.llvm.org/D61014.
llvm-svn: 359184
2019-04-25 12:11:43 +00:00
Marshall Clow 07161d6de3 Update test to better check for the non-constexpr-ness of a move constructor. Fixes PR#41577.
llvm-svn: 359162
2019-04-25 02:12:51 +00:00
Richard Smith d8b01111a0 Use modern type trait implementations when available.
Teach libcxx to stop using various deprecated __has_* type traits, in favor of
the ("modern", C++11 era) __is_* type traits.

This is mostly just a simplification, but fixes at least one bug: _Atomic T
should be considered trivially-destructible, but is not considered to be POD by
Clang, and __has_trivial_destructor is specified in the GCC documentation as
returning false for non-POD non-class types.

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

llvm-svn: 359159
2019-04-25 00:35:01 +00:00
Eric Fiselier 2fc5a786be Add std::is_constant_evaluated.
Clang recently added __builtin_is_constant_evaluated() and GCC 9.0
has it as well.

This patch adds support for it in libc++.

llvm-svn: 359119
2019-04-24 17:54:25 +00:00
Marshall Clow bce10f159c Make the test object callable. libstdc++'s bind checks that (libc++ currently does not). Thanks to Jonathan Wakely for the fix.
llvm-svn: 359108
2019-04-24 15:33:55 +00:00
Marshall Clow a14b76707c Fix a one more compare test that assumed -1/0/1 instsad of <0/0/>0. NFC.
llvm-svn: 359106
2019-04-24 15:26:45 +00:00
Marshall Clow 98b15320e4 Fix a couple of tests that assumed that compare retunred -1/0/1 instead of <0/0/>0. Thanks to Jonathan Wakely for the report.
llvm-svn: 359104
2019-04-24 15:14:14 +00:00
Marshall Clow c564c16308 Add an any_cast test for array types. Thanks to Jonathan Wakely for the suggestion.
llvm-svn: 359085
2019-04-24 12:11:12 +00:00
Eric Fiselier 6886f1e39b Avoid name conflict with kernel headers
llvm-svn: 359080
2019-04-24 09:43:44 +00:00
Eric Fiselier 433eecadee Fix namespace name conflict with GCC
llvm-svn: 359023
2019-04-23 18:23:33 +00:00
Eric Fiselier 1670772adc Fix implementation of ::abs and std::abs LWG 2192.
Summary:
All overloads of `::abs` and `std::abs` must be present in both `<cmath>` and `<cstdlib>`. This is problematic to implement because C defines `fabs` in `math.h` and `labs` in `stdlib.h`. This introduces a circular dependency between the two headers. 

This patch implements that requirement by moving `abs` into `math.h` and making `stdlib.h` include `math.h`. In order to get the underlying C declarations from the "real" `stdlib.h` inside our `math.h` we need some trickery. Specifically we need to make `stdlib.h` include next itself.

Suggestions for a cleaner implementation are welcome.

Reviewers: mclow.lists, ldionne

Reviewed By: ldionne

Subscribers: krytarowski, fedor.sergeev, dexonsmith, jdoerfert, jsji, libcxx-commits

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

llvm-svn: 359020
2019-04-23 18:01:58 +00:00
Casey Carter e3f7074c7e [libc++][test] Update some wstring_convert tests for MSVC quirks
Due to MSVC's decision to encode `wchar_t` as UTF-16, it rejects wide
character/string literals that expect a character value greater than
`\xffff`. UTF-16 `wchar_t` is clearly non-conforming, given that the
standard requires wchar_t to be capable of representing all characters
in the supported wide character execution sets, but rejecting e.g.
`\x40003` is a reasonably sane compromise given that encoding choice:
there's an expectation that `\xFOO` produces a single character in the
resulting literal. Consequently `L'\x40003'`/`L"\x40003"` are ill-formed
literals on MSVC. `L'\U00040003'` is a high surrogate (and produces a
warning about ignoring the "second character" in a multi-character
literal), and `L"\U00040003"` is a perfectly-valid `const wchar_t[3]`.

This change updates these tests to use universal-character-names instead
of raw values for the intended character values, which technically makes
them portable even to implementations that don't use a unicode
transformation format encoding for their wide character execution
character set. The two-character literal `L"\u1005e"` is awkward - the
`e` looks like part of the UCN's hex encoding - but necessary to compile
in '03 mode since '03 didn't allow UCNs to be used for members of the
basic execution character set even in character/string literals.

I've also eliminated the extraneous `\x00` "bonus null-terminator" in
some of the string literals which doesn't affect the tested behavior.

I'm sorry about using `*L"\U00040003"` in `conversions.string/to_bytes.pass.cpp`,
but it's correct for platforms with 32-bit wchar_t, *and* doesn't
trigger narrowing warnings as did the prior `CharT(0x40003)`.

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

llvm-svn: 358908
2019-04-22 19:08:13 +00:00
Casey Carter c8eb2d0354 [libc++] [test] Silence C++20 deprecation warnings in the MSVC STL
... when including msvc_stdlib_force_include.hpp.

llvm-svn: 358782
2019-04-19 20:39:41 +00:00
Thomas Anderson 6ab51de08e [libc++] Make __debug_less::operator() constexpr
This is a followup to [1] which added a new `__debug_less::operator()` overload.
[2] added `_LIBCPP_CONSTEXPR_AFTER_CXX17` to the original
`__debug_less::operator()` between the time of writing [1] and landing it.  This
change adds `_LIBCPP_CONSTEXPR_AFTER_CXX17` to the new overload too.

[1] https://reviews.llvm.org/rL358423
[2] https://reviews.llvm.org/rL358252

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

llvm-svn: 358725
2019-04-19 00:52:54 +00:00
Billy Robert O'Neal III bd7db5ac95 [libc++] [test] Add missing required headers to midpoint.integer.pass.cpp
This change authored by Paolo Torres <t-pator@microsoft.com>

llvm-svn: 358698
2019-04-18 18:02:14 +00:00
Louis Dionne 09ef420d62 [libc++] (Take 2) Add a test that uses the debug database from multiple threads
In r358591, I added a test that uses the debug database from multiple
threads and that helped us uncover the problem that was fixed in r355367.
However, the test broke the tsan CI bots, and I think the problem is the
test allocator that was used in the test (which is not thread safe).

I'm committing again without using the test allocator, and in a separate
test file.

llvm-svn: 358610
2019-04-17 20:07:39 +00:00
Louis Dionne 840197e5ed Revert "[libc++] Add a test that uses the debug database from multiple threads"
This reverts r358591, which seems to have uncovered an actual bug and
causes the tsan CI to fail. We need to fix the bug and re-commit the
test.

llvm-svn: 358593
2019-04-17 16:43:03 +00:00
Louis Dionne 00f2ab1c2f [libc++] Add a test that uses the debug database from multiple threads
This test helped us concurrently discover the problem that was fixed
in r355367.

llvm-svn: 358591
2019-04-17 16:21:55 +00:00
Marshall Clow 83465c7938 Add tests for stability to list::sort and forward_list::sort. Thanks to Jonathan Wakely for the notice
llvm-svn: 358541
2019-04-17 00:11:00 +00:00
Marshall Clow 896b0c7b99 Fix list/forward_list implementations of remove_if and unique to deal with predicates that are part of the sequence passed in. We already do this for remove.
llvm-svn: 358534
2019-04-16 22:11:26 +00:00
Louis Dionne e1e1bd7f9c [libc++] Fix debug_less test in C++03
We were using C++11 features but the test needs to work in C++03 too.

llvm-svn: 358433
2019-04-15 18:00:01 +00:00
Thomas Anderson 3c3ccc0049 [libc++] Fix build failure with _LIBCPP_DEBUG=0 when iterators return values instead of references
There are many STL algorithms (such as lexicographical_compare) that compare
values pointed to by iterators like so:
    __comp(*it1, *it2);
	
When building with `_LIBCPP_DEBUG=0`, comparators are wrapped in `__debug_less`
which does some additional validation.  But `__debug_less::operator()` takes
non-const references, so if the type of `*it1` is int, not int&, then the build
will fail.

This change adds a `const&` overload for `operator()` to fix the build.

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

llvm-svn: 358423
2019-04-15 17:02:15 +00:00
Louis Dionne e4d6ac5d19 [libc++] Run back-deployment CI against previously-released libc++abi dylibs
We used to do it against the current system's libc++abi, which is not as
good as doing it with the libc++abi that matches the libc++ we're running
against.

Note that I made sure we were indeed picking up the provided libc++abi
by replacing it by something that doesn't work and watching it burn.

llvm-svn: 358294
2019-04-12 16:58:25 +00:00
Louis Dionne 7c142fcc06 [libc++] Make sure we don't eagerly diagnose non-const comparators for containers of incomplete types
Summary:
In r348529, I improved the library-defined diagnostic for using containers
with a non-const comparator/hasher. However, the check is now performed
too early, which leads to the diagnostic being emitted in cases where it
shouldn't. See PR41360 for details.

This patch moves the diagnostic to the destructor of the containers, which
means that the diagnostic will only be emitted when the container is instantiated
at a point where the comparator and the key/value are required to be complete.
We still retain better diagnostics than before r348529, because the diagnostics
are performed in the containers themselves instead of __tree and __hash_table.

As a drive-by fix, I improved the diagnostic to mention that we can't find
a _viable_ const call operator, as suggested by EricWF in PR41360.

Reviewers: EricWF, mclow.lists

Subscribers: christof, jkorous, dexonsmith, libcxx-commits, zoecarver

Tags: #libc

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

llvm-svn: 358189
2019-04-11 16:14:56 +00:00
Louis Dionne 19c44c5a00 [libc++] Add XFAILs for istream tests that were added in r357775
We fixed incorrect behavior of input streams in r357775 and tests were
added accordingly. However, older versions of macOS don't have the
change in the dylib yet, so the tests fail on those platforms.

llvm-svn: 357794
2019-04-05 18:50:47 +00:00
Louis Dionne 396145d0da [libc++] Fix error flags and exceptions propagated from input stream operations
Summary:
This is a re-application of r357533 and r357531. They had been reverted
because we thought the commits broke the LLDB data formatters, but it
turns out this was because only r357531 had been included in the CI
run.

Before this patch, we would only ever throw an exception if the badbit
was set on the stream. The Standard is currently very unclear on how
exceptions should be propagated and what error flags should be set by
the input stream operations. This commit changes libc++ to behave under
a different (but valid) interpretation of the Standard. This interpretation
of the Standard matches what other implementations are doing.

This effectively implements the wording in p1264r0. It hasn't been voted
into the Standard yet, however there is wide agreement that the fix is
correct and it's just a matter of time before the fix is standardized.

PR21586
PR15949
rdar://problem/15347558

Reviewers: mclow.lists, EricWF

Subscribers: christof, dexonsmith, cfe-commits

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

llvm-svn: 357775
2019-04-05 16:33:37 +00:00
Nico Weber ea3f97d278 Try to suppress nodiscard_extension failures with Xcode 9
See https://crbug.com/949509 for the error message.

llvm-svn: 357692
2019-04-04 13:37:15 +00:00
Eric Fiselier 4d50879d9c Cleanup test failures in no discard tests.
llvm-svn: 357637
2019-04-03 21:17:34 +00:00
Nico Weber 1362d7ef88 libcxx: Add _LIBCPP_NODISCARD_EXT to 38 more functions
This builds on the work done in r342808 and adds _LIBCPP_NODISCARD_EXT
to 37 more functions, namely:

adjacent_find, all_of, any_of, binary_search, clamp, count_if, count,
equal_range, equal, find_end, find_first_not_of, find_first_of, find_if,
find, includes, is_heap_until, is_heap, is_partitioned, is_permutation,
is_sorted_until, is_sorted, lexicographical_compare, lower_bound,
max_element, max, min_element, min, minmax_element, minmax, mismatch,
none_of, remove_if, remove, search_n, search, unique, upper_bound

The motivation here is that we noticed that find_if is nodiscard with
Visual Studio's standard library, and we deemed that useful
(https://crbug.com/948122).
https://devblogs.microsoft.com/cppblog/c17-progress-in-vs-2017-15-5-and-15-6/
says "Our criteria for emitting the warning are: discarding the return
value is a guaranteed leak [...], discarding the return value is
near-guaranteed to be incorrect (e.g. remove()/remove_if()/unique()), or
the function is essentially a pure observer (e.g. vector::empty() and
std::is_sorted())." so I went through algorithm and tried to apply these
criteria.

Some of these, like vector::empty() are already nodiscard per C++
standard and didn't need changing.

I didn't (yet?) go over std::string::find* methods which should probably
have _LIBCPP_NODISCARD_EXT too (but not as part of this change).

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

llvm-svn: 357619
2019-04-03 18:13:08 +00:00
Louis Dionne 6c49e1ce26 [libc++] Use std::is_nothrow_callable for std::invoke according to LWG 2807
Thanks to Zoe Carver for the patch.
Differential Revision: https://reviews.llvm.org/D58097

llvm-svn: 357616
2019-04-03 17:54:37 +00:00
Louis Dionne 4e0605d552 [libc++][NFC] Rename test file according to the libc++ convention
llvm-svn: 357588
2019-04-03 14:38:28 +00:00
Louis Dionne 3b8c90b80d [libc++] (Take 2) Correctly handle Objective-C++ ARC qualifiers in std::is_pointer
Summary:
Otherwise, std::is_pointer<id __strong> works, but std::is_pointer<id __weak>
(and others) don't work as expected.

The previous patch (r357517) had to be reverted in r357569 because it
broke the Chromium build. This patch shouldn't have the same problem.

rdar://problem/49126333

Reviewers: ahatanak, EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

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

llvm-svn: 357586
2019-04-03 14:29:52 +00:00
Hans Wennborg e475c89700 Revert "[libc++] Correctly handle Objective-C++ ARC qualifiers in std::is_pointer"
This broke the Chromium build on Mac, see https://crbug.com/949071

> Summary:
> Otherwise, std::is_pointer<id __strong> works, but std::is_pointer<id __weak>
> (and others) don't work as expected.
>
> rdar://problem/49126333
>
> Reviewers: ahatanak, EricWF
>
> Subscribers: christof, jkorous, dexonsmith, libcxx-commits
>
> Differential Revision: https://reviews.llvm.org/D60087

llvm-svn: 357569
2019-04-03 10:07:37 +00:00
Billy Robert O'Neal III 4c1581e2da [libcxx] [test] Add missing <stdexcept> to name std::out_of_range to string.conversions\stold.pass.cpp.
llvm-svn: 357547
2019-04-03 00:08:42 +00:00