Commit Graph

5968 Commits

Author SHA1 Message Date
Sergej Jaskiewicz e308a0ca15 [libcxx] Fix a typo in config.py
Reviewers: ldionne, jroelofs, EricWF

Subscribers: christof, dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D71890
2019-12-26 18:51:09 +03:00
Ruslan Baratov 6e8659c351 [libc++] Fix typo in std::midpoint
Reviewed By: mclow.lists

Differential Revision: https://reviews.llvm.org/D71525
2019-12-21 01:26:24 -08:00
Michał Górny e1882af9f6 [libc++] Update feature list for NetBSD
Add NetBSD to the same feature list as Fuchsia since it matches
in available features, effectively enabling aligned_alloc(),
timespec_get() and C11 features.  Remove now-duplicate declaration
of quick_exit() support.

Differential Revision: https://reviews.llvm.org/D71511
2019-12-20 17:50:47 +01:00
Mikhail Maltsev 67ce7f51a5 [libcxx] Fix include paths in fuzzing/partial_sort.pass.cpp
Summary:
When testing an installed (out-of-tree) version of libc++, the
"libcxx/fuzzing/partial_sort.pass.cpp" test fails because of missing
include files "../fuzzing/fuzzing.{h,cpp}". This happens because in
the source tree "../fuzzing" can be accessed as
"libcxx/include/../fuzzing", but with the installed library this does
not work.

