Commit Graph

7121 Commits

Author SHA1 Message Date
Ilya Tokar
c81d52997a [libc++] Use builtins in more math.h functions.
Not using builtins doesn't always imply worse code,
but for e. g. isinf, this is 30%+ faster.

Before:
name        time/op
BM_isinf     2.14ns ± 2%

After:
name        time/op
BM_isinf     1.33ns ± 2%

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D88854
2021-02-10 15:17:42 -05:00
Christopher Di Bella
17db24a7a8 [libcxx] adds concepts std::invocable and std::regular_invocable
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Differential Revision: https://reviews.llvm.org/D96235
2021-02-10 19:35:53 +00:00
Christopher Di Bella
c63de225fd [libcxx] adds concept std::derived_from
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D74292
2021-02-10 19:30:08 +00:00
Christopher Di Bella
bee7b07f23 [libcxx] adds [concepts.arithmetic]
Implements parts of:
    * P0898R3 Standard Library Concepts
    * P1754 Rename concepts to standard_case for C++20, while we still can

Differential Revision: https://reviews.llvm.org/D88131
2021-02-10 19:04:57 +00:00
Louis Dionne
183b75f667 [libc++] Remove c++98 Lit features in the test suite
We don't populate a Lit feature named c++98 since 31cbe0f240.
2021-02-10 13:32:41 -05:00
Christopher Di Bella
2193e8be3e [libcxx] adds concept std::copy_constructible
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D96230

Differential Revision: https://reviews.llvm.org/D96232
2021-02-10 17:56:42 +00:00
Christopher Di Bella
2b2f36a8b1 [libcxx] adds concept std::move_constructible
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D77961

Differential Revision: https://reviews.llvm.org/D96230
2021-02-10 17:33:35 +00:00
Colin Finck
ebfadd82cb [libc++] Fix copy-paste mistake in __threading_support
Differential Revision: https://reviews.llvm.org/D96115
2021-02-10 11:00:32 -05:00
Christopher Di Bella
8caf835337 [libcxx] adds concept std::convertible_to
Implements parts of:
    - P0898R3 Standard Library Concepts
    - P1754 Rename concepts to standard_case for C++20, while we still can

Differential Revision: https://reviews.llvm.org/D77961
2021-02-10 03:27:41 +00:00
Arthur O'Dwyer
eec04092d6 [libc++] [LWG2993] reference_wrapper<T> conversion from U&&
Implement the resolution of LWG2993. Replace a deleted constructor
with a constructor that SFINAEs away in appropriate circumstances.
Also, now that the constructor is templated, we must have an
explicit deduction guide to make CTAD work.

Some tests have been merged in from Agustín Bergé's D40259.

Differential Revision: https://reviews.llvm.org/D92725
2021-02-09 15:50:25 -05:00
zoecarver
dea74b2820 [libc++] Add noexcept to string::find and similar members.
Adds `noexcept` to `string_view`/`string::find` and similar members
(`rfind`, etc.). See discussion in D95251. Refs D95821.

Reviewed By: curdeius, ldionne

Differential Revision: https://reviews.llvm.org/D95848
2021-02-09 11:47:40 -08:00
Mark de Wever
171956aab3 Revert "[libc++] Require C++20 to build the benchmarks."
There are build bots without C++20 support building the benchmarks.

This reverts commit 34acc91642.
2021-02-09 19:59:34 +01:00
Mark de Wever
34acc91642 [libc++] Require C++20 to build the benchmarks.
Some work-in-progress patches for the format header contain benchmarks.
The format header requires C++20 to build. This is a preparation to make
it easy to add these benchmarks.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96057
2021-02-09 18:34:07 +01:00
Mark de Wever
2544060e71 [libc++] Remove C++11 work-arounds in src.
Building libcxx requires at least C++17 so remove the old work-arounds.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D96200
2021-02-09 18:31:00 +01:00
Louis Dionne
73aa09704a [libc++] Add a wait step in the BuildKite pipeline to shield macOS builders
We don't have many of those and they are rather slow, so we'd rather not run
those jobs if we know other jobs in the pipeline failed anyway.
2021-02-08 10:14:16 -05:00
Sterling Augustine
a34b8b879e Various minor fixes for python 3
Switch StdTuple printer from python 2-style "next" to python 3.

Nested iteration changed enough to make the original bitset iteration
code a bit trickier than it needs to be, so unnest.

