Commit Graph

7234 Commits

Author SHA1 Message Date
Marek Kurdej a11f8b1ad6 [libc++] [P0935] [C++20] Eradicating unnecessarily explicit default constructors from the standard library.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0935r0.html

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D91292
2021-01-19 08:22:06 +01:00
Arthur O'Dwyer 14573d44ae Regenerate the feature test macro unit-tests. NFCI.
Somehow commit 1f1250151f added the
right code but with the wrong whitespace.
2021-01-18 19:06:28 -05:00
Louis Dionne 2cb4a96a99 [libc++] NFCI: Refactor allocator_traits
The implementation had a lot of boilerplate and was more complicated than
necessary. This NFC refactoring introduces a few macros to reduce code
duplication, and uses a consistent style and formatting for the whole file.

Differential Revision: https://reviews.llvm.org/D94544
2021-01-18 17:37:25 -05:00
Wim Leflere 2776be43f0 [libc++] improve feature test macro script
I've been playing a bit with the `generate_feature_test_macro_components.py` script and replaced some hardcoded values with extra code generation (generate ALL the things).
The output is the same and it makes updating the script less work for the coming 25 C++ standards (until 2 digit number overflow).

Feel free to 'veto' if you think it's overkill.

Differential Revision: https://reviews.llvm.org/D94530
2021-01-18 15:19:21 -05:00
Louis Dionne 01a13f127a [libc++] Rename check-cxx-deps to cxx-test-depends for consistency
Several subprojects have targets that do the same thing, and they all
follow the same naming convention: llvm-test-depends, clang-test-depends,
lld-test-depends, etc.

This makes libc++ consistent with other LLVM projects.
Thanks to Duncan Exon Smith for noticing and suggesting the change.

Differential Revision: https://reviews.llvm.org/D94499
2021-01-18 14:41:53 -05:00
Reid Kleckner 4f24d0dd53 Fix libc++ clang-cl build, swap attribute order
Clang insists that __attribute__ attributes precede __declspec
attributes. This is a longstanding known issue:
https://llvm.org/pr24559. Re-order the visibility and deprecation macros
to fix the build.

Differential Revision: https://reviews.llvm.org/D94788
2021-01-15 11:44:13 -08:00
Igor Kudrin 7803636057 [libcxx testing] Fix UB in tests for std::lock_guard
If mutex::try_lock() is called in a thread that already owns the mutex,
the behavior is undefined. The patch fixes the issue by creating another
thread, where the call is allowed.

Differential Revision: https://reviews.llvm.org/D94656
2021-01-15 16:11:45 +07:00
Shoaib Meenai 0066a09579 [libc++] Give extern templates default visibility on gcc
Contrary to the current visibility macro documentation, it appears that
gcc does handle visibility attribute on extern templates correctly, e.g.
https://godbolt.org/g/EejuV7. We need this so that extern template
instantiations of classes not marked _LIBCPP_TEMPLATE_VIS (e.g.
__vector_base_common) are correctly exported with gcc when building with
hidden visibility.

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D35388
2021-01-12 18:30:56 -08:00
Martin Storsjö 02f1d28ed6 [libcxx] Avoid overflows in the windows __libcpp_steady_clock_now()
As freq.QuadValue can be in the range of 10000000 to 19200000,
the multiplication before division makes the calculation overflow
and wrap to negative values every 16-30 minutes.

Instead count the whole seconds separately before adding the
scaled fractional seconds.

Add a testcase for steady_clock to check that the values returned for
now() compare as bigger than the zero time origin; this
corresponds to a testcase in Qt [1] [2] (that failed spuriously
due to this).

[1] https://bugreports.qt.io/browse/QTBUG-89539
[2] https://code.qt.io/cgit/qt/qtbase.git/tree/tests/auto/corelib/kernel/qdeadlinetimer/tst_qdeadlinetimer.cpp?id=f8de5e54022b8b7471131b7ad55c83b69b2684c0#n569

Differential Revision: https://reviews.llvm.org/D93456
2021-01-12 23:56:03 +02:00
Brad Smith 79f99ba65d [libcxx] Port to OpenBSD
Add initial OpenBSD support.

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D94205
2021-01-12 14:21:11 -05:00
Arthur O'Dwyer eef4bdbb34 [libc++] Add a missing `<_Compare>` template argument.
Sometimes `_Compare` is an lvalue reference type, so letting it be
deduced is pretty much always wrong. (Well, less efficient than
it could be, anyway.)

Differential Revision: https://reviews.llvm.org/D93562
2021-01-12 14:18:24 -05:00
Marek Kurdej 1f1250151f [libc++] [C++2b] [P1048] Add is_scoped_enum and is_scoped_enum_v.
* https://wg21.link/p1048

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D94409
2021-01-12 17:08:20 +01:00
Marek Kurdej 30a7d430e8 [libc++] Turn off auto-formatting of generated files. NFC.
This adds `// clang-format off` in the auto-generated file to avoid lint warnings.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D94410
2021-01-11 20:49:26 +01:00
Louis Dionne d86e16e4bd [libc++] NFC: Document the Differential queries to avoid duplicating work
Differential Revision: https://reviews.llvm.org/D94343
2021-01-08 17:47:39 -05:00
Arthur O'Dwyer cdd7cbf7b5 [libc++] Mark [P0809] "LWG2831: Comparing Unordered Containers" as Nothing To Do.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0809r0.pdf

This issue/paper simply removed some library UB because vendors were
already doing the right thing. libc++ has always done the right thing
(in this respect).

Differential Revision: https://reviews.llvm.org/D93816
2021-01-08 17:33:22 -05:00
Arthur O'Dwyer 963b771e24 [libc++] Mark [P0475] "LWG2511: guaranteed copy elision for piecewise construction" as Complete.
The point of LWG2511 is basically just to make sure that we use
`tuple<Args&&...>` instead of `tuple<Args...>` in a couple of places
inside `scoped_allocator_adaptor` and inside `pair`.
As far as I can tell, this has been true for libc++
since EricWF's D27612 (and maybe even earlier than that).
2021-01-08 17:33:13 -05:00
Arthur O'Dwyer ca1694b9d0 Re-enable __cpp_lib_constexpr_functional.
I accidentally disabled this feature-test macro in my D93830,
due to a rebasing conflict. It had been enabled by my D93815,
and should have remained enabled.
2021-01-08 17:30:04 -05:00
Louis Dionne bc556e5685 [libc++/abi] Re-remove unnecessary null pointer checks from operator delete
In 7cd67904f7, we removed the unnecessary nullptr checks from the libc++abi
definition of operator delete, but we forgot to update the definition in
libc++ (damn code duplication!). Then, in d4a1e03c5f, I synced the
definitions across libc++ and libc++abi, but I did it the wrong way around.
I re-added the if() checks to libc++abi instead of removing them from libc++.

In ef74f0fdc3, we re-removed the if() check from operator delete, but
only in libc++abi. This patch corrects this mess and removes it
consistently in libc++ and libc++abi.

Differential Revision: https://reviews.llvm.org/D93473
2021-01-08 17:03:50 -05:00
Louis Dionne 955dd7b7f3 [libc++] LWG2070: Use Allocator construction for objects created with allocate_shared
This patch updates `allocate_shared` to call `allocator_traits::construct`
when creating the object held inside the shared_pointer, and
`allocator_traits::destroy` when destroying it. This resolves
the part of P0674R1 that was originally filed as LWG2070.

This change is landed separately from the rest of P0674R1 because it is
incredibly tricky from an ABI perspective.

