Commit Graph

5450 Commits

Author SHA1 Message Date
Louis Dionne beb6efb42e [libcxx] Make sure reference_wrapper works with incomplete types
Summary: Completes P0357R3, which was merged into the C++20 Working Draft in San Diego.

Reviewers: EricWF, mclow.lists

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

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

llvm-svn: 357423
2019-04-01 19:53:44 +00:00
Marshall Clow ecad92b068 Fix PR#41323 'Race condition in steady_clock::now for _LIBCPP_WIN32API'. thanks to Ivan Afanasyev for the report.
llvm-svn: 357413
2019-04-01 17:23:30 +00:00
Louis Dionne 2b0c7abba3 [libc++] Declare std::tuple_element as struct instead of class
Similarly to https://reviews.llvm.org/rL350972, this revision changes
std::tuple_element from class to struct.

Fixes PR41331.
Thanks to Jan Wilken Dörrie for the patch.

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

llvm-svn: 357411
2019-04-01 16:39:34 +00:00
Marshall Clow efa6d803c6 Fix PR41130 - 'operator/ of std::chrono::duration and custom type'. Thanks to Zulan for the report, and Howard for the direction of the fix.
llvm-svn: 357410
2019-04-01 16:38:02 +00:00
Eric Fiselier b0e79823d6 Make common_type's implementation common
Summary:
Currently the C++03 implementation of common_type has much different behavior than the C++11 one. This causes bugs, including inside `<chrono>`.

This patch unifies the two implementations as best it can. The more code they share, the less their behavior can diverge. 

Reviewers: mclow.lists, ldionne, sbenza

Reviewed By: mclow.lists, ldionne

Subscribers: libcxx-commits

Tags: #libc

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

llvm-svn: 357370
2019-03-31 20:49:06 +00:00
Eric Fiselier 0706e144d5 Mark fenv.h as a system header before the #include_next directive
This fixes a -Wgnu-include-next warning

Patch by dmauro.

llvm-svn: 357267
2019-03-29 16:03:57 +00:00
Marshall Clow 1931c4306a Fix PR#35967: '<regex> syntax_option_type is not a proper bitmask' Sadly, this is an ABI break, so it's only available if you define either '_LIBCPP_ABI_VERSION > 2' or '_LIBCPP_ABI_UNSTABLE' or '_LIBCPP_ABI_REGEX_CONSTANTS_NONZERO' and rebuild your dylib.
llvm-svn: 357190
2019-03-28 17:30:23 +00:00
Louis Dionne afeff20c0f [libc++] Remove unnecessary <iostream> #includes in tests
Some tests #include <iostream> but they don't use anything from the
header. Those are probably artifacts of when the tests were developped.

llvm-svn: 357181
2019-03-28 16:38:15 +00:00
Marshall Clow 24fa56bcc8 Reworked all the utilities/meta tests to use ASSERT_SAME_TYPE instead of 'static_assert( is_same<'. Much easier to read. I left two tests alone: is_same.pass.cpp, which should call 'is_same' directly, and common_type.pass.cpp, which Eric is working on. NFC intended
llvm-svn: 357146
2019-03-28 03:39:25 +00:00
Louis Dionne 7cd0dad834 [libc++] Rename span's as_writeable_bytes to as_writable_bytes
Summary: The Standard says as_writable_bytes.

Reviewers: mclow.lists, EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

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

llvm-svn: 357139
2019-03-28 01:27:52 +00:00
Thomas Anderson 24812d8ac4 Fix and speedup __libcpp_locale_guard on Windows
The old implementation assumed the POSIX `setlocale()` API where the old
locale is returned.  On Windows, the _new_ locale is returned.  This meant
that `__libcpp_locale_guard` wasn't resetting the locale on destruction.

The new implementation fixes the above issue and takes advantage of
`setlocale(LC_ALL)` to reduce the number of calls, and also avoids setting
the locale at all if it's not necessary.

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

llvm-svn: 357104
2019-03-27 18:09:30 +00:00
Casey Carter 132955fa66 Fix occurrences of _LIBCPP_ASSERT in span tests
llvm-svn: 357092
2019-03-27 17:03:44 +00:00
Louis Dionne daf43ed800 [libc++] Add proper XFAILs for shared_mutex tests
Dylib support for shared_mutex was added in macOS 10.12, so the tests
should be XFAILed accordingly instead of being completely disabled
whenever availability is enabled.

rdar://problem/48769104