The end node of a map iterator is sometimes hard to detect in isolation,
don't fail in that case.

Differential Revision: https://reviews.llvm.org/D96167
2021-02-05 13:01:34 -08:00
Martin Storsjö
d4f4e723d0 [libcxx] Implement temp_directory_path using GetTempPath on windows
This does roughly the same as the manual implementation, but checks
a slightly different set of environment variables and has a more
appropriate fallback if no environment variables are available
(/tmp isn't a very useful fallback on windows).

Differential Revision: https://reviews.llvm.org/D91175
2021-02-05 22:47:33 +02:00
Martin Storsjö
4d292d531b [libcxx] Use the posix code for directory_entry::__do_refresh
This works just fine for windows, as all the functions it calls
are implemented and wrapped for windows.

Differential Revision: https://reviews.llvm.org/D91173
2021-02-05 22:47:33 +02:00
Arthur O'Dwyer
85167fb7c2 [libc++] Further improve the contiguous-iterator story, and fix some bugs.
- Quality-of-implementation: Avoid calling __unwrap_iter in constexpr contexts.
    The user might conceivably write a contiguous iterator where normal iterator
    arithmetic is constexpr-friendly but `std::to_address(it)` isn't.

- Bugfix: When you pass contiguous iterators to `std::copy`, you should get
    back your contiguous iterator type, not a raw pointer. That means that
    libc++ can't `__unwrap_iter` unless it also does `__rewrap_iter`.
    Fortunately, this is implementable.

- Improve test coverage of the new `contiguous_iterator` test iterator.
    This catches the bug described above.

- Tests: Stop testing that we can `std::copy` //into// an `input_iterator`.
    Our test iterators may currently support that, but it seems nonsensical to me.

Differential Revision: https://reviews.llvm.org/D95983
2021-02-05 15:18:04 -05:00
zoecarver
fab194898b [lic++][docs] Explain noexcept policy for narrow contracts.
Adds documentation around libc++'s policy to add noexcept to things that cannot throw but aren't marked as noexcept.

Refs LWG 3518 and D95251.

Differential Revision: https://reviews.llvm.org/D95821
2021-02-05 11:27:19 -08:00
Arthur O'Dwyer
5d9565634c Revert "Revert "[libc++] [P0879] constexpr std::nth_element, and rewrite its tests.""
This reverts commit b6ffece320.

The bug is now fixed (it was a stupid cut-and-paste kind of error),
and the regression test added. The new patch is also simpler than the old one!

Differential Revision: https://reviews.llvm.org/D96084
2021-02-05 12:02:43 -05:00
Jordan Rupprecht
b6ffece320 Revert "[libc++] [P0879] constexpr std::nth_element, and rewrite its tests."
This reverts commit 207d4be4d9 due to returning incorrect results. Regression test case posted in D96074.
2021-02-04 14:03:49 -08:00
Marek Kurdej
1361c5e7d7 [libc++] Add format check to CI
Note: contrary to what I said previously, I didn't change .clang-format nor utils/generate_feature_test_macro_components.py script.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D92229
2021-02-04 21:15:37 +01:00
Louis Dionne
1700ea7302 [libc++] Remove the ability to use braced-init for filesystem paths
According to my reading of http://eel.is/c++draft/filesystems#fs.class.path,
the Standard doesn't actually mention that this should work. Since other
implementations don't allow it, allowing it in libc++ is just setting a
portability trap.

Supersedes https://reviews.llvm.org/D89865.

Differential Revision: https://reviews.llvm.org/D95975
2021-02-04 11:49:00 -05:00
Louis Dionne
76fc35752d [libc++] Make feature-test macros consistent with availability macros
Before this patch, feature-test macros didn't take special availability
markup into account, which means that feature-test macros can sometimes
appear to "lie". For example, if you compile in C++20 mode and target
macOS 10.13, the __cpp_lib_filesystem feature-test macro will be provided
even though the <filesystem> declarations are marked as unavailable.
This patch fixes that.

rdar://68142369

Differential Revision: https://reviews.llvm.org/D94983
2021-02-04 11:40:22 -05:00
Louis Dionne
85b9c5ccc1 [libc++] Fix libcxx build on 32bit architectures with 64bit time_t defaults e.g. riscv32
Patch by Khem Raj.

Differential Revision: https://reviews.llvm.org/D85095
2021-02-04 11:38:54 -05:00
Mark de Wever
e275e62983 [libc++] Adds a make_string test helper function.
These function makes it easier to write generic unit tests for the
format header. It solves the issue where it's not possible to use
  `templated_prefix"foo"`
where `templated_prefix` resolves to: nothing, `L`, `u8`, `u`,
or `U`. The templated_prefix would be more faster during execution.

Reviewed By: ldionne, #libc, curdeius

Differential Revision: https://reviews.llvm.org/D93414
2021-02-04 17:16:44 +01:00
Louis Dionne
b51756819a [libc++] Rename include/support to include/__support
We do ship those headers, so the directory name should not be something
that can potentially conflict with user-defined directories.

Differential Revision: https://reviews.llvm.org/D95956
2021-02-04 10:16:33 -05:00
Arthur O'Dwyer
493f140792 [libc++] [P0879] constexpr std::sort
This completes libc++'s implementation of
P0879 "Constexpr for swap and swap related functions."
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0879r0.html

For the feature-macro adjustment, see
https://cplusplus.github.io/LWG/issue3256

Differential Revision: https://reviews.llvm.org/D93661
2021-02-03 18:57:05 -05:00
Arthur O'Dwyer
d41c6d51cb [libc++] Rationalize our treatment of contiguous iterators and __unwrap_iter().
- Implement C++20's changes to `reverse_iterator`, so that it won't be
    accidentally counted as a contiguous iterator in C++20 mode.
- Implement C++20's changes to `move_iterator` as well.
- `move_iterator` should not be contiguous. This fixes a bug where
    we optimized `std::copy`-of-move-iterators in an observable way.
    Add a regression test for that bugfix.
- Add libcxx tests for `__is_cpp17_contiguous_iterator` of all relevant
    standard iterator types. Particularly check that vector::iterator
    is still considered contiguous in all C++ modes, even C++03.

After this patch, there continues to be no supported way to write your
own iterator type in C++17-and-earlier such that libc++ will consider it
"contiguous"; however, we now fully support the C++20 approach (in C++20
mode only). If you want user-defined contiguous iterators in C++17-and-earlier,
libc++'s position is "please upgrade to C++20."

Differential Revision: https://reviews.llvm.org/D94807
2021-02-03 16:28:38 -05:00
Martin Storsjö
cdc60a3b9a [libcxx] Implement the read_symlink function for windows
Differential Revision: https://reviews.llvm.org/D91172
2021-02-03 09:23:58 +02:00
Martin Storsjö
40117b700f [libcxx] Implement the permissions function for windows
Differential Revision: https://reviews.llvm.org/D91171
2021-02-03 09:23:24 +02:00
Martin Storsjö
83d705adb2 [libcxx] Implement the canonical function for windows
Differential Revision: https://reviews.llvm.org/D91170
2021-02-02 23:03:19 +02:00
Martin Storsjö
0c71c914fa [libcxx] Implement the current_path function for windows
Differential Revision: https://reviews.llvm.org/D91169
2021-02-02 23:03:19 +02:00
Louis Dionne
3fb8385379 [libc++] Add new queues for specific macOS system versions
This will allow running back-deployment testing on macOS only on systems
running the right version of macOS. For the time being, we're cheating
because we don't have actual machines running older than 10.15.
2021-02-02 15:56:44 -05:00
Reid Kleckner
bab7486416 Disable CFI in __get_elem to allow casting a pointer to uninitialized memory
Fixes usage of shared_ptr with CFI enabled, which is llvm.org/pr48993.

Differential Revision: https://reviews.llvm.org/D95827
2021-02-02 12:39:24 -08:00
Martin Storsjö
a3cc99658d [libcxx] Implement the space function for windows
Differential Revision: https://reviews.llvm.org/D91168
2021-02-02 19:48:24 +02:00
Mehdi Amini
68f66f37d7 Revert "[libc++][format] Add basic_format_parse_context."
This reverts commit 35a57f39b5.

A build is broken during clang bootstrap with:

In file included from ../libcxx/src/format.cpp:9:
/tmp/ci-nGNyLRM9V3/include/c++/v1/format:153:16: error: no member named 'is_constant_evaluated' in namespace 'std::__1'
    if (_VSTD::is_constant_evaluated() && __id >= __num_args_)
        ~~~~~~~^
1 error generated.
2021-02-01 21:18:11 +00:00
Mark de Wever
35a57f39b5 [libc++][format] Add basic_format_parse_context.
Implements parts of:
- P0645 Text Formatting

Depends on D92214

Reviewed By: ldionne, curdeius, #libc

Differential Revision: https://reviews.llvm.org/D93166
2021-02-01 20:19:20 +01:00
Mark de Wever
3ffc53ba16 [libc++] Implements concept default_initializable.
Implements:
- LWG3149 DefaultConstructible should require default initialization

Implements parts of:
 - P0898R3 Standard Library Concepts
 - P1754 Rename concepts to standard_case for C++20, while we still can

Depends on D91986

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D93461
2021-02-01 19:13:24 +01:00
Ruslan Arutyunyan
c448ea948c [libc++] Fix for the Bug 41784
Add deleted volatile copy-assignment operator in the most derived atomic
to fix the Bug 41784. The root cause: there is an `operator=(T) volatile`
that has better match than the deleted copy-assignment operator of the base
class when `this` is `volatile`. The compiler sees that right operand of
the assignment operator can be converted to `T` and chooses that path
without taking into account the deleted copy-assignment operator of the
base class.

The current behavior on libstdc++ is different from what we have in libc++.
On the same test compilation fails with libstdc++. Proof: https://godbolt.org/z/nebPYd
(everything is the same except the -stdlib option).

I choose the way with explicit definition of copy-assignment for atomic
in the most derived class. But probably we can fix that by moving
`operator=(T)` overloads to the base class from both specializations.
At first glance, it shouldn't break anything.

Differential Revision: https://reviews.llvm.org/D90968
2021-02-01 10:14:22 -05:00
xgupta
94fac81fcc [Branch-Rename] Fix some links
According to the [[ https://foundation.llvm.org/docs/branch-rename/ | status of branch rename ]], the master branch of the LLVM repository is removed on 28 Jan 2021.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D95766
2021-02-01 16:43:21 +05:30
Mark de Wever
8869e2f969 [libc++] Allow building with C++17.
After committing D92214 it was noticed libc++ no longer builds with
C++17. For now reenable building with C++17. This is intended to be a
temporary measure in the future a C++20 capable compiler will be
required.
2021-01-31 14:25:01 +01:00
Casey Carter
6057517904 [libcxx][test] Silence MSVC narrowing warning 2021-01-29 11:05:52 -08:00
Casey Carter
5565092faa [libcxx][test] Silence false positive MSVC /analyze warning 2021-01-29 10:05:14 -08:00
Casey Carter
9f8ca86a87 [libcxx][test] explicitly discard bitset::test's return
... just in case some implementation annotates it `[[nodiscard]]`.
2021-01-29 10:01:51 -08:00
Martin Storsjö
f65ba25cf3 [libcxx] Sanitize paths before creating symlinks on windows
The MS STL does even more cleanup (corresponding to lexically_normal
I think), but this seems to be the very minimum needed for making the
symlinks work when the target path contains non-native paths.

Differential Revision: https://reviews.llvm.org/D91145
2021-01-29 13:39:30 +02:00
Martin Storsjö
efec3cc652 [libcxx] Hook up a number of operation functions to their windows counterparts
Use the corresponding wchar functions, named "_wfunc" instead of "func",
where feasible, or reimplement functions with native windows APIs.

Differential Revision: https://reviews.llvm.org/D91143
2021-01-29 13:38:45 +02:00
Martin Storsjö
592d623529 [libcxx] Implement _FilesystemClock::now() and __last_write_time for windows
Differential Revision: https://reviews.llvm.org/D91142
2021-01-29 13:38:27 +02:00
Martin Storsjö
2ff8662b5d [libcxx] Implement the stat function family on top of native windows APIs
While the windows CRTs (the modern UCRT, and the legacy msvcrt.dll
that mingw still often defaults to) do provide stat functions, they're
a bit lacking - they only provide second precision on the modification
time, lack support for symlinks and a few other details.

Instead reimplement them using a couple windows native functions,
getting exactly the info we need. (Technically, the implementation
within the CRT calls these functions anyway.)

If we only need a few fields, we could also do with fewer calls, as a
later optimization.

Differential Revision: https://reviews.llvm.org/D91141
2021-01-29 13:37:54 +02:00