This is the reason why this change is so tricky is that we previously
used EBO in a compressed pair to store both the allocator and the object
type stored in the `shared_ptr`. However, starting in C++20, P0674
requires us to use Allocator construction for initializing the object type.
That requirement rules out the use of the EBO for the object type, since
using the EBO implies that the base will be initialized when the control
block is initialized (and hence we can't do it through Allocator construction).
Hence, supporting P0674 requires changing how we store the object type
inside the control block, which we do while being ABI compatible by using
some trickery with a properly aligned char buffer.

Fixes https://llvm.org/PR41900
Supersedes https://llvm.org/D62760

Differential Revision: https://reviews.llvm.org/D91201
2021-01-08 13:04:03 -05:00
Marek Kurdej 95729f95d8 [libc++] Add basic support for -std=c++2b.
* Add feature test macros.
* Add buildbot configuration generic-cxx2b that uses clang-tot.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D94227
2021-01-08 19:02:41 +01:00
Arthur O'Dwyer 466df1718e [libc++] Update generate_feature_test_macro_components.py to match SD-6.
It's still a little confusing because in many cases C++17 and C++20
have different values, and libc++ implements the C++17 behavior but
not the C++20 behavior; 'unimplemented' can't represent that scenario.
Ultimately we probably ought to completely redesign the script to be
in terms of paper numbers, rather than language revisions, and make
it generate the CSV files like "Cxx2aStatusPaperStatus.csv" as well.

Most newly added macros are unimplemented. I've marked a few as implemented,
though, based on my reading of the code; for example I was pretty sure
`__cpp_lib_latch` is implemented since we have `<latch>`.

Differential Revision: https://reviews.llvm.org/D93830
2021-01-08 11:44:39 -05:00
Alex Richardson 32733c347d [libc++] Add missing XFAIL to tests that need __atomic_* libcalls
FreeBSD did not provide the __atomic_* functions as part of the base
system until recently. They were added to libgcc_s in SVN revision r364753
(August 2020), so check for availability of 'non-lockfree-atomics' so that
these tests do not fail unexpectedly on older versions of FreeBSD.

This also removes the #ifndef __APPLE__ from atomic_helpers.h that was used
to work around lack of atomic runtime functions on older Apple platforms
and replaces it with XFAIL: !non-lockfree-atomics.

Reviewed By: #libc, ldionne
Differential Revision: https://reviews.llvm.org/D88818
2021-01-08 12:48:22 +00:00
Arthur O'Dwyer ff1b6f9ff2 [libc++] Alphabetize generate_feature_test_macro_components.py. NFCI.
For ease of comparing our list with the official SD-6 list, which is alphabetized.
https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#library-feature-test-macros
This also alphabetizes the lists of headers in which the macros are
defined, which harmlessly alters many comments in <version>.
Also drive-by-fix some trivial flake8 warnings.
2021-01-07 18:11:46 -05:00
Louis Dionne c01202a7ef [libc++] Fix typo in run-buildbot
The installation directory was never meant to contain a brace.
2021-01-07 17:37:09 -05:00
Marek Kurdej 044b892c79 [libc++] Use c++20 instead of c++2a consistently.
* The only exception is that the flag -std=c++2a is still used not to break compatibility with older compilers (clang <= 9, gcc <= 9).
* Bump _LIBCPP_STD_VER for C++20 to 20 and use 21 for the future standard (C++2b).

That's a preparation step to add c++2b support to libc++.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D93383
2021-01-07 13:11:33 +01:00
Mikhail Maltsev 7da3e3a898 [libcxx] Mark a test as unsupported for C++03
The nullptr_t_integral_cast.pass.cpp test is currently xfailed for
C++03, but actually, it only fails with the first version of libc++
ABI.

This patch changes XFAIL to UNSUPPORTED to avoid unexpected passes
with ABI v2 or later.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D93941
2021-01-07 12:06:08 +00:00
Marek Kurdej b6fb0209b6 [libc++] [CI] Install Tip-of-Trunk clang.
* Check created symlinks.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D93520
2021-01-07 12:04:09 +01:00
Martin Storsjö f4485240a2 [libcxx] Handle backslash as path separator on windows
Differential Revision: https://reviews.llvm.org/D91138
2021-01-07 10:02:47 +02:00
Arthur O'Dwyer 781c476ce0 [libc++] ADL-proof vector<bool> by adding _VSTD:: qualification on calls.
This affects only vectors with weird/malicious allocators,
the same corner case covered in D91708, but for `vector<bool>` this time.

Also ADL-proof <__tree>, which affects only sets and maps with weird/malicious
allocators where the ADL trap is in the *fancy pointer type*.

Also drive-by _VSTD:: qualification in the guts of std::bind,
std::packaged_task, std::condition_variable.

Differential Revision: https://reviews.llvm.org/D93424
2021-01-06 18:23:50 -05:00
Marek Kurdej 3f0b637d6b [libc++] [docs] Mark contract-related papers as removed from C++20. 2020-12-30 14:24:26 +01:00
Arthur O'Dwyer c0a2d3b90b [libc++] Fix a test failure in 7b00e9fae3 (D93815).
"LLVM Buildbot on libcxx-libcxxabi-libunwind-armv7-linux" is not happy
with comparing `unsigned` and `int` [-Werror,-Wsign-compare].
2020-12-28 18:46:07 -05:00
Arthur O'Dwyer dd756e3e84 [libc++] Fix a test failure in 7b00e9fae3 (D93815).
"LLVM Buildbot on libcxx-libcxxabi-x86_64-linux-debian" is not happy
with default-initializing the `double` member of `A` in a constexpr
function. At least I'm pretty sure that's what it's complaining about.
2020-12-28 13:55:40 -05:00
Arthur O'Dwyer 7b00e9fae3 [libc++] [P1065] Constexpr invoke, reference_wrapper, mem_fn, not_fn, default_searcher.
This completes the implementation of P1065 "constexpr INVOKE":
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1065r2.html

This doesn't yet complete the implementation of P1032 "Misc constexpr bits,"
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1032r1.html
but it does complete all of the <functional> bits, which means
that we can now set `__cpp_lib_constexpr_functional` for C++20.

This could use more constexpr tests for `std::reference_wrapper<T>`,
but the existing tests are extremely non-constexpr-friendly and
so I don't want to get into that rabbit-hole today.

Differential Revision: https://reviews.llvm.org/D93815
2020-12-28 13:24:07 -05:00
Arthur O'Dwyer 30f589c912 [libc++] Constexpr-proof some machinery in not_fn.pass.cpp. NFCI.
We don't need to use global variables here; we can store the "State"
of this machinery on the stack, so that it's constexpr-friendly.
2020-12-28 13:24:07 -05:00
Alex Richardson 0f81598cc1 [libc++] Add a 'is-lockfree-runtime-function' lit feature
On macOS 10.14 /usr/lib/system/libcompiler_rt.dylib contains all the
`__atomic_load*`, etc. functions but does not include the `__atomic_is_lock_free`
function. The lack of this function causes the non-lockfree-atomics feature
to be set to false even though large atomic operations are actually
supported, it's just the is_lock_free() function that is missing.

This is required so that the !non-lockfree-atomics feature can be used
to XFAIL tests that require runtime library support (D88818).

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D91911
2020-12-22 11:56:20 +00:00
Mark de Wever 5740f96d8e [NFC][libc++] Fixes swapped comments. 2020-12-19 16:16:54 +01:00
Martin Storsjö 156180727d [libcxx] Fix the preexisting directory_iterator code for windows
The directory_iterator.cpp file did contain an incomplete,
non-working implementation for windows.

Change it to use the wchar version of the APIs.

Don't set the windows specific errors from GetLastError() as code
in the generic category; remap the errors to the std::errc values.

Error out cleanly on empty paths.

Invoke FindFirstFile on <directoryname>/* to actually list the
entries of the directory.

If the first entry retured by FindFirstFile is to be skipped (e.g.
being "." or ".."), call advance() (which calls FindNextFile and loops)
which doesn't return until a valid entry is found (or the end is
reached).

Differential Revision: https://reviews.llvm.org/D91140
2020-12-18 11:24:53 +02:00
Martin Storsjö de698ae734 [libcxx] Convert paths to/from the right narrow code page for narrow strings on windows
On windows, the narrow, char based paths normally don't use utf8, but
can use many different native code pages, and this is what system
functions that operate on files, taking such paths/file names, interpret
them as.

Differential Revision: https://reviews.llvm.org/D91137
2020-12-18 11:24:52 +02:00
Martin Storsjö 48c6500b5b [libcxx] Reorder the two u8path functions, to make the following diff more readable. NFC.
Differential Revision: https://reviews.llvm.org/D91136
2020-12-18 11:24:52 +02:00
Martin Storsjö e83e0cac04 [libcxx] Make filesystem::path::value_type wchar_t on windows
Also set the preferred separator to backslash.

libc++ doesn't compile successfully for windows prior to this change,
and this change on its own isn't enough to make it compile successfully
either, but is the first stepping stone towards making it work correctly.

Most of operations.cpp will need to be touched, both for calling
functions that take wchar paths, but also for using other windows
specific functions instead of the posix functions used so far; that is
handled in later commits.

Changing parts of operations.cpp to generalize the string type handling
in code that doesn't touch system functions.

Differential Revision: https://reviews.llvm.org/D91135
2020-12-18 11:24:52 +02:00
Azat Khuzhin 6340f890bb [libc++] Fix extern C for __sanitizer_annotate_contiguous_container() (for gcc)
gcc supports it only at the beginning:

    $ g++ -o /dev/null -c /tmp/test_extern.cpp
    $ cat /tmp/test_extern.cpp
    extern "C" __attribute__ ((__visibility__("default"))) int foo();

Otherwise:

    $ g++ -o /dev/null -c /tmp/test_extern.cpp
    /tmp/test_extern.cpp:1:52: error: expected unqualified-id before string constant
        1 | __attribute__ ((__visibility__("default"))) extern "C" int foo();
          |                                                    ^~~
    $ cat /tmp/test_extern.cpp
    __attribute__ ((__visibility__("default"))) extern "C" int foo();

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D93316
2020-12-17 16:20:24 -05:00
Martin Storsjö 08a00c6f43 [libcxx] Remove ifdefs in the message to static_assert. NFC.
Differential Revision: https://reviews.llvm.org/D93283
2020-12-17 13:37:52 +02:00
Louis Dionne 46ae360452 [libc++] Fix CI Dockerfile
Installing clang-format-11 doesn't seem to work if it's done before
we've installed LLVM. I must admit I didn't try to get to the bottom
of the issue, since installing it after seems to work.
2020-12-16 17:01:21 -05:00
Marek Kurdej d69fc6629d [libc++] Install git-clang-format on CI nodes.
Two problems fixed:
* an old version of clang-format get installed by default (6.0).
* git-clang-format is not present, only git-clang-format-<version> (e.g. git-clang-format-6.0).

Solution:
* install clang-format-11 with explicit version
* make symlink git-clang-format to the latest version of git-clang-format-<version>

Differential Revision: https://reviews.llvm.org/D93201
2020-12-16 16:36:34 -05:00
Louis Dionne f2966d17a2 [libc++] Use consistent declaration for main() in test 2020-12-15 17:34:06 -05:00
Marek Kurdej d1da346296 [libc++] Fix synopsis in string::ends_with test. NFC. 2020-12-15 19:03:11 +01:00
Louis Dionne a00290ed10 [libc++] Fix allocate_shared when used with an explicitly convertible allocator
When the allocator is only explicitly convertible from other specializations
of itself, the new version of std::allocate_shared would not work because
it would try to do an implicit conversion. This patch fixes the problem
and adds a test so that we don't fall into the same trap in the future.
2020-12-15 11:50:06 -05:00
Louis Dionne b3d1d1f4ff [libc++] Remove unnecessary static assertion in allocate_shared
Checking that `T` is constructible from `Args...` is technically not
required by the Standard, although any implementation will obviously
error out if that's not satisfied. However, this check is incompatible
with using Allocator construction in the control block (upcoming change
as part of implementing P0674), so I'm removing it now to reduce the
upcoming diff as much as possible.

Differential Revision: https://reviews.llvm.org/D93246
2020-12-14 17:47:43 -05:00
Louis Dionne 3b7280f5e4 [libc++] NFCI: Return pointer instead of reference from __shared_ptr_emplace helper method
This makes __get_alloc consistent with __get_elem, and will reduce the
diff required to implement P0674R1.
2020-12-14 17:46:09 -05:00
Louis Dionne 19d57b5c42 [libc++] Refactor allocate_shared to use an allocation guard
This commit is a step towards making it easier to add support for arrays
in allocate_shared. Adding support for arrays will require writing multiple
functions, and the current complexity of writing allocate_shared is
prohibitive for understanding.

Differential Revision: https://reviews.llvm.org/D93130
2020-12-14 17:10:05 -05:00
Louis Dionne 7ad49aec12 [libc++] Split allocator_traits and pointer_traits out of <memory>
In addition to making the code a lot easier to grasp by localizing many
helper functions to the only file where they are actually needed, this
will allow creating helper functions that depend on allocator_traits
outside of <memory>.

This is done as part of implementing array support in allocate_shared,
which requires non-trivial array initialization algorithms that would be
better to keep out of <memory> for sanity. It's also a first step towards
splitting up our monolithic headers into finer grained ones, which will
make it easier to reuse functionality across the library. For example,
it's just weird that we had to define `addressof` inside <type_traits>
to avoid circular dependencies -- instead it's better to implement those
in true helper headers.

Differential Revision: https://reviews.llvm.org/D93074
2020-12-14 16:13:57 -05:00
Arthur O'Dwyer 3c8e31e17b [libc++] ADL-proof <functional> by adding _VSTD:: qualification on calls.
- std::reference_wrapper
- std::function
- std::mem_fn

While I'm here, remove _VSTD:: qualification from calls to `declval`
because it takes no arguments and thus isn't susceptible to ADL.

Differential Revision: https://reviews.llvm.org/D92884
2020-12-14 12:08:34 -05:00
Arthur O'Dwyer be4c657b01 [libc++] Consistently replace `::new(__p) T` with `::new ((void*)__p) T`. NFCI.
Everywhere, normalize the whitespace to `::new (EXPR) T`.
Everywhere, normalize the spelling of the cast to `(void*)EXPR`.

Without the cast to `(void*)`, the expression triggers ADL on GCC.
(I think this is a GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98249)
Even if it doesn't trigger ADL, it still seems incorrect to use any argument
that's not exactly `(void*)` because that opens the possibility of overload
resolution picking a user-defined overload of `operator new`, which would be
wrong.

Differential Revision: https://reviews.llvm.org/D93153
2020-12-14 12:08:34 -05:00
Marek Kurdej 59c72a7012 [libc++] [P1164] Add tests for create_directories. NFC.
That's a follow-up patch after D92769.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D93026
2020-12-14 17:27:18 +01:00
Arthur O'Dwyer 2664f5d436 generate_header_tests.py: Sort the header files ASCIIbetically.
Otherwise they come out in random (inode?) order.

Also `chmod +x` the generator, and re-run it. Somehow on Marek's
machine it produced \r\n line endings?! Open all files with
`newline='\n'` so that (if the Python3 docs are correct)
that won't happen again.

Differential Revision: https://reviews.llvm.org/D93137
2020-12-14 09:56:07 -05:00
Arthur O'Dwyer b6f1917415 [libc++] Fix some one-off typos in comments. NFCI. 2020-12-14 09:54:58 -05:00
Arthur O'Dwyer ce9ac549c9 [libc++] Remove __is_construct::__nat. NFCI.
This type has been unused since commit 5b4cc84b87.
2020-12-14 09:54:58 -05:00
Arthur O'Dwyer e9eb99999f [libc++] s/insertible/insertable/g. NFCI. 2020-12-14 09:54:58 -05:00
Arthur O'Dwyer 1d7c39e14e [libc++] s/Birdirectional/Bidirectional/g. NFCI. 2020-12-14 09:54:57 -05:00
Richard Smith 7de9c61f31 Fix test expectation to cope with custom version namespaces. 2020-12-13 22:43:24 -08:00
Louis Dionne d02eac0c00 [libc++] Fix Docker image build after installing clang-format 2020-12-11 14:13:13 -05:00
Louis Dionne 202df6870e [libc++] Install clang-format on CI nodes 2020-12-11 14:06:42 -05:00
Louis Dionne f75bf712de [libc++] Use TARGET_FILE instead of TARGET_SONAME_FILE when generating ABI lists
TARGET_SONAME_FILE isn't valid on Windows, and TARGET_FILE should achieve
the same results.

Differential Revision: https://reviews.llvm.org/D92856
2020-12-11 12:12:40 -05:00
Louis Dionne ece3e5bb8b [libc++] NFCI: Implement make_shared as allocate_shared with std::allocator
This simplifies the implementation, and it appears to be equivalent since
make_shared was allocating memory with std::allocator anyway.

Differential Revision: https://reviews.llvm.org/D93071
2020-12-11 12:01:48 -05:00
Marek Kurdej da97d12cc0 [libc++] Remove invalid use of `#if _LIBCPP_STD_VER >= 11`, as `_LIBCPP_STD_VER` can never be less than 11.
The relevant part of `__config` is:
```
#ifndef _LIBCPP_STD_VER
#  if  __cplusplus <= 201103L
#    define _LIBCPP_STD_VER 11
```

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D93025
2020-12-11 08:31:59 +01:00
Arthur O'Dwyer 3696227c10 [libc++] ADL-proof by adding _VSTD:: qualifications to memmove etc.
Generally these calls aren't vulnerable to ADL because they involve only
primitive types. The ones in <list> and <vector> drag in namespace std
but that's OK; the ones in <fstream> and <strstream> are vulnerable
iff `CharT` is an enum type, which seems far-fetched.
But absolutely zero of them *need* ADL to happen; so in my opinion
they should all be consistently qualified, just like calls to any
other (non-user-customizable) functions in namespace std.

Also: Include <cstring> and <cwchar> in <__string>.
We seemed to be getting lucky that <memory> included <iterator>
included <iosfwd> included <wchar.h>. That gave us the
global-namespace `wmemmove`, but not `_VSTD::wmemmove`.
This is now fixed.

I didn't touch these headers:
<ext/__hash> uses strlen, safely
<support/ibm/locale_mgmt_aix.h> uses memcpy, safely
<string.h> uses memchr and strchr, safely
<wchar.h> uses wcschr, safely
<__bsd_locale_fallbacks.h> uses wcsnrtombs, safely

Differential Revision: https://reviews.llvm.org/D93061
2020-12-10 22:03:12 -05:00
Arthur O'Dwyer b12ea06521 [libc++] Include C++ headers, not C headers, in <charconv>.
This matches how libc++ does it in all other C++ headers
(that is, headers not ending in ".h").
We need to include <cstring> if we want to use `_VSTD::memmove`
instead of unqualified ADL `memmove`. Even though ADL doesn't
physically matter in <charconv>'s specific case, I'm trying
to migrate libc++ to using `_VSTD::memmove` for all cases
(because some of them do matter, and this way it's easier to
grep for outliers).

Differential Revision: https://reviews.llvm.org/D92875
2020-12-10 22:03:12 -05:00
Louis Dionne 092e8a7ea3 [libc++] NFCI: Refactor __shared_ptr_emplace
This is the first of a series of patches leading up to the implementation
of P0674r1, i.e. array support in allocate_shared. I am splitting this
up into multiple patches because the overall change is very tricky and
I want to isolate potential breakage.
2020-12-10 16:45:58 -05:00
Marek Kurdej e4ed349c76 [libc++] [P1164] [C++20] Make fs::create_directory() error if there is already a non-directory.
Also mark LWG2935 and LWG3079 as complete.

Applied retroactively to previous standards too, as it's a DR.

* https://wg21.link/P1164
* https://wg21.link/lwg2935
* https://wg21.link/lwg3079

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D92769
2020-12-10 08:40:27 +01:00
Marek Kurdej 6fd5a94eeb [libc++] Add a script to automatize updating test for a new header.
Idea from D92525.
This script globs include/ directory and updates the tests in test/libcxx.
This patch does not generate module.modulemap nor CMakeLists.txt.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D92656
2020-12-10 08:37:50 +01:00
Richard Smith 2a2c228c7a Add new 'preferred_name' attribute.
This attribute permits a typedef to be associated with a class template
specialization as a preferred way of naming that class template
specialization. This permits us to specify that (for example) the
preferred way to express 'std::basic_string<char>' is as 'std::string'.

The attribute is applied to the various class templates in libc++ that have
corresponding well-known typedef names.

This is a re-commit. The previous commit was reverted because it exposed
a pre-existing bug that has since been fixed / worked around; see
PR48434.

Differential Revision: https://reviews.llvm.org/D91311
2020-12-09 12:22:35 -08:00
Louis Dionne 717b0da7a6 [libc++] Run back-deployment CI on macOS 10.15 instead of 10.14
The goal was to add coverage for back-deployment over the filesystem
library, but it was added in macOS 10.15, not 10.14.

Differential Revision: https://reviews.llvm.org/D92937
2020-12-09 11:35:15 -05:00
Arthur O'Dwyer 2130699ba4 [libc++] Mark my new <algorithm> test unsupported on clang-8.
Because in C++20 mode, it tests that `copy_n` is constexpr;
so it depends on the compiler supporting `is_constant_evaluated`.
2020-12-08 17:25:23 -05:00
Arthur O'Dwyer 1968804ac7 [libc++] Add _VSTD:: qualifications to ADL-proof <algorithm>.
Relevant blog post: https://quuxplusone.github.io/blog/2019/09/26/uglification-doesnt-stop-adl/

Differential Revision: https://reviews.llvm.org/D92776
2020-12-08 17:05:38 -05:00
Arthur O'Dwyer 35c3b53943 [libc++] ADL-proof __libcpp_is_nothrow_constructible.
The GCC C++20 buildbot hit this ADL call; Clang doesn't,
presumably because it uses a compiler builtin instead of
this codepath in <type_traits>.
https://buildkite.com/llvm-project/libcxx-ci/builds/674
2020-12-08 17:05:38 -05:00
Louis Dionne a65dc08d10 [libc++] Implement missing feature-test macro __cpp_lib_shared_ptr_arrays
This was forgotten when we implemented support for arrays in std::shared_ptr
in https://reviews.llvm.org/D62259.
2020-12-08 15:46:45 -05:00
Louis Dionne 3e46b3a188 [libc++] NFC: Indent feature-test macro script consistently 2020-12-08 15:42:57 -05:00
Yuriy Chernyshov b526d87618 [libc++] Add std::hash<char8_t> specialization if char8_t is enabled
Differential Revision: https://reviews.llvm.org/D92325
2020-12-08 13:46:18 -05:00
Marek Kurdej 877170f3eb [libc++] [LWG3221] Add tests for wrapping operator+(year_month, months).
The behaviour didn't change since commit 5b08c1742a (Recommit <chrono> changes with a couple xtra tests marked to fail on apple's clang.)

* http://wg21.link/lwg3221

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D92730
2020-12-08 18:08:04 +01:00
Arthur O'Dwyer c0428b3c0c [libc++] ADL-proof <iterator>. `__convert_to_integral` is not a customization point.
The interesting change here is that we no longer consider `__convert_to_integral`
an ADL customization point for the user's types. I think the new behavior
is defensible. The old behavior had come from D7449, where Marshall explicitly
said "people can't define their own [`__convert_to_integral` overloads]."

Differential Revision: https://reviews.llvm.org/D92814
2020-12-08 11:19:16 -05:00
Louis Dionne 8726f94cc7 [libc++] Add a CI job to backdeploy to macOS 10.14
It adds coverage for back-deploying to a system that contains the
filesystem library, which 10.9 (currently our only back-deployment
target in the CI) does not have.

Differential Revision: https://reviews.llvm.org/D92794
2020-12-08 11:07:56 -05:00
Richard Smith a1344779ab Revert "Add new 'preferred_name' attribute."
This change exposed a pre-existing issue with deserialization cycles
caused by a combination of attributes and template instantiations
violating the deserialization ordering restrictions; see PR48434 for
details.

A previous commit attempted to work around PR48434, but appears to have
only been a partial fix, and fixing this properly seems non-trivial.
Backing out for now to unblock things.

This reverts commit 98f76adf4e and
commit a64c26a47a.
2020-12-08 00:42:48 -08:00
Marek Kurdej ba3adfad6e [libc++] Mark LWG3200 as Nothing To Do. NFC.
This is only a wording change, because it is currently impossible to constrain the overload set on whether the type is complete or not.
2020-12-08 09:00:45 +01:00
Richard Smith 98f76adf4e Add new 'preferred_name' attribute.
This attribute permits a typedef to be associated with a class template
specialization as a preferred way of naming that class template
specialization. This permits us to specify that (for example) the
preferred way to express 'std::basic_string<char>' is as 'std::string'.

The attribute is applied to the various class templates in libc++ that have
corresponding well-known typedef names.

Differential Revision: https://reviews.llvm.org/D91311
2020-12-07 12:53:07 -08:00
Marek Kurdej bf8683adfa [libc++] [docs] Mark LWG3055 as complete. Use string_view instead of string in path::operator+=(ECharT).
The issue didn't change the behaviour which is tested in libcxx/test/std/input.output/filesystems/class.path/path.member/path.concat.pass.cpp.

The change to use string_view instead of string is not strictly necessary.

<filesystem> was added in commit 998a5c8831 (Implement <filesystem>).

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D92731
2020-12-07 20:18:09 +01:00
Marek Kurdej e2279c2350 [libc++] [docs] Mark P1865 as complete since 11.0 as it was implemented together with P1135. Fix synopses in <barrier> and <latch>.
It was implemented in commit 54fa9ecd30 ([libc++] Implementation of C++20's P1135R6 for libcxx).
2020-12-06 15:36:52 +01:00
Marek Kurdej f6326736ba [libc++] [LWG3374] Mark `to_address(const Ptr& p)` overload `constexpr`.
Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D92659
2020-12-06 15:26:26 +01:00
Zbigniew Sarbinowski e6c89a499d [SystemZ][ZOS] Fix the usage of pthread_t within libc++
This is the the minimal change introduced in [[ https://reviews.llvm.org/D88599 | D88599 ]]  to unblock the controversial change and discussion of proper separation between thread from thread id which will continue in D88599.

This patch will address the differences of definition of pthread_t on z/OS vs. Linux and other OS. Main trick to make the code work on z/OS relies on redefining libcpp_thread_id type and _LIBCPP_NULL_THREAD macro. This is necessary to separate initialization of libcxx_thread_id from the one of __libcxx_thread_t;

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D91875
2020-12-05 17:46:30 +00:00
Mark de Wever ce6269f9ba [NFC][libc++] Update C++20 issues status.
Properly mark LWG1203 as completed and move the version number to the
version column.
2020-12-05 16:36:19 +01:00
Arthur O'Dwyer b8bc4e153f [libc++] Update the commented "synopsis" in <algorithm> to match current reality.
The synopsis now reflects what's implemented. It does NOT reflect
all of what's specified in C++20. The "constexpr in C++20" markings
are still missing from these 12 algorithms, because they are still
unimplemented by libc++:

    reverse partition sort nth_element next_permutation prev_permutation
    push_heap pop_heap make_heap sort_heap partial_sort partial_sort_copy

All of the above algorithms were excluded from [P0202].

All of the above algorithms were made constexpr in [P0879] (along with
swap_ranges, iter_swap, and rotate — we've already implemented those three).

Differential Revision: https://reviews.llvm.org/D92255
2020-12-04 17:53:54 -05:00
Arthur O'Dwyer 14098cf6c0 [libc++] [P0202] constexpr set_union, set_difference, set_symmetric_difference, merge
These had been waiting on the ability to use `std::copy` from
constexpr code (which in turn had been waiting on the ability to
use `is_constant_evaluated()` to switch between `memmove` and non-`memmove`
implementations of `std::copy`). That work landed a while ago,
so these algorithms can all be constexpr in C++20 now.

Simultaneously, update the tests for the set algorithms.

- Use an element type with "equivalent but not identical" values.
- The custom-comparator tests now pass something different from `operator<`.
- Make the constexpr coverage match the non-constexpr coverage.

Differential Revision: https://reviews.llvm.org/D92255
2020-12-04 17:53:54 -05:00
Arthur O'Dwyer c75c6549ba [libc++] Slightly improve constexpr test coverage for std::includes.
Differential Revision: https://reviews.llvm.org/D92255
2020-12-04 17:53:53 -05:00
Brett Gutstein 297c839e2d [libc++] fix std::sort(T**, T**)
previously, invocations of std::sort(T**, T**) casted the arguments to
(size_t *). this breaks sorting on systems for which pointers don't fit
in a size_t. change the cast to (uintptr_t *) and add a test.

Differential Revision: https://reviews.llvm.org/D92190
2020-12-04 16:05:21 -05:00
Marek Kurdej 5ad6ed5298 [libc++] [test] Disable parts of path.factory.pass.cpp as requiring localization enabled.
It was added in commit 6be11e35d5, "[libcxx] Implement c++2a char8_t input/output of std::filesystem::path".
2020-12-04 20:04:35 +01:00
Marek Kurdej b04a5e752f [libc++] [test] Mark path.charconv.pass.cpp as requiring localization enabled.
It was added in commit 0b71bf7939, "[libcxx] [test] Add a test for conversions between wchar_t, utf8, char16_t, char32_t and windows native narrow code pages"
2020-12-04 19:58:48 +01:00
Marek Kurdej c36801ecd5 [libc++] [docs] Add Version column to issues tables on status pages. 2020-12-04 18:44:35 +01:00
Martin Storsjö 0b71bf7939 [libcxx] [test] Add a test for conversions between wchar_t, utf8, char16_t, char32_t and windows native narrow code pages
Differential Revision: https://reviews.llvm.org/D91133
2020-12-04 11:37:05 +02:00
Martin Storsjö 6be11e35d5 [libcxx] Implement c++2a char8_t input/output of std::filesystem::path
This implements the std::filesystem parts of P0482 (which is already
marked as in progress), and applies the actions that are suggested
in P1423.

Differential Revision: https://reviews.llvm.org/D90222
2020-12-04 11:37:05 +02:00
Arthur O'Dwyer d430330788 [libc++] Update and normalize the "all the headers" tests.
Some C++20 headers weren't added properly to all three of these
test files. Add them, and take the time to normalize the formatting
so that

    diff <(grep '#include' foo.cpp) <(grep '#include' bar.cpp)

shows no diffs (except that `no_assert_include` deliberately
excludes `<cassert>`).

- Add macro guards to <{barrier,latch,semaphore}>.
- Add macro guards to <experimental/simd>.
- Remove an include of <cassert> from <semaphore>.
- Instead, include <cassert> in the semaphore tests.

Differential Revision: https://reviews.llvm.org/D92525
2020-12-03 15:01:38 -05:00
Marek Kurdej 590bbfe0d8 [libc++] [docs] Add C++2b (to be C++23) status page.
Also:
* Fix header line in all status tables.
* Use C++20 instead of C++2a.

Reviewed By: ldionne, #libc, miscco

Differential Revision: https://reviews.llvm.org/D92306
2020-12-03 09:22:06 +01:00
Louis Dionne 4277adda1d [libc++] Install missing packages to cross-compile to 32 bits during CI 2020-12-02 16:45:53 -05:00
zoecarver 644f68ed4d [libc++] Add slice_array operator= valarray overload.
Add the slice_array::operator=(const std::valarray<T>& val_arr) overload.

Fixes https://llvm.org/PR40792.

Differential Revision: https://reviews.llvm.org/D58735
2020-12-02 10:49:20 -08:00
Marek Kurdej 28797e9952 [libc++] [docs] Mark LWG2296 as complete not only on clang.
std::addressof was made constexpr in gcc 7.
libc++ fixed it in ac473034fc (Provide a constexpr addressof with GCC 7.)
2020-12-02 11:39:43 +01:00
Marek Kurdej d82fb6022b [libc++] [docs] Mark P1424 as superseded by P1902. 2020-12-02 11:19:37 +01:00
Marek Kurdej a984dcaf7c [libc++] [P0482] [C++20] Implement missing bits for codecvt and codecvt_byname.
Add codecvt*<char16_t, char8_t> and codecvt*<char32_t, char8_t>.
Deprecate codecvt<char(16|32)_t, char>.
Enable disabled tests.
Update _LIBCPP_STD_VER to use 20 for C++20. Add _LIBCPP_DEPRECATED_IN_CXX20 macro.

Reviewed By: ldionne, #libc, #libc_abi

Differential Revision: https://reviews.llvm.org/D91517
2020-12-02 09:01:58 +01:00
Martin Storsjö 0d7bd72f5a [libcxx] Apply msvcrt specific exception for lgamma() to mingw configurations, too
This fixes linking code that uses some bits of the <random> header
on mingw targets.

Differential Revision: https://reviews.llvm.org/D92379
2020-12-02 09:55:16 +02:00
Marek Kurdej 1c656e9b64 [libc++] [docs] Update and move NOTES.txt to docs/Contributing.rst.
Also, add notes about exporting ABI symbols.
Later, we can add notes about using git-clang-format before sending a patch for review.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D92300
2020-12-02 08:54:11 +01:00
Arthur O'Dwyer e181a6aedd s/instantate/instantiate/ throughout. NFCI.
The static_assert in "libcxx/include/memory" was the main offender here,
but then I figured I might as well `git grep -i instantat` and fix all
the instances I found. One was in user-facing HTML documentation;
the rest were in comments or tests.
2020-12-01 22:13:40 -05:00
Arthur O'Dwyer d586f92c94 [libc++] Consistently replace `std::` qualification with `_VSTD::` or nothing. NFCI.
I used a lot of `git grep` to find places where `std::` was being used
outside of comments and assert-messages. There were three outcomes:

- Qualified function calls, e.g. `std::move` becomes `_VSTD::move`.
    This is the most common case.

- Typenames that don't need qualification, e.g. `std::allocator` becomes `allocator`.
    Leaving these as `_VSTD::allocator` would also be fine, but I decided
    that removing the qualification is more consistent with existing practice.

- Names that specifically need un-versioned `std::` qualification,
    or that I wasn't sure about. For example, I didn't touch any code in
    <atomic>, <math.h>, <new>, or any ext/ or experimental/ headers;
    and I didn't touch any instances of `std::type_info`.

In some deduction guides, we were accidentally using `class Alloc = typename std::allocator<T>`,
despite `std::allocator<T>`'s type-ness not being template-dependent.
Because `std::allocator` is a qualified name, this did parse as we intended;
but what we meant was simply `class Alloc = allocator<T>`.

Differential Revision: https://reviews.llvm.org/D92250
2020-12-01 22:13:39 -05:00
Arthur O'Dwyer 40950a44b9 [libc++] ADL-proof <thread>, and eliminate `using namespace chrono`.
Since we know exactly which identifiers we expect to find in `chrono`,
a using-directive seems like massive overkill. Remove the directives
and qualify the names as needed.

One subtle trick here: In two places I replaced `*__p` with `*__p.get()`.
The former is an unqualified call to `operator*` on a class type, which
triggers ADL and breaks the new test. The latter is a call to the
built-in `operator*` on pointers, which specifically
does NOT trigger ADL thanks to [over.match.oper]/1.

Differential Revision: https://reviews.llvm.org/D92243
2020-12-01 22:13:39 -05:00
Arthur O'Dwyer c3e15b3c1c [libc++] Support simply `std::iterator_traits` in the iterator_traits test.
This follows on from D56698. I copied this fix (simpler than D92142's)
from commit 66e6e37447.

Differential Revision: https://reviews.llvm.org/D92239
2020-12-01 22:13:39 -05:00
Louis Dionne 2671fccf03 [libc++] NFC: Remove unused macros in <__config> 2020-12-01 16:51:25 -05:00
Louis Dionne c30d5101f1 [libc++] Optimize the number of assignments in std::exclusive_scan
Reported in https://twitter.com/blelbach/status/1169807347142676480

Differential Revision: https://reviews.llvm.org/D67273
2020-12-01 12:49:45 -05:00
Zequan Wu 871f96eed3 [libcxx] remove checks for __STDCPP_THREADS__ as it is defined by compiler
Differential Revision: https://reviews.llvm.org/D92349
2020-11-30 16:36:47 -08:00
Harald van Dijk fba0b65f72
[libc++] hash<long double>: adjust for x86-64 ILP32
x86-64 ILP32 mode (x32) uses 32-bit size_t, so share the code with ix86 to zero out padding bits, not with x86-64 LP64 mode.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D91349
2020-11-29 13:52:28 +00:00
Mark de Wever ae5f792002 [libc++] Disable some tests using gcc 9.
This should fix running the libc++ unit tests.
They failed due to the changes introduced in 67c88e.
2020-11-28 20:08:09 +01:00
Mark de Wever 67c88e47bd [libc++] P1645 constexpr for <numeric>
Implements P1645: constexpr for <numeric> algorithms

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D90569
2020-11-28 17:02:54 +01:00
Arthur O'Dwyer 530c69e909 [libc++] s/constpexr/constexpr/ in some comments. NFC. 2020-11-27 18:53:08 -05:00
Vladimir Vereschaka 24b3c57ade [libc++] Support no libc++ namespace in the iterator test.
The 5f12f4ff90 commit suppress printing of
inline namespace names in diagnostics by default that breaks the libc++
iterator test, which expects __1 in the namespace.

This patch fixes the test by supporting a test case without __1 in the
namespace.

Differential Revision: https://reviews.llvm.org/D92142
2020-11-27 15:01:09 -08:00
Arthur O'Dwyer 03ee461276 [libc++] Consistently unparenthesize `numeric_limits<T>::max`. NFCI.
I think people were sometimes parenthesizing `(foo::max)()` out of
misplaced concern that an unparenthesized `foo::max()` would trip up
Windows' `max(a,b)` macro. However, this is not the case: `max(a,b)`
should be tripped up only by an unparenthesized call to `foo::max(a,b)`,
and in fact we already do `_VSTD::max(a,b)` all over the place anyway
without any guards.

However, in order to do it without guards, we must also
wrap the header in _LIBCPP_PUSH_MACROS, which <span> was not.

Differential Revision: https://reviews.llvm.org/D92240
2020-11-27 17:27:36 -05:00
zoecarver b2943765e7 [libc++] Use std::move in numeric algorithms (P0616R0).
This patch updates algorithms in <numeric> to use std::move
based on p0616r0. Moving values instead of copying them
creates huge speed improvements (see the paper for details).

Differential Revision: https://reviews.llvm.org/D61170
2020-11-27 11:09:44 -08:00
Louis Dionne 564628014c [libc++] Introduce an indirection to create threads in the test suite
We create threads using std::thread in various places in the test suite.
However, the usual std::thread constructor may not work on all platforms,
e.g. on platforms where passing a stack size is required to create a thread.

This commit introduces a simple indirection that makes it easier to tweak
how threads are created inside the test suite on various platforms. Note
that tests that are purposefully calling std::thread's constructor directly
(e.g. because that is what they're testing) were not modified.
2020-11-27 11:54:19 -05:00
Louis Dionne da1b50d7df [libc++] Formalize what configurations are covered by the ABI lists
By encoding ABI-affecting properties in the name of the ABI list, it
makes it clear when an ABI list test should or should not be available,
and what results we should expect.

Note that we clearly don't encode all ABI-affecting parameters in the
name right now -- I just ported over what we supported in the code that
was there previously. As we encounter configurations that we wish to
support but produce different ABI lists, we can add those to the ABI
identifier and start supporting them.

This commit also starts checking the ABI list in the CI jobs that run
a supported configuration. Eventually, all configurations should have
a generated ABI list and the test should even run implicitly as part of
the Lit test suite.

Differential Revision: https://reviews.llvm.org/D92194
2020-11-27 10:01:07 -05:00
Bruce Mitchener 527a7fdfbd [libc++] Replace several uses of 0 by nullptr
Differential Revision: https://reviews.llvm.org/D43159
2020-11-27 10:00:21 -05:00
Marek Kurdej b215198bb0 [libc++] [docs] Exclude helper files from Sphinx configuration to avoid generating empty pages. 2020-11-27 13:47:20 +01:00
Louis Dionne 76667c768e [libc++] Install missing package in the Dockerfile
python3-distutils is required to use `import distutils.spawn`, which is
required by the ABI list targets.
2020-11-26 15:14:48 -05:00
Louis Dionne 433d0a30c6 [libc++] Remove ABI lists for previous releases
We don't actually update the ABI lists at every release -- it's too much
work, since we'd technically have to do it even for minor releases.
Furthermore, I don't think anybody uses those (I certainly don't rely
on them for anything).

Instead, it is better to rely on the ABI list changelog and the canonical
ABI list that we always keep up to date. If one wants to know what symbols
were shipped in a specific release, that can be discovered easily using
Git, which is a superior tool than keeping textual copies of old versions.
2020-11-26 14:45:07 -05:00
Louis Dionne e9f7dc4f1c [libc++] Fix the Homebrew tap to install Buildkite on macOS hosts 2020-11-26 14:40:53 -05:00
Louis Dionne 3d7f19ff18 [libc++] Remove sysctl-based implementation of thread::hardware_concurrency()
Using sysctl requires including headers that are considered internal on
Linux, like <sys/sysctl.h> & friends. Instead, sysconf is defined by POSIX
(and we have a fallback for Windows), so all the systems we support should
be happy with just sysconf.

Differential Revision: https://reviews.llvm.org/D92135
2020-11-26 12:00:59 -05:00
Louis Dionne d7ca140c01 [libc++] Attempt to fix spurious modules-related failures in the CI
I'm not 100% sure what the issue actually is since I can't reproduce it
locally, however what I explain in the comment is my best attempt to
explain what's going on.

Differential Revision: https://reviews.llvm.org/D92131
2020-11-26 12:00:11 -05:00
Alex Richardson 0b20d0af3f [libc++] Fix two fr_FR locale tests on FreeBSD
FreeBSD's locale data uses the same U+2027 separator as Glibc 2.27 and newer.

Reviewed By: #libc, emaste, ldionne

Differential Revision: https://reviews.llvm.org/D91165
2020-11-26 16:09:51 +00:00
Marek Kurdej 5641b1dfdd [libc++] Mark a few more tests as unsupported on gcc-8/9.
This will fix remaining failures on gcc-9 buildbot: http://lab.llvm.org:8011/#/builders/101.
gcc-8 and gcc-9 do not support constexpr destructors nor constexpr allocation.

Fix gcc warnings: -Wconversion, -Wpragmas.
2020-11-26 12:40:50 +01:00
Mark de Wever 83d26603e0 [NFC][libc++] Mark LWG3296 as complete.
I recalled Marshall had already made this change. The change is
committed in e3f89a989a.
2020-11-26 10:39:44 +01:00
Marek Kurdej 8db009d273 [libc++] Fix gcc warning -Wsign-compare. 2020-11-26 10:20:09 +01:00
Marek Kurdej 841132efda [libc++] [P0966] [C++20] Fix bug PR45368 by correctly implementing P0966: string::reserve should not shrink.
This patch fixes the implementation as well as the tests that didn't actually test the wanted behaviour.
You'll find all the details in the bug report.
It adds as well deprecation warning for reserve() (without argument) and adds a test.

http://wg21.link/P0966R1
https://bugs.llvm.org/show_bug.cgi?id=45368
https://reviews.llvm.org/D54992

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D91778
2020-11-26 10:13:12 +01:00
Marek Kurdej a5f98b5419 [libc++] [docs] Migrate C++ status pages to RestructuredText (RST).
Currently, papers and issues are in separate .csv files (that is easier to update), but I can put them inline.Transforming current html tables into rst are done by the script (attached to the patch FYI but I'll remove it before committing).
I'll of course update RST files before committing to match any modifications that may happen in master branch.

This patch moves the status pages in www/ to RST format in docs/.

It also does some other minor changes: fix copyright year and broken comment end, adds substitutions for coherence (and add colors, but that can be removed easily).
It adds as well redirects from old to new status pages.

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D92076
2020-11-26 10:01:09 +01:00
Marek Kurdej 69d2567624 [libc++] [www] Fix HTML. NFC.
Needed for a future automatic update to RST.
2020-11-26 09:31:20 +01:00
Marek Kurdej dde0fcd7a7 [libc++] [libc++abi] Mark a few tests as unsupported/xfail on gcc-7/8/9.
This should make the builder http://lab.llvm.org:8011/#/builders/101/ happy.
It uses gcc-9 and not Tip-Of-Trunk as its name indicates BTW.
GCC-10 passes all these tests.

Fix gcc warnings: -Wsign-compare, -Wparentheses, -Wpragmas.

Reviewed By: ldionne, #libc, #libc_abi

Differential Revision: https://reviews.llvm.org/D92099
2020-11-26 08:59:52 +01:00
Louis Dionne e5cc7baf67 [libc++] NFC: Reindent non-lockfree-atomics feature 2020-11-25 16:14:34 -05:00
Louis Dionne a78aaa1ad5 [libc++] Factor out common logic for calling aligned allocation
There were a couple of places where we needed to call the underlying
platform's aligned allocation/deallocation function. Instead of having
the same logic all over the place, extract the logic into a pair of
helper functions __libcpp_aligned_alloc and __libcpp_aligned_free.

The code in libcxxabi/src/fallback_malloc.cpp looks like it could be
simplified after this change -- I purposefully did not simplify it
further to keep this change as straightforward as possible, since it
is touching very important parts of the library.

Also, the changes in libcxx/src/new.cpp and libcxxabi/src/stdlib_new_delete.cpp
are basically the same -- I just kept both source files in sync.

The underlying reason for this refactoring is to make it easier to support
platforms that provide aligned allocation through C11's aligned_alloc
function instead of posix_memalign. After this change, we'll only have
to add support for that in a single place.

Differential Revision: https://reviews.llvm.org/D91379
2020-11-25 15:44:50 -05:00
Arthur O'Dwyer bbf8a9ca3f [libc++] ADL-proof <variant> by adding _VSTD:: qualification on calls.
Differential Revision: https://reviews.llvm.org/D92036
2020-11-25 09:19:37 -05:00
Mark de Wever ecabb39ca1 Revert "[libc++] P1645 constexpr for <numeric>"
This reverts commit eb9b063539.

The commit fails to build on build bots using LLVM 8.
2020-11-25 13:46:08 +01:00
Mark de Wever eb9b063539 [libc++] P1645 constexpr for <numeric>
Implements P1645: constexpr for <numeric> algorithms

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D90569
2020-11-25 13:19:32 +01:00
Marek Kurdej 9c97e4ef45 [libc++] [P0482] [C++20] Implement missing bits for atomic
Added: ATOMIC_CHAR8_T_LOCK_FREE, atomic<char8_t>, atomic_char8_t.
http://wg21.link/P0482

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D91706
2020-11-24 21:07:57 +01:00
Louis Dionne 0ec73a61cc [libc++] NFC: Fix confusing indentation in <numeric> 2020-11-24 12:30:31 -05:00
Mark de Wever 1a036e9cc8 [libcxx] Implement P1956 rename low-level bit functions
Implements P1956: On the names of low-level bit manipulation functions.

Users may use older versions of libc++ or other standard libraries with the old names. In order to keep compatibility the old functions are kept, but marked as deprecated.

The patch also adds a new config macro `_LIBCPP_DEPRECATED_MSG`. Do you prefer a this is a separate patch?

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D90551
2020-11-24 17:37:06 +01:00
Arthur O'Dwyer ee95c7020c [libc++] Remove _LIBCPP_CONSTEXPR_AFTER_CXX17_WITH_IS_CONSTANT_EVALUATED.
Zoe Carver says: "We decided that libc++ only supports C++20 constexpr algorithms
when `is_constant_evaluated` is also supported. Here's a link to the discussion."
https://reviews.llvm.org/D65721#inline-735682

Remove _LIBCPP_HAS_NO_BUILTIN_IS_CONSTANT_EVALUATED from tests, too.
See Louis's 5911e6a885 if needed to fix bots.
I've applied `UNSUPPORTED: clang-8` preemptively to the altered tests;
I don't know for sure that this was needed, because no clang-8 buildbots
are triggered on pull requests.
2020-11-24 11:04:21 -05:00
Marek Kurdej 605be65c8b [libc++] [www] Fix HTML. NFC.
Needed for a future automatic update to RST.
2020-11-24 11:06:08 +01:00
zoecarver 0a20660c8f [libcxx] Resolve LWG 2724 protected -> private.
Fixes LWG issue 2724: "The protected virtual member functions of memory_resource should be private."

Differential Revision: https://reviews.llvm.org/D66615
2020-11-23 14:27:22 -08:00
Marek Kurdej de212de22e [libc++] [www] Mark P0482 as "In Progress", as some parts of it are already implemented. 2020-11-23 09:10:20 +01:00
Marek Kurdej 3b625060fc [libc++] [libc++abi] Use C++20 standard.
This change is needed to use char8_t when building libc++.
Using the same standard in libc++abi for coherence.

See https://reviews.llvm.org/D91517.

Reviewed By: ldionne, #libc, #libc_abi

Differential Revision: https://reviews.llvm.org/D91691
2020-11-22 15:57:25 +01:00
Arthur O'Dwyer 6e965df605 Revert "Revert "[libc++] ADL-proof <vector> by adding _VSTD:: qualification on calls.""
This reverts commit 620adacf87.

Fix: unsupport C++03 for the new test, define helpers before __swap_allocator

(1) Add _VSTD:: qualification to __swap_allocator.

(2) Add _VSTD:: qualification consistently to __to_address.

(3) Add some more missing _VSTD:: to <vector>, with a regression test.
This part is cleanup after d9a4f936d0.

Note that a vector whose allocator actually runs afoul of any of these ADL calls will
likely also run afoul of simple things like `v1 == v2` (which is also an ADL call).
But, still, libc++ should be consistent in qualifying function calls wherever possible.

Relevant blog post: https://quuxplusone.github.io/blog/2019/09/26/uglification-doesnt-stop-adl/

Differential Revision: https://reviews.llvm.org/D91708
2020-11-20 20:59:18 -05:00
Zbigniew Sarbinowski 2c7e24c4b6 Guard init_priority attribute within libc++
Not all platforms support priority attribute. I'm moving conditional definition of this attribute to `include/__config`.

Reviewed By: #libc, aaron.ballman

Differential Revision: https://reviews.llvm.org/D91565
2020-11-20 15:53:26 -05:00
Louis Dionne 389ef79a07 [libc++] Add documentation for setting up new CI jobs 2020-11-19 14:42:02 -05:00
Louis Dionne 5911e6a885 [libc++] Mark a few tests as unsupported on older Clangs to fix bots 2020-11-19 13:37:07 -05:00
Mikhail Goncharov 620adacf87 Revert "[libc++] ADL-proof <vector> by adding _VSTD:: qualification on calls."
This reverts commit 40267cc989.

Build fails, e.g. http://lab.llvm.org:8011/#/builders/23/builds/108
2020-11-19 15:36:49 +01:00
Arthur O'Dwyer 40267cc989 [libc++] ADL-proof <vector> by adding _VSTD:: qualification on calls.
(1) Add _VSTD:: qualification to __swap_allocator.

(2) Add _VSTD:: qualification consistently to __to_address.

(3) Add some more missing _VSTD:: to <vector>, with a regression test.
This part is cleanup after d9a4f936d0.

Note that a vector whose allocator actually runs afoul of any of these ADL calls will
likely also run afoul of simple things like `v1 == v2` (which is also an ADL call).
But, still, libc++ should be consistent in qualifying function calls wherever possible.

Relevant blog post: https://quuxplusone.github.io/blog/2019/09/26/uglification-doesnt-stop-adl/

Differential Revision: https://reviews.llvm.org/D91708
2020-11-19 09:19:16 -05:00
Louis Dionne be00e8893f [libc++] Clarify how we pick the typeinfo comparison
This commit makes it clear that the typeinfo comparison implementation
is automatically selected by default, and that the CMake option only
overrides the value. This has been a source of confusion and bugs ever
since we've introduced complexity in that area, so I'm trying to simplify
it while still allowing for some control on the implementation.

Differential Revision: https://reviews.llvm.org/D91574
2020-11-18 16:58:45 -05:00
Xiang Xiao f0785c1f7a [libcxx] Port to NuttX (https://nuttx.apache.org) RTOS
Since NuttX conform to POSIX standard, the code need to add is very simple.

Differential Revision: https://reviews.llvm.org/D88718
2020-11-18 16:20:56 -05:00
Mark de Wever 3abaf6cde7 [libc++] Implements multiline regex support.
This resolves LWG2503.
2020-11-18 18:17:36 +01:00
Martin Storsjö 83a03867da [libcxx] Add missing _LIBCPP_FUNC_VIS on a few win32 locale functions
These functions are called directly from the public installed
headers, and thus need to be exported in DLL builds, just like
some other functions in the same header (e.g. snprintf_l).

This fixes e.g. test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp
in mingw configurations.

Differential Revision: https://reviews.llvm.org/D91328
2020-11-18 11:04:55 +02:00
Eric Fiselier 9c09757bca [libc++] Revert switch-based std::variant implementation again.
These changes cause substantial binary size increases for non-opt builds.
For example, the visit.pass.cpp test grows from 20k to 420k.

Further work will be done to re-land this patch without the size increases,
but that work is proving too tricky to fix forward.

This patch fully reverts:

* 35d2269111

And it partially reverts:

* bb43a0cd4a

The latter of which added XFAIL's to new variant tests
because the new implementation needlessly makes non-throwing code
paths in variant invoke throwing code.

This means the reverted change also breaks source backwards compat
with code compiled on OS X targeting older system dylibs. There is no
need for this to be the case. We should fix it before recommitting.

Reviewed as:
https://reviews.llvm.org/D91662
2020-11-17 23:09:31 -05:00
Louis Dionne 48138e7338 [libc++] Do not error out when we don't know the file format
Erroring out prevents the library from working with other file formats
(e.g. in embedded). Since that error does not guard us from doing something
incorrect, it seems fine to just remove it.
2020-11-17 13:18:51 -05:00
Louis Dionne 121f27f3ac [libc++] Only include_next <wctype.h> if it exists
This allows building on platforms that don't provide that header.
2020-11-17 13:14:36 -05:00
Louis Dionne 7ad8e19958 [libc++] Move the GDB pretty printer tests to the DSL
Also, enable them whenever we detect that gdb is available. Previously,
these tests would basically never run because they relied on a CMake
configuration option that defaulted to OFF.

Differential Revision: https://reviews.llvm.org/D91434
2020-11-16 16:16:39 -05:00
Louis Dionne f1cf6b47e4 [libc++] Remove transitional #error message
It's been more than 4 years now, so anyone that was defining
_LIBCPP_TRIVIAL_PAIR_COPY_CTOR has had ample time to see that
error and fix their code.
2020-11-16 13:36:16 -05:00
Marek Kurdej d2acf22927 [gcc] Fix -Wempty-body warning. NFC. 2020-11-15 16:17:52 +01:00
Louis Dionne e56eea26ca [libc++] Install GDB in the Docker images
This will allow running the GDB pretty printer tests.
2020-11-13 11:57:54 -05:00
Louis Dionne 2728293bbc [libc++] Only check for GCC's empty string storage on macOS and iOS
We don't need to do that on other Apple platforms, since they never
shipped libstdc++. I also added a comment extracted from the original
commit by Howard Hinnant (e115af2777).

Differential Revision: https://reviews.llvm.org/D91359
2020-11-13 10:48:38 -05:00
Zbigniew Sarbinowski 6a8099e0f6 [libc++] Port the time functions to z/OS
This patch adds a shim for missing time functions on z/OS, and adds a
layer of indirection to account for differences in the timespec struct
on different systems.

This was originally committed as 173b51169b and reverted in 777ca48c9f
because the original commit also checked-in unrelated changes.

Differential Revision: https://reviews.llvm.org/D87940
2020-11-13 10:47:57 -05:00
Zbigniew Sarbinowski aa8a5b800d [SystemZ][ZOS] libcxx - no posix memalign
The unavailability of posix_memalign on z/OS forces us to define _LIBCPP_HAS_NO_LIBRARY_ALIGNED_ALLOCATION'. The use of posix_memalign is being used in libcxx/src/new.cpp.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D90178
2020-11-12 14:47:58 -05:00
Louis Dionne 557e268425 [libc++] NFC: Remove symbol from ABI list changelog that was never added
The `posix_memalign@GLIBC_2.2.5` symbol can't have been added by r284206,
because it doesn't show up in the corresponding ABI list. It's also not
defined in libc++, so that wouldn't make sense. It must have made it into
that comment by mistake.
2020-11-12 14:35:56 -05:00
Louis Dionne 997d41cdec [libc++] Instantiate additional <iostream> members in the dylib
This commit adds new explicit instantiations for some classes in <iostream>
in the library. This is done after noticing that many programs that use
streams end up containing weak definitions of these classes, which has a
negative impact on both code size and load times (due to the need to
resolve weak symbols at load time). Note that we are just adding the
additional explicit instantiations for the `char` specializations, since
the `wchar_t` specializations are not used as often, and as a result there
wouldn't be a clear benefit.

This change is not an ABI break, since we are just adding additional
symbols.

Differential Revision: https://reviews.llvm.org/D90677
2020-11-12 13:52:47 -05:00
Louis Dionne 777ca48c9f Revert "[SystemZ][ZOS] Porting the time functions within libc++ to z/OS"
This reverts commit 173b51169b. That commit was applied incorrectly,
and undid previous changes. That was clearly not intended.
2020-11-12 13:36:18 -05:00
Zbigniew Sarbinowski 173b51169b [SystemZ][ZOS] Porting the time functions within libc++ to z/OS
This patch is one part of many steps required to build libc++ and libc++abi libraries on z/OS.  This particular deals with time related functions and consists of the following 3 parts.

1) Initialization of :timeval within libc++ library need to be adjusted to work on z/OS.
The following is z/OS definition from time.h which includes additional aggregate member.
typedef signed int suseconds_t;
struct timeval {
time_t tv_sec;
char tv_usec_pad[4];
suseconds_t tv_usec;
};

In contracts the following is definition from time.h on Linux.

typedef long int __suseconds_t;
struct timeval
{
__time_t tv_sec;
__suseconds_t tv_usec;
};

2) In addition, retrieving ::timespec within libc++ library needs to be adjusted to compensate the difference of some of the members of ::stat depending of the target host.
Here are the 2 members in conflict on z/OS extracted from stat.h.
struct stat {
...
time_t st_atime;
time_t st_mtime;
...
};
In contract here is Linux equivalent from stat.h.
struct stat
{
...
struct timespec st_atim;
struct timespec st_mtim;
...
};

3) On Linux both members are of type timespec whereas on z/OS an object of type timespec need to be constructed first before retrieving it within libc++ library.

The libc++ header file __threading_support calls nanosleep, which is not available on z/OS.
The equivalent functionality will be implemented by using both sleep() and usleep().

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D87940
2020-11-12 11:29:13 -05:00
Marek Kurdej e331dfea70 [libc++] [P0340] [C++20] Update status page. NFC.
This was implemented in 410b650e674496e61506fa88f3026759b8759d0f:
"Implement P0340R3: Make 'underlying_type' SFINAE-friendly. Reviewed as https://reviews.llvm.org/D63574

llvm-svn: 364094"
2020-11-12 09:32:29 +01:00
Ruslan Arutyunyan e5ec94a1a0 [libc++] Implement P0919R3: heterogenous lookup for unordered containers
Implement heterogenous lookup for unordered containers, including the
refinement from P1690R1.

Differential Revision: https://reviews.llvm.org/D87171
2020-11-11 17:44:42 -05:00
Louis Dionne 69ca17a92c [libc++] NFC: Simplify incude of <cstdlib>
We include <exception>, which includes <cstdlib> unconditionally anyway.
2020-11-11 17:04:32 -05:00
Louis Dionne d4a1e03c5f [libc++] NFC: Synchronize libc++abi and libc++ new definitions
Some changes were made to the libc++abi new/delete definitions, but
they were not copied back to the libc++ definition. It sucks that we
have this duplication, but for now at least let's keep them in sync.
2020-11-11 16:35:25 -05:00
Xiang Xiao 20acf6d588 [libcxx] Check _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE first in __locale
This is consistent with what's done in locale.cpp, and it ensures that
we get the default rune table whenever _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
is defined, regardless of the actual platform.

Differential Revision: https://reviews.llvm.org/D91074
2020-11-11 15:32:59 -05:00
zoecarver 31dfaff3b3 [libc++] Change requirements on linear_congruential_engine.
This patch changes how linear_congruential_engine picks its randomization
algorithm. It adds two restrictions, `_OverflowOK` and `_SchrageOK`.
`_OverflowOK` means that m is a power of two so using the classic
`(a * x + c) % m` will create a meaningless overflow. The second checks
that Schrage's algorithm will produce results that are in bounds of min
and max. This patch fixes https://llvm.org/PR27839.

Differential Revision: D65041
2020-11-10 18:23:22 -08:00
Louis Dionne 02af11094f [libc++] NFC: Add helper methods to simplify __shared_ptr_emplace
The previous implementation was really difficult to follow, especially
with the get() method sharing the same name as std::unique_ptr::get().
2020-11-10 12:49:19 -05:00
Muiez Ahmed e72e785d47 [SystemZ][z/OS] Enable POSIX_l functions for z/OS
The aim of this patch is to enable POSIX _l functions for z/OS. In particular, the functions are provided with libc++ and this patch resorts to the fallback functions. Nonetheless, the functions are being added so the implementation of the ctype<> member functions can call them. The following changes were needed to allow for a successful build when using the libc++ library for z/OS.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D90319
2020-11-10 09:57:11 -05:00
Martin Storsjö 539ce1d288 [libcxx] [test] Simplify the fs helper header for posix cases. NFC.
Differential Revision: https://reviews.llvm.org/D91073
2020-11-10 10:39:15 +02:00
Martin Storsjö c41bda7f5f [libcxx] [test] Call create_directory_symlink where relevant
Differential Revision: https://reviews.llvm.org/D91072
2020-11-10 10:39:15 +02:00
Martin Storsjö 8f5f6ee27e [libcxx] [test] Make a separate create_directory_symlink helper
This more closely mirrors the public API, instead of using an
obscure bool parameter.

Differential Revision: https://reviews.llvm.org/D91071
2020-11-10 10:39:15 +02:00
Sam Clegg e84c3b2fc8 [libc++] Remove emscripten handling from exception_fallback.ipp
Emscripten doesn't use this file (at least not anymore), it uses
exception_libcxxabi.ipp since _LIBCPPABI_VERSION is defined.

Differential Revision: https://reviews.llvm.org/D91041
2020-11-09 16:09:54 -08:00
Louis Dionne 8d51969bd4 [runtimes] Avoid overwriting the rpath unconditionally
When building the runtimes, it's very important not to add rpaths unless
the user explicitly asks for them (the standard way being CMAKE_INSTALL_RPATH),
or to change the install name dir unless the user requests it (via
CMAKE_INSTALL_NAME_DIR).

llvm_setup_rpath() would override the install_name_dir of the runtimes
even if CMAKE_INSTALL_NAME_DIR was specified to something, which is wrong
and in fact even "dangerous" for the runtimes.

This issue was discovered when trying to build libc++ and libc++abi as
system libraries for Apple, where we set the install name dir to /usr/lib
explicitly. llvm_setup_rpath() would cause libc++ to have the wrong install
name dir, and for basically everything on the system to fail to load.
This was discovered just now because we previously used something closer
to a standalone build, where llvm_setup_rpath() wouldn't exist, and hence
not be used.

This is a revert of the following commits:

  libunwind: 3a667b9bd8
  libc++abi: 4877063e19
  libc++: 88434fe05f

Those added llvm_setup_rpath() for consistency, so it seems reasonable
to revert.

Differential Revision: https://reviews.llvm.org/D91099
2020-11-09 16:56:03 -05:00
Louis Dionne c1887e3f15 Revert "Allow running back-deployment testing against libc++abi"
This reverts commit 4d79ef814a, which broke a few build bots.
I'm reverting until I have time to investigate.
2020-11-06 17:26:42 -05:00
Louis Dionne 1d53b55e18 [libc++] Try fixing the oss-fuzz build
See https://github.com/google/oss-fuzz/issues/4586.
2020-11-06 10:06:44 -05:00
Louis Dionne 4d79ef814a Allow running back-deployment testing against libc++abi
Summary:
Before this patch, we could only link against the back-deployment libc++abi
dylib. This patch allows linking against the just-built libc++abi, but
running against the back-deployment one -- just like we do for libc++.

Also, add XFAIL markup to flag expected errors.
2020-11-06 08:12:46 -05:00
Louis Dionne 75b6726b57 [libc++] Also allow customizing the build directory when running CI 2020-11-05 19:10:08 -05:00
Louis Dionne 3790e17f46 [libc++] Allow customizing a few paths when running build bots
This allows reusing run-buildbot for downstream testing as well.
2020-11-05 19:02:32 -05:00
Louis Dionne bb43a0cd4a [libc++] Add a Buildkite job that tests back-deployment on Apple
The current way we test this is pretty cheap, i.e. we download previously
released macOS dylibs and run against that. Ideally, we would require a
full host running the appropriate version of macOS, and we'd execute the
tests using SSH on that host. But since we don't have such hosts available
easily for now, this is better than nothing.

At the same time, also fix some tests that were failing when back
deploying.

Differential Revision: https://reviews.llvm.org/D90869
2020-11-05 18:26:08 -05:00
Louis Dionne f7e4f041d6 [libc++] Add a CI job to build the documentation
At the same time, fix an issue that broke the documentation since 2eadbc8614.
2020-11-05 15:33:09 -05:00
Louis Dionne 738d981eb6 [libc++] Update the CI Dockerfile
Remove Phabricator, which isn't needed anymore since we don't report
the job results ourselves. Also, install python3-sphinx instead of
sphinx-doc, since the latter doesn't provide the sphinx-build binary.
2020-11-05 15:33:09 -05:00
Louis Dionne 2eadbc8614 [libc++] Rework the whole availability markup implementation
Currently, vendor-specific availability markup is enabled by default.
This means that even when building against trunk libc++, the headers
will by default prevent you from using some features that were not
released in the dylib on your target platform. This is a source of
frustration since people building libc++ from sources are usually not
trying to use some vendor's released dylib.

For that reason, I've been thinking for a long time that availability
annotations should be off by default, which is the primary change that
this commit enables.

In addition, it reworks the implementation to make it easier for new
vendors to add availability annotations for their platform, and it
refreshes the documentation to reflect the current state of the codebase.

Finally, a CMake configuration option is added to control whether
availability annotations should be turned on for the flavor of libc++
being created. The intent is for vendors like Apple to turn it on, and
for the upstream libc++ to leave it off (the default).

Differential Revision: https://reviews.llvm.org/D90843
2020-11-05 12:28:52 -05:00
Louis Dionne 0e61d02c05 [libc++] Correct XFAILs for the C++20 Synchronization Library
Technically, these tests don't only fail against macosx10.9 to 10.15,
but really against any released macOS yet.
2020-11-05 08:45:57 -05:00
Arthur O'Dwyer 418de7d5d8 Fix UB in one libcxx test, when deleting D through a pointer to B.
This undefined behavior was found by applying Lénárd Szolnoki's proposal
to disable implicit conversion of default_delete<D> to default_delete<B>.

The offending part of the test is circa line 243.

The wording that makes it undefined behavior is http://eel.is/c++draft/expr.delete#3 .

Differential Revision: https://reviews.llvm.org/D90536
2020-11-04 17:34:05 -05:00
Louis Dionne 8e01749bb1 [libc++] Remove stray setting of use_system_cxx_lib left behind 2020-11-04 15:01:59 -05:00
Louis Dionne 70eb30cc81 [libc++] Move availability-related Lit configuration to the DSL
The implementation is not really satisfactory, but it's better than
being in the legacy config, which causes other issues.
2020-11-04 14:56:08 -05:00
Steven Wan 09f2c92e5b Add info about the cherry-picked commit and contributor 2020-11-04 14:23:27 -05:00
Steven Wan 296c2f31f0 [PowerPC] Rename mftbl to mftb
`mftb` and `mftbl` are equivalent, there is no need to have two names for doing the same thing, rename `mftbl` to only have `mftb`.

Differential Revision: https://reviews.llvm.org/D89506
2020-11-04 14:23:27 -05:00
Louis Dionne 0df0d0fe2d [libc++] NFC: Remove trailing whitespace 2020-11-04 14:08:06 -05:00
Louis Dionne 6706342f48 [libc++] Remove the ability to not install the support headers
Those are part of the library, and shipping them just adds a tiny bit of
size to the distribution. This was originally added in b422ecc7de to
make it possible to match the Makefile build, which doesn't exist anymore.

The upside is build system simplification.
2020-11-04 11:45:34 -05:00
Louis Dionne 9d58dab6f6 [libc++] Split off part of a test that require signals into a separate test
This will allow running the basic test on all platforms, and the part that
requires signals on platforms that support them only.
2020-11-04 11:20:47 -05:00
Louis Dionne 2dec36e532 [libc++] NFCI: Refactor chrono.cpp to make it easier to support new platforms
Also simplify a few conditionals along the way for readability.
2020-11-04 10:23:36 -05:00
Louis Dionne bbd15062d2 [libc++] Remove test that is irrelevant since f1a96de1bc
We don't want to give the impression that we allow running arbitrary
shell commands under %{exec}, which isn't the case.
2020-11-04 08:47:48 -05:00
Louis Dionne f1a96de1bc [libc++] Don't run tests in a shell in the default executor 2020-11-04 08:29:05 -05:00
zoecarver e2b6987204 [libc++][NFC] Mark LWG issue 2899 as not complete.
Commit 59e26308e6 accidentally
marked this LWG issue as complete but it has not yet been
implemented. D66262 fixes this issue.
2020-11-03 13:35:12 -08:00
Louis Dionne 8e5156f6b0 [libc++] Harden tests against executors not running tests in a shell
Some executors do not run the tests in a shell, and so assuming that
they can understand shell builtins is wrong. Instead, call Bash
directly to do what we need to do.

This still requires the executor to be able to run Bash, but at least
it does not require it to interpret command lines in the Bash language.
2020-11-03 16:03:20 -05:00
Louis Dionne 5369d8cca7 [libc++] Remove support for .run.fail.cpp tests
Unfortunately, executing these tests correctly on platforms that do not
support a shell is very challenging. Since the executor can't just negate
the result of the command, we'd have to ship a portable program capable
of running the actual test executable, and negating its result.

Doing this portably is challenging. Since we do not currently have strong
use cases for tests that fail at runtime (we effectively have no tests
using that capability right now), it is difficult to justify making them
work portably. Instead, it makes more sense to remove this feature until
we can implement it properly (i.e. without requiring shell support).
2020-11-03 15:40:24 -05:00
Louis Dionne d1217be43f [libc++] NFC: Simplify how we run config tests
We can use the convenience substitutions provided by the format instead
of bootstrapping our own.
2020-11-03 14:59:41 -05:00
Louis Dionne d9a4f936d0 [libc++] Move <memory> helpers outside of std::allocator_traits
They don't really belong as members of allocator_traits.
2020-11-03 12:27:26 -05:00
Martin Storsjö 1127ef789c [libcxx] Error out if __libcpp_mbsrtowcs_l fails in __time_get_storage
If __libcpp_mbsrtowcs_l outputs zero wchar_t's for week days or
month names (due to errors in the locale function setup), these are
matched all the time in __time_get_storage::__analyze, ending up in
an infinite loop, allocating more memory until killed.

Differential Revision: https://reviews.llvm.org/D69553
2020-11-03 17:15:05 +02:00
Martin Storsjö 8a73aa8c4c [libcxx] [libcxxabi] Set flags for visibility when statically linking libcxxabi into libcxx for windows
Previously, these had to be set manually when building each of the
projects standalone, in order to get proper symbol visibility when
combining the two libraries.

Differential Revision: https://reviews.llvm.org/D90021
2020-11-03 17:13:48 +02:00
Martin Storsjö 529ba612b0 [libcxx] [test] Use error_code::default_error_condition to check errors against the expected codes
error_code returned from functions might not be of the generic category,
but of the system category, which can have different error code values.
Use default_error_condition() to remap errors to the generic category
where possible, to allow comparing them to the expected values.

Use the ErrorIs() helper instead of a direct comparison against
an excpected value.

Differential Revision: https://reviews.llvm.org/D90602
2020-11-03 09:32:52 +02:00
Martin Storsjö 08b4cc5e0d [libcxx] Avoid double frees of file descriptors in the fallback ifstream/ofstream codepath
So far, most actual uses of libc++ std::filesystem probably use
the sendfile or fcopyfile implementations.

Differential Revision: https://reviews.llvm.org/D90601
2020-11-03 09:32:52 +02:00
Martin Storsjö 11987248c8 [libcxx] [test] Create symlink_to_dir as the right kind, as a directory symlink
This was missed in 5c39eebc12.

Differential Revision: https://reviews.llvm.org/D90600
2020-11-03 09:32:52 +02:00
Martin Storsjö 22e5ee0eef [libcxx] [test] Avoid an unused variable in non-libcpp cases in path.append
Differential Revision: https://reviews.llvm.org/D89947
2020-11-03 09:32:52 +02:00
Martin Storsjö 321f696920 [libcxx] [test] Fix the fs.op.absolute test to cope with windows paths
Prepend the root path on the already_absolute testcase, and construct
a path ending with the preferred separator for the test reference for
"foo/".

Differential Revision: https://reviews.llvm.org/D89944
2020-11-03 09:32:52 +02:00
Louis Dionne 5a829ef6ad [libc++] Fix invalid parsing of ints in a <random> test
The strings were concatenated together without adding spaces between
numbers, which lead to numbers that wouldn't fit in an unsigned int.

Thanks to Casey Carter for the find.
2020-11-02 19:20:59 -05:00
Louis Dionne d6e2bac195 [libc++] Migrate warning flags to the DSL
This makes us closer to running the test suite on platforms where the
legacy test suite configuration doesn't work.

One notable change after this commit is that the tests will be run with
warnings enabled on GCC too, which wasn't the case before. However,
previous commits should have tweaked the test suite to make sure it
passes with warnings enabled on GCC.

Note that warnings can still be disabled with `--param enable_warnings=False`,
as before.

Differential Revision: https://reviews.llvm.org/D90432
2020-11-02 12:25:05 -05:00
Louis Dionne 6b2de7c53a [libc++][CI] Allow retries in case an agent is lost
We see this fairly often on our Linux bots, which appear to be killed
by GCE from time to time.
2020-11-02 11:58:45 -05:00
Louis Dionne 2ca4406de8 [libc++] NFC: Re-generate the ABI lists with the new script
The new script keeps the results sorted, which is why the ABI lists appear
to have changed so much. However, this commit makes no actual ABI change.
2020-11-02 11:36:35 -05:00
Louis Dionne b128373eb8 [libc++] Make it easier to re-generate the ABI lists
Instead of having to remember the command-line to use every time, this
commit adds a CMake target to generate the ABI list in the current
configuration, if it is supported.

As a fly-by change, remove scripts that are now unused (sym_match.py
and sym_extract.py).
2020-11-02 11:36:35 -05:00
Louis Dionne 1b2fa6e46e [libc++/libc++abi] Use Python3_EXECUTABLE consistently to run utilities 2020-11-02 11:07:31 -05:00
Louis Dionne c6eaa14e11 [libc++] Split off iostreams explicit instantiations into its own source file
This makes it cleaner to add more instantiations without cluttering the
actual implementation of ios.
2020-11-02 10:36:34 -05:00
Louis Dionne ca62b8673b [libc++] NFC: Remove warning about non-void function returning void 2020-11-02 08:25:44 -05:00
Nico Weber 8954fd436c [libcxx] Fix regression where `ninja all` doesn't copy libcxx headers
Before 6db314e86b, when running cmake with clang, libcxx, and
compiler-rt enabled, building `ninja all` would run the
generate-cxx-headers target, due to the sanitizers depending on it.

After 6db314e86b, if LIBCXX_ENABLE_SHARED and LIBCXX_ENABLE_STATIC
and LIBCXX_INCLUDE_TESTS and LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY are
disabled (https://reviews.llvm.org/D82702#2153627), `ninja all`
no longer copies the libcxx headers, which means clang can't compile
programs like `#include <string>` on macOS.

Explicitly add the copy target to the all target to restore the old
behavior.
2020-11-01 21:34:51 -05:00
Louis Dionne 81b6aa0e27 [libc++] Fix tests failing with Clang after removing GCC warnings 2020-10-30 14:56:12 -04:00
Louis Dionne 4dfe014a12 [libc++] Add -Wno-sized-deallocation to avoid spurious GCC warnings
GCC tries to be nice and tell us that we probably want to also implement
sized deallocation functions when we override the normal ones. However,
we know what we're doing in the test suite and don't want to override
them.
2020-10-30 12:51:07 -04:00
Louis Dionne c479e0c994 [libc++] NFC: Fix several GCC warnings in the test suite
- Several -Wshadow warnings
- Several places where we did not initialize our base class explicitly
- Unused variable warnings
- Some tautological comparisons
- Some places where we'd pass null arguments to functions expecting
  non-null (in unevaluated contexts)
- Add a few pragmas to turn off spurious warnings
- Fix warnings about declarations that don't declare anything
- Properly disable deprecation warnings in ext/ tests (the pragmas we
  were using didn't work on GCC)
- Disable include_as_c.sh.cpp because GCC complains about C++ flags
  when compiling as C. I couldn't find a way to fix this one properly,
  so I'm disabling the test. This isn't great, but at least we'll be
  able to enable warnings in the whole test suite with GCC.
2020-10-30 12:48:05 -04:00
Louis Dionne d085697013 [libc++] Add a new concept of ConfigAction, and use it in the DSL
This will allow adding bare compiler flags through the new
configuration DSL. Previously, this would have required adding
a Lit feature for each such flag.

Differential Revision: https://reviews.llvm.org/D90429
2020-10-30 09:27:15 -04:00
Louis Dionne bffdc241a6 [libc++] Minor cleanup in the test suite 2020-10-29 13:58:02 -04:00
Louis Dionne bd8884f05e [libc++] Remove additional uses of std::rand() missed by 63aeadb484 2020-10-29 11:11:29 -04:00
Marek Kurdej 6648414b2b [libcxx] [docs] [NFC] Fix typo. 2020-10-29 14:39:09 +01:00
Daniel Kiss fd1c064845 [libcxx] Add targets to available features.
This patch add the target-* (x86_64-*) as used elsewhere in llvm.

Reviewed By: #libc, #libc_abi, ldionne

Differential Revision: https://reviews.llvm.org/D88027
2020-10-29 14:04:11 +01:00
Michael Park 35d2269111 [libc++] Re-apply the switch-based std::variant implementation
This commit is a mass re-application of the following commits:

  7d15ece79c
  e0ec7a0206
  02197f7e50
  a175a96517

Those were temporarily reverted in 057028ed39, and never re-applied.
Re-committed by @ldionne (author edited for credit).

Differential Revision: https://reviews.llvm.org/D90168
2020-10-28 17:09:11 -04:00
YAMAMOTO Takashi acd7be74ca [libc++] Fix a few warnings
Found during a NuttX porting effort.
But these changes are not directly relevant to NuttX.

Differential Revision: https://reviews.llvm.org/D90139
2020-10-28 15:41:10 -04:00
Louis Dionne 63aeadb484 [libc++] Refactor tests to remove uses of std::rand()
This allows running these tests on systems that do not support std::rand().
2020-10-28 15:22:51 -04:00
Louis Dionne 91336a0c61 [libc++] Move the #error message for no localization to <locale.h>
<locale.h> is lower level than <__locale>, so that's where we want the
error to live for systems that don't provide localization support.
2020-10-28 09:49:37 -04:00
Louis Dionne 201184b30b [libc++] Remove <clocale> from some system_error tests
The explicit call to `std::setlocale(LC_ALL, "C")` isn't required, since
the Standard already says the equivalent of this call is performed on
program startup.
2020-10-28 09:49:36 -04:00
Martin Storsjö 70bba9ef35 [libcxx] Don't truncate intermediates to wchar_t when widening
On windows, wchar_t is 16 bit, while we might be widening chars to
char32_t.

This cast had been present since the initial commit, and removing it
doesn't seem to make any tests fail.

Differential Revision: https://reviews.llvm.org/D90228
2020-10-27 23:58:27 +02:00
Louis Dionne 2089e762d0 [libc++] Try to fix cross-loading of lit.local.cfg on Windows
On windows, the previous path replacement using forward slashes wouldn't
work, and so we'd end up including the same file again. We would do that
until we'd hit the recursion limit of the Python interpreter.

Instead, use `os.path` to properly replace without assuming a specific
path separator.
2020-10-27 16:28:29 -04:00
Louis Dionne c56bbb3961 [libc++] Make sure we include a header when checking compiler macros
Otherwise, it's possible for some __config_site macros not to be
picked up.
2020-10-27 15:58:43 -04:00
Louis Dionne 88ffc72717 [libc++] Add a libc++ configuration that does not support localization
When porting libc++ to embedded systems, it can be useful to drop support
for localization, which these systems don't implement or care about.

Differential Revision: https://reviews.llvm.org/D90072
2020-10-27 14:56:30 -04:00
Martin Storsjö 0be27302d4 [libcxx] Fix typo in spelling of 'sentinel'. NFC.
Differential Revision: https://reviews.llvm.org/D90220
2020-10-27 20:38:32 +02:00
Louis Dionne cfa1376a01 [libc++] Get rid of iostreams in the to_string tests 2020-10-27 13:36:13 -04:00
Louis Dionne 87d3a5365e [libc++] Remove references to CONDUIT_TOKEN
It's not required anymore, since we rely on another job to report
the results back to Phabricator.
2020-10-27 12:26:44 -04:00