Commit Graph

5479 Commits

Author SHA1 Message Date
Samuel Benzaquen
6f0f0a6b27 Add more benchmarks for literal strings.
Summary:
Comparing against the empty string should generate much better code that
what it does today.
We can also generate better code when comparing against literals that
are larger than the SSO space.

Reviewers: EricWF

Subscribers: christof, jdoerfert, libcxx-commits

Tags: #libc

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357614 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-03 17:40:51 +00:00
Louis Dionne
77c439298e [libc++][NFC] Rename test file according to the libc++ convention
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357588 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-03 14:38:28 +00:00
Louis Dionne
572de35685 [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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357586 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-03 14:29:52 +00:00
Hans Wennborg
e42f32507a 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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357569 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-03 10:07:37 +00:00
Petr Hosek
d5529b8cd9 [CMake] Differentiate between static and shared libc++abi
This addresses the issue introduced in r354212 which broke the case when
static libc++abi is merged into static libc++, but shared libc++ is
linked against shared libc++. There are 4 different possible
combinations which is difficult to capture using a single variable. This
change splits LIBCXX_CXX_ABI_LIBRARY into two:
LIBCXX_CXX_SHARED_ABI_LIBRARY and LIBCXX_CXX_STATIC_ABI_LIBRARY to
handle the shared and static cases. This in turn allows simplification
of some of the logic around merging of static archives.

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357556 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-03 01:33:14 +00:00
Billy Robert O'Neal III
306670a063 [libcxx] [test] Add missing <stdexcept> to name std::out_of_range to string.conversions\stold.pass.cpp.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357547 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-03 00:08:42 +00:00
Billy Robert O'Neal III
8b2f8ce5e6 [libcxx] [test] Use ptrdiff_t rather than int in splice_after_range.pass.cpp to avoid narrowing from pointer subtraction to int warnings.
Reviewed as https://reviews.llvm.org/D60104

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357546 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-03 00:07:18 +00:00
Billy Robert O'Neal III
2b2bf84c98 [libcxx] [test] Fix test bugs in string.cons/copy_alloc.pass.cpp.
Fixed the inability to properly rebind the testing allocator, by making the
inner alloc_impl type a plain struct and making the operations templates. Before
rebind failed to compile complaining that a alloc_impl<T>* was not convertible
to an alloc_impl<U>*.

This enables the test to pass for MSVC++ once we provide the strong guarantee
for the copy assignment operator.

Reviewed as https://reviews.llvm.org/D60023

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357545 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-03 00:05:49 +00:00
Marshall Clow
1db13908c6 Fix backwards test that I committed yesterday. Sigh
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357540 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-03 00:01:03 +00:00
Louis Dionne
ee85f7c135 Revert "[libc++] Fix error flags and exceptions propagated from input stream operations"
This reverts commits r357533 and r357531, which broke the LLDB
data formatters. I'll hold off until we know how to fix the data
formatters accordingly.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357536 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-02 22:21:27 +00:00
Louis Dionne
756d3fde05 [libc++] Fix build when exceptions are turned off
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357533 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-02 22:02:17 +00:00
Louis Dionne
59d894965e [libc++] Fix error flags and exceptions propagated from input stream operations
Summary:
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.

I will submit a paper in San Diego to clarify the Standard such that the
interpretation used in this commit (and other implementations) is the only
possible one.

PR21586
PR15949
rdar://problem/15347558

Reviewers: mclow.lists, EricWF

Subscribers: christof, dexonsmith, cfe-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357531 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-02 21:43:07 +00:00
Louis Dionne
5a9a7c3d4a [libc++] 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.

rdar://problem/49126333

Reviewers: ahatanak, EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357517 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-02 19:48:39 +00:00
Louis Dionne
442ed81d6a [libc++] Remove use of auto with actual type
For compatibility with C++03.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357512 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-02 19:20:47 +00:00
Louis Dionne
1eb61826c8 [libc++][NFC] Remove useless public: label at the end of class
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357511 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-02 19:11:22 +00:00
Marshall Clow
6517895ec2 Special case some duration arithmetic for GCC and PPC because their long double constant folding is broken. Fixes PR#39696.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357478 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-02 14:46:36 +00:00
Marshall Clow
0abd0b7cf7 Fix typo that I introduced in r357413. Thanks to ensadc@mailnesia.com for the catch.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357474 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-02 14:00:36 +00:00
Eric Fiselier
571eaaa095 Fix a number of bugs in __val_expr's subset operator[].
The current definitions were entirely broken. They didn't call any
existing constructor and the forgot to friend the expression types they
were trying to construct.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357453 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-02 08:05:23 +00:00
Louis Dionne
7b9927381c [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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357423 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-01 19:53:44 +00:00
Marshall Clow
3de658f6b7 Fix PR#41323 'Race condition in steady_clock::now for _LIBCPP_WIN32API'. thanks to Ivan Afanasyev for the report.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357413 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-01 17:23:30 +00:00
Louis Dionne
b857e811b3 [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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357411 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-01 16:39:34 +00:00
Marshall Clow
eec31ce77c Fix PR41130 - 'operator/ of std::chrono::duration and custom type'. Thanks to Zulan for the report, and Howard for the direction of the fix.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357410 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-01 16:38:02 +00:00
Eric Fiselier
4cf126b504 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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357370 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-31 20:49:06 +00:00
Eric Fiselier
aebb09cfdb Mark fenv.h as a system header before the #include_next directive
This fixes a -Wgnu-include-next warning

Patch by dmauro.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357267 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-29 16:03:57 +00:00
Marshall Clow
cc07c8937b 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357190 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-28 17:30:23 +00:00
Louis Dionne
4ff4db7f84 [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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357181 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-28 16:38:15 +00:00
Marshall Clow
9c5bb6e040 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
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357146 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-28 03:39:25 +00:00
Louis Dionne
a9b1043901 [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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357139 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-28 01:27:52 +00:00
Thomas Anderson
22374ba643 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


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357104 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-27 18:09:30 +00:00
Casey Carter
2fe3307e56 Fix occurrences of _LIBCPP_ASSERT in span tests
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357092 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-27 17:03:44 +00:00
Louis Dionne
d88714db16 [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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357079 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-27 15:50:34 +00:00
Thomas Anderson
955113db37 [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


git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357024 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-26 19:51:30 +00:00
Brian Gesiak
2c4b419ec4 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.



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357023 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-26 19:50:46 +00:00
Brian Gesiak
e83c41a26a [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).



git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@357010 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-26 17:46:06 +00:00
Marshall Clow
9d9372a34c 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356918 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-25 16:35:59 +00:00
Louis Dionne
244334750d [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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356903 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-25 14:56:29 +00:00
Marshall Clow
d36fc70220 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.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356818 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-22 22:32:20 +00:00
Louis Dionne
61ce4ebc45 [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++.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356804 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-22 20:18:17 +00:00
Louis Dionne
0b3b8d8d65 [libc++] Re-export the sjlj ABI v2 for ARM architectures
We were previously not exporting the right ABI version of libc++abi.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356798 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-22 19:38:53 +00:00
Marshall Clow
4d774fe669 Fix a vector test to not use a local type as a template parameter. This causes a warning on C++03. NFC
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356726 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-22 00:49:41 +00:00
Louis Dionne
0ec48a9e30 [libc++] Remove too-stringent XFAILs for file_clock tests
Those tests actually pass because we don't use anything that's marked
as unavailable.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356719 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-21 21:07:33 +00:00
Louis Dionne
52d4ad5066 [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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356693 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-21 18:19:21 +00:00
Louis Dionne
129faa51ec [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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356681 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-21 16:21:09 +00:00
Samuel Benzaquen
e53014e329 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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356680 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-21 16:06:15 +00:00
Louis Dionne
eba9009ffa [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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356678 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-21 15:37:11 +00:00
Eric Fiselier
4daecde1d7 Add dylib-has-no-filesystem when filesystem is disabled
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356640 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-21 02:13:30 +00:00
Eric Fiselier
d60e4a1030 Mark debug death tests as unsupported on Windows
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356639 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-21 02:07:55 +00:00
Eric Fiselier
c4f99d8c02 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.

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356637 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-21 01:48:15 +00:00
Billy Robert O'Neal III
3fd12d449b [libcxx] [test] Revert r356632 add (void) casts to operator new calls, to suppress warnings generated by [[nodiscard]]."
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356635 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-21 00:24:43 +00:00
Eric Fiselier
cdb3094601 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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@356633 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-21 00:04:31 +00:00