This patch fixes the issue by changing the path to be relative from
the `libcxx/test/fuzzing" directory.

Reviewers: mclow.lists, EricWF, christof, michaelplatings

Reviewed By: michaelplatings

Subscribers: merge_guards_bot, ldionne, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D71459
2019-12-17 11:48:19 +00:00
Eric Fiselier a53534a9f6 [libc++] Add __default_init_tag to basic_string constructors
This removes unneeded zero initialization of string data.

For example, given the below code:

void Init(void *mem) {
    new (mem) std::string("Hello World");
}

Assembly before:

Init(void*):
        xorps   xmm0, xmm0
        movups  xmmword ptr [rdi], xmm0
        mov     qword ptr [rdi + 16], 0
        mov     byte ptr [rdi], 22
        movabs  rax, 8022916924116329800
        mov     qword ptr [rdi + 1], rax
        mov     dword ptr [rdi + 8], 1684828783
        mov     byte ptr [rdi + 12], 0
        ret

Assembly after:

Init():
        mov     byte ptr [rdi], 22
        movabs  rax, 8022916924116329800
        mov     qword ptr [rdi + 1], rax
        mov     dword ptr [rdi + 8], 1684828783
        mov     byte ptr [rdi + 12], 0
        ret

Patch by Martijn Vels (mvels@google.com)
Reviewed as https://reviews.llvm.org/D70621
2019-12-16 19:04:09 -05:00
Eric Fiselier 549545b64a [libc++] Rework compressed pair constructors.
This patch de-duplicates most compressed pair constructors
to use the same code in C++11 and C++03.

Part of doing that is deleting the "__second_tag()" and replacing
it with a "__value_init_tag()" which has the same effect, but
allows for the removal of the special "one-arg" first element
constructor.

This patch is intended to have no semantic change.
2019-12-16 18:38:58 -05:00
Eric Fiselier 0fa118a9da Add default initialization to compressed_pair.
This change introduces the __default_init_tag to memory, and a corresponding
element constructor to allow for default initialization of either of the pair
values. This is useful for classes such as std::string where most (all)
constructors explicitly initialize the values in the constructor.

Patch by Martijn Vels (mvels@google.com)
Reviewed as https://reviews.llvm.org/D70617
2019-12-16 17:14:02 -05:00
Stephan T. Lavavej 5688f16852 [libcxx] [test] Include missing headers. (NFC)
libcxx/test/std/containers/sequences/array/at.pass.cpp
Need to include <stdexcept> for std::out_of_range.

libcxx/test/std/localization/locale.categories/category.time/*
Need to include <ios> for std::ios.
2019-12-13 18:24:18 -08:00
Eric Fiselier fda3825c7a [libc++] Ensure __config always defines certain configuration macros. 2019-12-13 15:42:07 -05:00
Stephan T. Lavavej bf7dc572f1 [libcxx] [test] Fix valarray UB and MSVC warnings.
[libcxx] [test] Calling min and max on an empty valarray is UB.

libcxx/test/std/numerics/numarray/template.valarray/valarray.members/min.pass.cpp
libcxx/test/std/numerics/numarray/template.valarray/valarray.members/max.pass.cpp

The calls `v1.min();` and `v1.max();` were emitting nodiscard warnings
with MSVC's STL. Upon closer inspection, these calls were triggering
undefined behavior. N4842 [valarray.members] says:

"T min() const;
8 Preconditions: size() > 0 is true.
T max() const;
10 Preconditions: size() > 0 is true."

As these tests already provide coverage for non-empty valarrays
(immediately above), I've simply deleted the code for empty valarrays.

[libcxx] [test] Add macros to msvc_stdlib_force_include.h (NFC).

libcxx/test/support/msvc_stdlib_force_include.h

These macros are being used by:
libcxx/test/std/utilities/meta/meta.trans/meta.trans.other/result_of11.pass.cpp
Defining them to nothing allows that test to pass.

[libcxx] [test] Silence MSVC warning C5063 for is_constant_evaluated (NFC).

libcxx/test/std/utilities/meta/meta.const.eval/is_constant_evaluated.pass.cpp

This test is intentionally writing code that MSVC intentionally warns
about, so the warning should be silenced.

Additionally, comment an endif for clarity.

[libcxx] [test] Silence MSVC warning C4127 (NFC).

libcxx/test/support/charconv_test_helpers.h

MSVC avoids emitting this warning when it sees a single constexpr value
being tested, but this condition is a mix of compile-time and run-time.
Using push-disable-pop is the least intrusive way to silence this.

[libcxx] [test] Silence MSVC truncation warning (NFC).

libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp

This test is intentionally truncating float to int, which MSVC
intentionally warns about, so push-disable-pop is necessary.

[libcxx] [test] Avoid truncation warnings in erase_if tests (NFC).

libcxx/test/std/containers/associative/map/map.erasure/erase_if.pass.cpp
libcxx/test/std/containers/associative/multimap/multimap.erasure/erase_if.pass.cpp
libcxx/test/std/containers/unord/unord.map/erase_if.pass.cpp
libcxx/test/std/containers/unord/unord.multimap/erase_if.pass.cpp

These tests use maps with `short` keys and values, emitting MSVC
truncation warnings from `int`. Adding `static_cast` to `key_type`
and `mapped_type` avoids these warnings.

As these tests require C++20 mode (or newer), for brevity I've changed
the multimap tests to use emplace to initialize the test data.
This has no effect on the erase_if testing.
2019-12-12 18:35:27 -08:00
Eric Fiselier 9b540192b6 [libc++] Mark all fuzzing tests as unsupported in C++03 2019-12-12 21:12:27 -05:00
Eric Fiselier f97936fabd [libc++] Cleanup and enable multiple warnings.
Too many warnings are being disabled too quickly. Warnings are
important to keeping libc++ correct. This patch re-enables two
warnings: -Wconstant-evaluated and -Wdeprecated-copy.

In future, all warnings disabled for the test suite should require
an attached bug. The bug should state the plan for re-enabling that
warning, or a strong case why it should remain disabled.
2019-12-12 21:09:08 -05:00
Fangrui Song b7eb30d481 __bit_reference: fix -Wdeprecated-copy warnings
Since C++11, [depr.impldec]:

The implicit definition of a copy constructor as defaulted is deprecated
if the class has a user-declared copy assignment operator or a
user-declared destructor.

At clang HEAD, -Wdeprecated-copy (included by -Wextra) will warn on such instances.

Reviewed By: EricWF

Differential Revision: https://reviews.llvm.org/D71096
2019-12-12 16:31:36 -08:00
Eric Fiselier c6b8c3d5d9 [libc++] Tolerate NaN returning random distributions for now 2019-12-12 17:11:13 -05:00
Eric Fiselier 27ec4abeac [libc++] Add check to ensure oss-fuzz properly targets libc++. 2019-12-12 15:37:06 -05:00
Eric Christopher fa0fc04a4f Temporarily Revert "[libc++] Fix -Wdeprecated-copy warnings in __bit_reference"
as it's causing test failures due to mismatched visibility.

This reverts commit 02bb20223b.
2019-12-12 00:22:37 -08:00
Eric Christopher 02bb20223b [libc++] Fix -Wdeprecated-copy warnings in __bit_reference
Add a couple of default copy constructors to fix the warning.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D71395
2019-12-11 23:50:28 -08:00
Eric Fiselier 72b41e6e2d [libc++] Require C++14 in all cases.
LLVM has moved to C++14, and the libc++ build should too.
C++14 is needed to provide constant initialization for certain global
objects.

I suspect this change may break some older GCC buildbots, and I'll clean
those up as they fall.
2019-12-11 20:26:30 -05:00
Eric Fiselier 5c9816b84e [libc++] Fix fuzzing tests with older GCC compilers.
GCC 5 doesn't support `if constexpr`, so we need to do old-style tag
dispatching.
2019-12-11 16:36:54 -05:00
Eric Fiselier 29b2f64ddb [libc++] Fix fuzzing unit tests with exceptions disabled.
We simply turn off the parts of the tests that require exceptions.
2019-12-11 16:22:11 -05:00
Eric Fiselier daacf57032 [libc++] Add fuzzing tests for parts of <random>.
This patch also re-names the existing fuzzing unit tests so they
actually run.
2019-12-11 15:47:06 -05:00
Louis Dionne dd37e24ae6 [libc++] Hide some functions and types in <future> and <thread> as hidden
Otherwise, weak symbols leak into user programs when using `async` with
non-internal types.
2019-12-10 19:19:45 -05:00
Sergej Jaskiewicz 44c167ace9 [libcxx] Replace func_name with __name__ for compatibility with Python 3
Summary:
The __name__ attribute is the correct way to get a function name in
Python 3. This also works with Python 2.

Reviewers: jroelofs, EricWF

Subscribers: christof, ldionne, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D71136
2019-12-11 02:37:13 +03:00
Louis Dionne 8bd9d0bff2 [libcxx] [test] Query the target platform, not the host one
target_info is inferred to WindowsLocalTI on Windows hosts unless
specified otherwise. In the latter case, it doesn't make sense to use
Windows-specific settings if the target is not Windows.

This change should not break anything, because target_info is inferred
based on what platform.system() returns. self.is_windows was set based
on the same platform.system() call.

Thanks to Sergej Jaskiewicz for the patch.

Differential Revision: https://reviews.llvm.org/D68275
2019-12-10 16:36:07 -05:00
Petr Hosek 1aa1702381 [libcxx{,abi}] Don't link libpthread and libdl on Fuchsia
These are a part of the libc so linking these explicitly isn't necessary
and embedding these as deplibs causes link time error.

This issues was introduced in a9b5fff which changed how we emit deplibs.

Differential Revision: https://reviews.llvm.org/D71135
2019-12-06 11:15:15 -08:00
Michał Górny a9b5fff591 [libcxx{,abi}] Emit deplibs only when detected by CMake
This is a followup to 35bc5276ca.  It fixes the dependent libs usage
in libcxx and libcxxabi to link pthread and rt libraries only if CMake
detects them, rather than based on explicit platform blacklist.

Differential Revision: https://reviews.llvm.org/D70888
2019-12-02 22:19:20 +01:00
David Zarzycki 06e5ebf8db
[libcxx] Add -Wno-deprecated-copy to the test config 2019-11-29 09:57:51 +02:00
marshall 703c26f03b Optimize and fix basic_string move assignment operator. Reviewed as https://reviews.llvm.org/D68623. Thanks to mvels for the patch. 2019-11-27 07:13:32 -08:00
Shoaib Meenai d018b556c7 [libcxx] Omit unneeded locale fallbacks on Android 21+
Android API level 21 and above have all these functions available, so we
don't need to include our fallback definitions.

Differential Revision: https://reviews.llvm.org/D69983
2019-11-25 11:06:08 -08:00
Sergej Jaskiewicz 0313075793 [libcxx] Add Sergej Jaskiewicz to CREDITS.txt
Summary: Also, test commit access

Reviewers: EricWF

Subscribers: christof, ldionne, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D70526
2019-11-21 12:06:10 +03:00
Louis Dionne 9918312682 [libc++] Separate -include and path to the site config file
This apparently breaks weird use cases where the build directory is on
a separate drive. Someone reported that failure to me privately.

I can't remember of a reason for collating the two arguments in the
first place, so I don't think this should break anything.
2019-11-18 16:28:53 -05:00
Dan Albert 19fd9039ca Fix _LIBCPP_HAS_ definitions for Android.
Summary:
Android added quick_exit()/at_quick_exit() in API level 21,
aligned_alloc() in API level 28, and timespec_get() in API level 29,
but has the other C11 features at all API levels (since they're basically
just coming from clang directly).

_LIBCPP_HAS_QUICK_EXIT and _LIBCPP_HAS_TIMESPEC_GET already existed,
so we can reuse them. (And use _LIBCPP_HAS_TIMESPEC_GET in a few more
places where _LIBCPP_HAS_C11_FEATURES has been used as a proxy. This
isn't correct for Android.)

_LIBCPP_HAS_ALIGNED_ALLOC is added, to cover aligned_alloc() (obviously).

Add a missing std:: before aligned_alloc in a cstdlib test, and remove a
couple of !defined(_WIN32)s now that we're explicitly testing
TEST_HAS_ALIGNED_ALLOC rather than TEST_HAS_C11_FEATURES.

Reviewers: danalbert, EricWF, mclow.lists

Reviewed By: danalbert

Subscribers: srhines, christof, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D69929
2019-11-18 12:19:58 -08:00
Dan Albert 626260cfe3 Update the docs for building libc++.
Summary:
Rewrite the in-tree build to be a clearer tl;dr like we have for the
out-of-tree build.

Reviewers: EricWF, mclow.lists, ldionne

Reviewed By: ldionne

Subscribers: dexonsmith, christof, ldionne, enh, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D69917
2019-11-18 12:14:13 -08:00
Eric Fiselier f82dba0192 Rename __is_foo_iterator traits to reflect their Cpp17 nature.
With the upcoming introduction of iterator concepts in ranges,
the meaning of "__is_contiguous_iterator" changes drastically.

Currently we intend it to mean "does it have this iterator category",
but it could now also mean "does it meet the requirements of this
concept", and these can be different.
2019-11-18 01:49:32 -05:00
Eric Fiselier 6624fcba43 [libc++] Add _ITER_CONCEPT and _ITER_TRAITS implementations from C++20
These traits are currently unused because we don't implement ranges.
However, their addition is part of ongoing work to allow libc++
to optimize on user-provided contiguous iterators.
2019-11-16 20:26:35 -05:00
Eric Fiselier 45d048c204 [libc++] Add C++20 contiguous_iterator_tag.
This work is part of an ongoing effort to allow libc++ to
optimize user provided contiguous iterators.
2019-11-16 20:14:44 -05:00
Eric Fiselier 0068c59139 [libc++] Rename __to_raw_pointer to __to_address.
This function has the same behavior as the now-standand std::to_address.
Re-using the name makes the behavior more clear, and in the future it
will allow us to correctly get the raw pointer for user provided pointer
types.
2019-11-16 17:16:09 -05:00
Marek Kurdej 8e34be2f25 [libc++] [chrono] Fix year_month_weekday::ok() implementation.
Reviewers: ldionne, EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: christof, dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D70282
2019-11-15 18:48:45 +01:00
Ilya Tokar 767eadd782 [libcxx] use __builtin_isnan in std::isnan.
Summary: This allows std::isnan to be fully inlined, instead of generating calls.

Reviewers: EricWF

Reviewed By: EricWF

Subscribers: christof, ldionne

Differential Revision: https://reviews.llvm.org/D69806
2019-11-15 12:29:18 -05:00
Marek Kurdej 76ac1660f7 [libc++] [P0920] [P1661] Update status page. 2019-11-15 00:12:34 +01:00
Louis Dionne 1466335cf4 [libc++][P1872] span should have size_type, not index_type.
Thanks to Marek Kurdej for the patch.

Differential Revision: https://reviews.llvm.org/D70206
2019-11-14 09:07:05 -05:00
Louis Dionne 8b77a3a0f4 [libc++] [P1612] Add missing feature-test macro __cpp_lib_endian.
Thanks to Marek Kurdej for the patch.

Differential Revision: https://reviews.llvm.org/D70221
2019-11-14 08:55:19 -05:00
Marek Kurdej d94f63758a libc++ status page: Fix HTML. 2019-11-13 22:51:29 +01:00
David Zarzycki 1d55c9e59e [libcxx testing] Fix -Wtautological-overlap-compare bug 2019-11-13 10:55:19 +02:00
Michael Park eb8710cb93
[libc++][P0980] Marked member functions move/copy/assign of char_traits constexpr.
Reviewers: ldionne, EricWF, mclow.lists

Reviewed By: ldionne

Subscribers: christof, dexonsmith, libcxx-commits

Tags: #libc

Differential Revision: https://reviews.llvm.org/D68840
2019-11-11 09:49:48 -08:00
Nick Desaulniers 49fb4a96e0 change LLVM_VERSION_SUFFIX default from svn to git
Summary:
Sayonara SVN!

Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Reviewers: tstellar, jyknight, lebedev.ri, smeenai, mgorny, hans, mclow.lists

Reviewed By: mgorny, hans

Subscribers: christof, libcxx-commits, llvm-commits, srhines

Tags: #libc, #llvm

Differential Revision: https://reviews.llvm.org/D70019
2019-11-11 09:10:20 -08:00
Louis Dionne 48b7068bec [libc++] Mark __call_once_proxy as hidden and internal
We effectively never want to export that function, which is an
implementation detail of libc++. This was previously tried in
603715c66b and then reverted in 8335dd314f because it caused
linker warnings. These linker warnings should go away now that we
use internal_linkage instead of always_inline to implement per-TU
insulation.
2019-11-11 10:27:48 -05:00
marshall 2f4fb200b6 libc++ status page: New papers and issues adopted in Belfast 2019-11-11 08:13:05 +00:00
Mark de Wever 27c4eaac8c [libc++] Validate the entire regex is consumed
This change would have warned about the bug found in D62451.
No unit tests since the exception should never throw.

Differential Revision: https://reviews.llvm.org/D62452
2019-11-09 17:01:37 +01:00
Louis Dionne 0ec6a4882e [libc++] Fix potential OOB in poisson_distribution
See details in the original Chromium bug report:
    https://bugs.chromium.org/p/chromium/issues/detail?id=994957
2019-11-07 13:29:40 +00:00