llvm-svn: 357079
2019-03-27 15:50:34 +00:00
Thomas Anderson d4d824a861 [libc++] Fix return value of snprintf_l() on Windows when buffer is too small
When the output buffer is too small to contain the output, `vsnprintf()`
fills the buffer and returns the number of characters that __would have__
been written if the buffer was sufficiently large.

`_vnsprintf_s()` on the other hand fills the buffer and returns -1 when this
happens.  We want the former behavior, but we also want to be able to
pass in a locale to prevent having to call `setlocale()`.

`__stdio_common_vsprintf()` is the only function general enough to get
the behavior we want.

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

llvm-svn: 357024
2019-03-26 19:51:30 +00:00
Brian Gesiak b66754a29e Revert "[coroutines] Add std::experimental::task<T> type"
This revision is causing build and test failures, such as
http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-armv8-linux/builds/648/steps/test.libcxx/logs/stdio,
so I'll revert it.

llvm-svn: 357023
2019-03-26 19:50:46 +00:00
Brian Gesiak 57839425aa [coroutines] Add std::experimental::task<T> type
Summary:
Adds the coroutine `std::experimental::task<T>` type described in proposal P1056R0.
See https://wg21.link/P1056R0.

This implementation allows customization of the allocator used to allocate the
coroutine frame by passing std::allocator_arg as the first argument, followed by
the allocator to use.

This supports co_awaiting the same task multiple times. The second and
subsequent times it returns a reference to the already-computed value.

This diff also adds some implementations of other utilities that have potential for
standardization as helpers within the test/... area:
- `sync_wait(awaitable)` - See P1171R0
- `manual_reset_event`

Move the definition of the __aligned_allocation_size helper function
from <experimental/memory_resource> to <experimental/__memory>
so it can be more widely used without pulling in memory_resource.

Outstanding work:
- Use C++14 keywords directly rather than macro versions
  eg. use `noexcept` instead of `_NOEXCEPT`).
- Add support for overaligned coroutine frames.
  This may need wording in the Coroutines TS to support passing the extra `std::align_val_t`.
- Eliminate use of `if constexpr` if we want it to compile under C++14.

Patch by @lewissbaker (Lewis Baker).

llvm-svn: 357010
2019-03-26 17:46:06 +00:00
Marshall Clow 36db489874 Cleaup of requirements for optional. While researching LWG3196, I realized that optional did not reject 'const in_place_t' like it should. Added a test as well, and a check for arrays (which were already disallowed, but now we get a better error message). Should not affect anyone's code.
llvm-svn: 356918
2019-03-25 16:35:59 +00:00
Louis Dionne 976073794e [libc++][CMake] Allow merging libc++abi.a into libc++ even on Apple platforms
Summary:
I can't see a good reason to disallow this, even though it isn't the
standard way we build libc++ for Apple platforms.

Making this work on Apple platforms requires using different flags for
--whole-archive and removing the -D flag when running `ar` to merge
archives because that flag isn't supported by the `ar` shipped on Apple
platforms. This shouldn't be an issue since the -D option appears to be
enabled by default in GNU `ar`.

Reviewers: phosek, EricWF, serge-sans-paille

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

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

llvm-svn: 356903
2019-03-25 14:56:29 +00:00
Marshall Clow e1cd11d80f Fix a minor bug with std::next and prev not and negative numbers. In particular, std::prev cannot require Bidirectional Iterators, because you might 'go back' -1 places, which goes forward. Thanks to Ville and Jonathan for the bug report.
llvm-svn: 356818
2019-03-22 22:32:20 +00:00
Louis Dionne c48e223309 [libc++] Update the list of symbols exported from libc++abi for new/delete
When libc++ does not provide new/delete, libc++abi now also provides the
aligned allocation and deallocation functions, so those should be part of
the re-export list for libc++.

llvm-svn: 356804
2019-03-22 20:18:17 +00:00
Louis Dionne 5934341fd9 [libc++] Re-export the sjlj ABI v2 for ARM architectures
We were previously not exporting the right ABI version of libc++abi.

llvm-svn: 356798
2019-03-22 19:38:53 +00:00
Marshall Clow a73ac7d932 Fix a vector test to not use a local type as a template parameter. This causes a warning on C++03. NFC
llvm-svn: 356726
2019-03-22 00:49:41 +00:00
Louis Dionne bea1817e41 [libc++] Remove too-stringent XFAILs for file_clock tests
Those tests actually pass because we don't use anything that's marked
as unavailable.

llvm-svn: 356719
2019-03-21 21:07:33 +00:00
Louis Dionne f0d7d87a47 [NFC][libc++] Reindent #ifdefs
I don't understand why we don't always do that. We do it for normal `if`s
in the code, but not for preprocessor `if`s? It's a lot more readable when
indented properly.

llvm-svn: 356693
2019-03-21 18:19:21 +00:00
Louis Dionne 952387251e [libc++] Re-document how to use <filesystem> with various versions of libc++
This documentation was removed when we added <filesystem> to the dylib
in r356518, but it really should have been updated to reflect the new
state of things. Keeping documentation around doesn't hurt and users
will have an easier time migrating.

llvm-svn: 356681
2019-03-21 16:21:09 +00:00
Samuel Benzaquen 9b7aa02b53 Add relational benchmark against a string constant.
Summary:
Add relational benchmark against a string constant.
These can potentially trigger inlining of the operations. We want to
benchmark that.

Reviewers: EricWF

Subscribers: christof, jdoerfert, libcxx-commits

Tags: #libc

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

llvm-svn: 356680
2019-03-21 16:06:15 +00:00
Louis Dionne f3486db1f7 [libc++] Mark bad_any_cast tests as unsupported when the dylib doesn't support bad_any_cast
With the latest compiler fix to availability, some availability failures
that didn't trigger before now trigger.

llvm-svn: 356678
2019-03-21 15:37:11 +00:00
Eric Fiselier c9f4cbf7a6 Add dylib-has-no-filesystem when filesystem is disabled
llvm-svn: 356640
2019-03-21 02:13:30 +00:00
Eric Fiselier e7e268d942 Mark debug death tests as unsupported on Windows
llvm-svn: 356639
2019-03-21 02:07:55 +00:00
Eric Fiselier 0e04ab7e94 Remove type visibility specifiers from new chrono types.
_LIBCPP_TYPE_VIS is only really needed on types with a vtable.
And on Windows it doesn't work with types that have only inline methods.

This patch removes the unneeded attributes.

llvm-svn: 356637
2019-03-21 01:48:15 +00:00
Billy Robert O'Neal III 277cf30d6c [libcxx] [test] Revert r356632 add (void) casts to operator new calls, to suppress warnings generated by [[nodiscard]]."
llvm-svn: 356635
2019-03-21 00:24:43 +00:00
Eric Fiselier f1d87f8b4c Allow disabling of filesystem library.
Summary: Filesystem doesn't work on Windows, so we need a mechanism to turn it off for the time being.

Reviewers: ldionne, serge-sans-paille, EricWF

Reviewed By: EricWF

Subscribers: mstorsjo, mgorny, christof, jdoerfert, libcxx-commits

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

llvm-svn: 356633
2019-03-21 00:04:31 +00:00
Billy Robert O'Neal III 49fc265581 [libcxx] [test] Add (void) casts to operator new calls, to suppress warnings generated by [[nodiscard]].
This allows these tests to pass when compiled by MSVC++.

llvm-svn: 356632
2019-03-20 23:58:46 +00:00
Nico Weber 0fd00a581d libc++/win: Make once_flag have the same size as a pointer.
`unsigned long` is 32-bit on 32-bit systems and 64-bit on 64-bit systems
on LP64 systems -- which most Unix systems are, but Windows isn't.
Windows is LLP64, which means unsigned long is 32-bit even on 64-bit
systems.

pplwin.h contains

    static_assert(alignof(void *) == alignof(::std::once_flag), ...)

which fails due to this problem.

Instead of unsigned long, use uintptr_t, which consistently is 32-bit
on 32-bit systems and 64-bit on 64-bit systems.

No functional change except on 64-bit Windows.

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

llvm-svn: 356624
2019-03-20 22:55:03 +00:00
Louis Dionne fa0573027f [libc++] Mark <filesystem> as unavailable on Apple platforms using pragmas
Summary:
Also add the corresponding XFAILs to tests that require filesystem.
The approach taken to mark <filesystem> as unavailable in this patch
is to mark all the header as unavailable using #pragma clang attribute.
Marking each declaration using the attribute is more intrusive and
does not provide a lot of value right now because pretty much everything
in <filesystem> requires dylib support, often transitively.

This is an alternative to https://reviews.llvm.org/D59093.
A similar (but partial) patch was already applied in r356558.

Reviewers: mclow.lists, EricWF, serge-sans-paille

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

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

llvm-svn: 356616
2019-03-20 21:18:14 +00:00
Marshall Clow 61914dc2fe Mark <charconv> tests as unsupported for C++11 and C++14 if you're not testing libc++. Thanks to Louis for the suggestion.
llvm-svn: 356602
2019-03-20 19:43:22 +00:00
Louis Dionne 6f3b566c87 [libc++] Use the compiler that CMake found when running lit for back-deployment tests
llvm-svn: 356595
2019-03-20 19:12:27 +00:00
Louis Dionne 2d0b4d6bb3 [libc++][CMake] Clean up some of the libc++ re-exporting logic
Summary:
This change allows specifying the version of libc++abi's ABI to re-export
when configuring CMake. It also clearly identifies which ABI version of
libc++abi each export file contains.

Finally, it removes hardcoded knowledge about the 10.9 SDK for MacOS,
since that knowledge is not relevant anymore. Indeed, libc++ can't be
built with the toolchain that came with the 10.9 SDK anyway because
the version of Clang it includes is too old (for example if you want
to build a working libc++.dylib, you need bugfixes to visibility
attributes that are only in recent Clangs).

Reviewers: dexonsmith, EricWF

Subscribers: mgorny, christof, jkorous, arphaman, libcxx-commits

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

llvm-svn: 356587
2019-03-20 18:16:24 +00:00
Marshall Clow 769c2459d5 Make to_chars/from_chars work back to C++11. This means that we can use them to implement to_string as well. Reviewed as https://reviews.llvm.org/D59598.
llvm-svn: 356585
2019-03-20 18:13:23 +00:00
Louis Dionne 77bca6d296 [NFC] Fix a couple of typos in libc++'s __config
llvm-svn: 356574
2019-03-20 17:05:52 +00:00
Louis Dionne e526a6bd55 [libc++] Do not force going through xcrun to find Clang in the macOS CI scripts
It should be possible to run those CI scripts with different compilers
by simply exporting a different CXX environment variable.

llvm-svn: 356562
2019-03-20 15:40:56 +00:00
Louis Dionne b38c08ac02 [libc++] Mark <filesystem> tests as failing when the dylib doesn't support filesystem
This fixes CI for back-deployment testers on platforms that don't have
<filesystem> support in the dylib.

This is effectively half of https://reviews.llvm.org/D59224. The other
half requires fixes in Clang.

llvm-svn: 356558
2019-03-20 14:34:00 +00:00
Louis Dionne 4d03bbbb3a [libc++] Flag file_clock test as expected to fail with ASAN
This silences a known issue, as can be seen by looking at similar
tests for other clocks, like time.clock.steady/consistency.pass.cpp.

llvm-svn: 356528
2019-03-19 21:53:32 +00:00
Louis Dionne 2b27c00102 [libc++] Complete the ABI changelog after landing <filesystem> in the dylib
llvm-svn: 356523
2019-03-19 21:32:37 +00:00
Louis Dionne cc37af7a36 [libc++] Build <filesystem> support as part of the dylib
Summary:
This patch treats <filesystem> as a first-class citizen of the dylib,
like all other sub-libraries (e.g. <chrono>). As such, it also removes
all special handling for installing the filesystem library separately
or disabling part of the test suite from the lit command line.

Unlike the previous attempt (r356500), this doesn't remove all the
filesystem tests.

Reviewers: mclow.lists, EricWF, serge-sans-paille

Subscribers: mgorny, christof, jkorous, dexonsmith, jfb, jdoerfert, libcxx-commits

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

llvm-svn: 356518
2019-03-19 20:56:13 +00:00
Thomas Anderson a0feccdf56 [libc++] Speed up certain locale functions on Windows
The issue is that __libcpp_locale_guard makes some slow calls to setlocale().
This change avoids using __libcpp_locale_guard in snprintf_l().

Fixes https://bugs.llvm.org/show_bug.cgi?id=41131

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

llvm-svn: 356512
2019-03-19 20:30:58 +00:00
Louis Dionne f7b43230b8 Revert "[libc++] Build <filesystem> support as part of the dylib"
When I applied r356500 (https://reviews.llvm.org/D59152), I somehow
deleted all of filesystem's tests. I will revert r356500 and re-apply
it properly.

llvm-svn: 356505
2019-03-19 19:27:29 +00:00
JF Bastien d81df259b3 Fix char.traits.specializations.char8_t main return
llvm-svn: 356504
2019-03-19 19:25:07 +00:00
Eric Fiselier 9b7685d545 Fixup ABI lists on Linux after adding <filesystem> to the dylib.
llvm-svn: 356503
2019-03-19 19:20:43 +00:00
Eric Fiselier 33244990ad Add visibility attributes and inline to some vector methods.
Adding filesystem to the dylib caused some vector symbols to leak
into the set of exported symbols. This patch hides those symbols.

llvm-svn: 356502
2019-03-19 19:19:44 +00:00