Commit Graph

6109 Commits

Author SHA1 Message Date
David Blaikie e658b3eb97 PR43764: Qualify a couple of calls to forward_as_tuple to be ADL-resilient. 2019-10-28 18:04:41 -07:00
--global a062856bcf [NFC] Comment endif to test commit access 2019-10-28 09:19:08 -07:00
marshall 82b82e39c4 Add all the issues to be voted upon in Belfast 2019-10-26 07:53:15 -07:00
Louis Dionne fd667b860e [libcxx] [test] Run `chmod +x` on executables when testing via SSH
When running libc++ tests on a remote machine via SSH, we can encounter
a 'Permission denied' error.

Fix this with plain old 'chmod +x <executable>'.

Thanks to Sergej Jaskiewicz for the patch.

Differential Revision: https://reviews.llvm.org/D69170
2019-10-25 09:47:46 -07:00
Stephan T. Lavavej 2e4f1e112d [www] Change URLs to HTTPS.
This changes most URLs in llvm's html files to HTTPS. Most changes were
search-and-replace with manual verification; some changes were manual.
For a few URLs, the websites were performing redirects or had changed
their anchors; I fixed those up manually. This consistently uses the
official https://wg21.link redirector. This also strips trailing
whitespace and fixes a couple of typos.

Fixes D69363.

There are a very small number of dead links for which I don't know any
replacements (they are equally dead as HTTP or HTTPS):

https://llvm.org/cmds/llvm2cpp.html
https://llvm.org/devmtg/2010-11/videos/Grosser_Polly-desktop.mp4
https://llvm.org/devmtg/2010-11/videos/Grosser_Polly-mobile.mp4
https://llvm.org/devmtg/2011-11/videos/Grosser_PollyOptimizations-desktop.mov
https://llvm.org/devmtg/2011-11/videos/Grosser_PollyOptimizations-mobile.mp4
https://llvm.org/perf/db_default/v4/nts/22463
https://polly.llvm.org/documentation/memaccess.html
2019-10-24 13:25:15 -07:00
Stephan T. Lavavej 7c9844b66e [libcxx][NFC] Strip trailing whitespace, fix typo. 2019-10-23 11:49:43 -07:00
Louis Dionne 6b77ebdc91 [NFC] Strip trailing whitespace from libc++ 2019-10-23 11:19:19 -07:00
Casey Carter 689ce81059
[libc++][NFC] Remove excess trailing newlines from most files
Testing git commit access.
2019-10-23 08:08:57 -07:00
Stephan T. Lavavej 437e0e5191 [libcxx][test][NFC] Fix comment typos.
(Testing git commit access.)
2019-10-22 15:22:13 -07:00
Louis Dionne 19e95ab421 [NFC] Strip trailing whitespace in test to test Github committing 2019-10-22 15:03:01 -07:00
Zoe Carver 40c47680eb [libcxx] Remove shared_ptr::make_shared
Summary: This patch removes `shared_ptr::make_shared` as it is not part of the standard. This patch also adds __create_with_cntrl_block, which is a help function that can be used in std::allocate_shared and std::make_shared. This is the third patch (out of 4) from D66178.

    Reviewers: EricWF, mclow.lists, ldionne

    Subscribers: christof, dexonsmith, libcxx-commits

    Tags: #libc

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

llvm-svn: 375504
2019-10-22 15:16:49 +00:00
Louis Dionne 3292facc0a [NFC] Fix typos in CMake comment
llvm-svn: 375469
2019-10-21 23:38:32 +00:00
Dimitry Andric d5367db95c Refine check for `_LIBCPP_C_HAS_NO_GETS` on FreeBSD
Summary:
In D67316 we added `_LIBCPP_C_HAS_NO_GETS` to signal that the C library
does not provide `gets()`, and added a test for FreeBSD 13 or higher,
using the compiler-defined `__FreeBSD__` macro.

Unfortunately this did not work that well for FreeBSD's own CI process,
since the gcc compilers used for some architectures define `__FreeBSD__`
to match the build host, not the target.

Instead, we should use the `__FreeBSD_version` macro from the userland
header `<osreldate.h>`, which is more fine-grained.  See also
<https://reviews.freebsd.org/D22034>.

Reviewers: EricWF, mclow.lists, emaste, ldionne

Reviewed By: emaste, ldionne

Subscribers: dexonsmith, bsdjhb, krytarowski, christof, ldionne, libcxx-commits

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

llvm-svn: 375340
2019-10-19 10:59:23 +00:00
Richard Smith a9727033fb P1152R4: Fix deprecation warnings in libc++ testsuite and in uses of is_invocable that would internally conjure up a deprecated function type.
Summary: The implementation of P1152R4 in Clang has resulted in some deprecation warnings appearing in the libc++ and libc++abi test suite. Fix or suppress these warnings.

Reviewers: mclow.lists, EricWF

Subscribers: christof, ldionne, libcxx-commits

Tags: #libc

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

llvm-svn: 375307
2019-10-19 00:06:00 +00:00
Casey Carter 6f0768f64d [libc++][test] Use <version> to get config on MSVC
...instead of `<ciso646>`.

Also includes some NFC comment changes.

llvm-svn: 374854
2019-10-15 00:22:38 +00:00
Casey Carter fcad66f165 [libc++][test] Portability fix for std::any tests
Ensure that `large_tracked_t` defined in `any_helpers.h` is in fact too large to fit in `std::any`'s small object buffer.

llvm-svn: 374806
2019-10-14 19:05:04 +00:00
Casey Carter c86ba58188 [libc++][test] Add license headers to test/support/archetypes.*
Differential Revision: https://reviews.llvm.org/D68947

llvm-svn: 374797
2019-10-14 18:00:34 +00:00
Casey Carter a4f07b4d2e [libc++][test] Silence more warnings in variant tests
More cases of signed-to-unsigned conversion warnings that missed the train for d2623522.

llvm-svn: 374778
2019-10-14 14:38:12 +00:00
Casey Carter 80e088e141 [libc++][test] std::variant test cleanup
* Add the conventional `return 0` to `main` in `variant.assign/conv.pass.cpp` and `variant.ctor/conv.pass.cpp`

* Fix some MSVC signed-to-unsigned conversion warnings by replacing `int` literarls with `unsigned int` literals

llvm-svn: 374723
2019-10-13 16:46:16 +00:00
Casey Carter 1f92d8b544 [libc++][test] <=> now has a feature-test macro
...which `test/support/test_macros.h` can use to detect compiler support.

llvm-svn: 374722
2019-10-13 16:46:12 +00:00
Casey Carter e198823b87 [libc++][test] Silence MSVC warning in std::optional test
`make_optional<string>(4, 'X')` passes `4` (an `int`) as the first argument to `string`'s `(size_t, charT)` constructor, triggering a signed/unsigned mismatch warning when compiling with MSVC at `/W4`. The incredibly simple fix is to instead use an unsigned literal (`4u`).

llvm-svn: 374684
2019-10-12 19:01:46 +00:00
Petr Hosek 34a3b24a90 [libc++] Fix linker script generation
Handle the case when libc++abi and libunwind are being built together
with libc++ in the runtimes build. This logic was used in the previous
implementation but dropped in r374116.

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

llvm-svn: 374510
2019-10-11 04:54:35 +00:00
Casey Carter ffc83995de [libc++][test] Change IsSmallObject's calculation for std::any's small object buffer
`sizeof(std::any) - sizeof(void*)` is correct for both libc++ and the MSVC standard library.

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

llvm-svn: 374407
2019-10-10 18:07:12 +00:00
Casey Carter b2e3c83b0d [libc++][test] Miscellaneous MSVC cleanups
* Silence unused-local-typedef warnings: `map.cons/assign_initializer_list.pass.cpp` (and the `set.cons` variant) uses a local typedef only within `LIBCPP_ASSERT`s, so clang diagnoses it as unused when testing non-libc++.
* Add missing include: `c.math/abs.pass.cpp` uses `std::numeric_limits` but failed to `#include <limits>`.
* Don't test non-type: A "recent" change to `meta.trans.other/underlying_type.pass.cpp` unconditionally tests the type `F` which is conditionally defined.
* Use `hash<long long>` instead of `hash<short>` with `int` in `unordered_meow` deduction guide tests to avoid truncation warnings.
* Convert `3.14` explicitly in `midpoint.float.pass` since MSVC incorrectly diagnoses `float meow = 3.14;` as truncating.

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

llvm-svn: 374248
2019-10-09 22:19:17 +00:00
Eric Fiselier 78153b3a97 Optimize operator=(const basic_string&) for tail call.
Patch by Martijn Vels (mvels@google.com)
Reviewed as https://reviews.llvm.org/D68276

This is a non trivial win for externally templated assignment operator.

x86 without tail call (current libc++)

0000000000000000 <std::string::operator=(std::string const&)>:
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   53                      push   %rbx
   5:   50                      push   %rax
   6:   48 89 fb                mov    %rdi,%rbx
   9:   48 39 f7                cmp    %rsi,%rdi
   c:   74 17                   je     25 <std::string::operator=(std::string const&)+0x25>
   e:   0f b6 56 17             movzbl 0x17(%rsi),%edx
  12:   84 d2                   test   %dl,%dl
  14:   79 07                   jns    1d <std::string::operator=(std::string const&)+0x1d>
  16:   48 8b 56 08             mov    0x8(%rsi),%rdx
  1a:   48 8b 36                mov    (%rsi),%rsi
  1d:   48 89 df                mov    %rbx,%rdi
  20:   e8 00 00 00 00          callq  25 <std::string::operator=(std::string const&)+0x25>
  25:   48 89 d8                mov    %rbx,%rax
  28:   48 83 c4 08             add    $0x8,%rsp
  2c:   5b                      pop    %rbx
  2d:   5d                      pop    %rbp
  2e:   c3                      retq

After:

0000000000000000 <std::string::operator=(std::string const&)>:
   0:   48 39 f7                cmp    %rsi,%rdi
   3:   74 14                   je     19 <std::string::operator=(std::string const&)+0x19>
   5:   0f b6 56 17             movzbl 0x17(%rsi),%edx
   9:   84 d2                   test   %dl,%dl
   b:   79 07                   jns    14 <std::string::operator=(std::string const&)+0x14>
   d:   48 8b 56 08             mov    0x8(%rsi),%rdx
  11:   48 8b 36                mov    (%rsi),%rsi
  14:   e9 00 00 00 00          jmpq   19 <std::string::operator=(std::string const&)+0x19>
  19:   48 89 f8                mov    %rdi,%rax
  1c:   c3                      retq

Benchmark (pending per https://reviews.llvm.org/D67667)

```
BM_StringAssignStr_Empty_Opaque                     6.23ns ± 0%             5.19ns ± 0%  -16.70%          (p=0.016 n=5+4)
BM_StringAssignStr_Empty_Transparent                5.86ns ± 0%             5.14ns ± 0%  -12.24%          (p=0.008 n=5+5)
BM_StringAssignStr_Small_Opaque                     8.79ns ± 1%             7.69ns ± 0%  -12.53%          (p=0.008 n=5+5)
BM_StringAssignStr_Small_Transparent                9.44ns ± 0%             8.00ns ± 0%  -15.26%          (p=0.008 n=5+5)
BM_StringAssignStr_Large_Opaque                     25.2ns ± 0%             24.3ns ± 0%   -3.50%          (p=0.008 n=5+5)
BM_StringAssignStr_Large_Transparent                23.6ns ± 0%             22.5ns ± 0%   -4.76%          (p=0.008 n=5+5)
BM_StringAssignStr_Huge_Opaque                       319ns ± 5%              317ns ± 5%     ~             (p=0.690 n=5+5)
BM_StringAssignStr_Huge_Transparent                  319ns ± 5%              317ns ± 5%     ~             (p=0.421 n=5+5)
BM_StringAssignAsciiz_Empty_Opaque                  7.41ns ± 0%             7.77ns ± 0%   +4.89%          (p=0.008 n=5+5)
BM_StringAssignAsciiz_Empty_Transparent             7.54ns ± 3%             7.30ns ± 0%   -3.24%          (p=0.008 n=5+5)
BM_StringAssignAsciiz_Small_Opaque                  9.87ns ± 0%            10.24ns ± 1%   +3.76%          (p=0.008 n=5+5)
BM_StringAssignAsciiz_Small_Transparent             10.4ns ± 1%              9.8ns ± 2%   -5.78%          (p=0.008 n=5+5)
BM_StringAssignAsciiz_Large_Opaque                  30.1ns ± 0%             30.1ns ± 0%     ~             (p=0.167 n=5+5)
BM_StringAssignAsciiz_Large_Transparent             27.1ns ± 0%             27.4ns ± 0%   +0.92%          (p=0.016 n=4+5)
BM_StringAssignAsciiz_Huge_Opaque                    383ns ± 4%              382ns ± 4%     ~             (p=0.548 n=5+5)
BM_StringAssignAsciiz_Huge_Transparent               375ns ± 0%              380ns ± 0%   +1.37%          (p=0.029 n=4+4)
BM_StringAssignAsciizMix_Opaque                     14.0ns ± 0%             14.0ns ± 0%     ~             (p=0.881 n=5+5)
BM_StringAssignAsciizMix_Transparent                13.7ns ± 1%             13.8ns ± 0%     ~             (p=0.056 n=5+5)
```

llvm-svn: 374137
2019-10-09 03:07:02 +00:00
Louis Dionne fe53d2dc6b [libc++] Workaround old versions of CMake that don't understand list(JOIN)
llvm-svn: 374120
2019-10-08 21:33:35 +00:00
Louis Dionne 1ea8bb39b9 [libc++] Move the linker script generation step to CMake
Summary:
This allows the linker script generation to query CMake properties
(specifically the dependencies of libc++.so) instead of having to
carry these dependencies around manually in global variables. Notice
the removal of the LIBCXX_INTERFACE_LIBRARIES global variable.

Reviewers: phosek, EricWF

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

Tags: #libc

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

llvm-svn: 374116
2019-10-08 21:10:20 +00:00
Louis Dionne 32300877f9 [libc++] Make sure we link all system libraries into the benchmarks
It turns out that r374056 broke _some_ build bots again, specifically
the ones using sanitizers. Instead of trying to link the right system
libraries to the benchmarks bit-by-bit, let's just link exactly the
system libraries that libc++ itself needs.

llvm-svn: 374079
2019-10-08 16:26:24 +00:00
Louis Dionne c864f73e45 [libc++] TAKE 2: Make system libraries PRIVATE dependencies of libc++
We tried doing that previously (in r373487) and failed (reverted in
r373506) because the benchmarks needed to link against system libraries
and relied on libc++'s dependencies being propagated. Now that this has
been fixed (in r374053), this commit marks the system libraries as
PRIVATE dependencies of libc++.

llvm-svn: 374056
2019-10-08 14:53:11 +00:00
Louis Dionne cf3ab6d96c [libc++] Add missing link-time dependencies to the benchmarks
Since the benchmarks build with -nostdlib, they need to manually link
against some system libraries that are used by the benchmarks and the
GoogleBenchmark library itself.

Previously, we'd rely on the fact that these libraries were linked
through the PUBLIC dependencies of cxx_shared/cxx_static. However,
if we were to make these dependencies PRIVATE (as they should be
because they are implementation details of libc++), the benchmarks
would fail to link. This commit remediates that.

llvm-svn: 374053
2019-10-08 14:28:56 +00:00
Louis Dionne 534c86d172 [libc++] Use PRIVATE to link benchmark dependencies
It's better style to use PRIVATE when linking libraries to executables,
and it doesn't make a difference since executables don't need to propagate
their link-time dependencies anyway.

llvm-svn: 374050
2019-10-08 14:10:55 +00:00
Zoe Carver a9d43b55c7 [libc++] Remove C++03 variadics in shared_ptr (v2)
Summary: In my last patch (D67675) I forgot a few variadics. This patch removes the remaining make_shared and allocate_shared C++03 variadics.

    Reviewers: ldionne, EricWF, mclow.lists

    Subscribers: christof, dexonsmith, libcxx-commits

    Tags: #libc

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

llvm-svn: 373971
2019-10-07 21:41:15 +00:00
Alex Langford 9627b26c40 [libc++] Guard cxx_experimental settings behind LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY
If you explicitly set LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY to OFF, your
project will fail to configure because the cxx_experimental target
doesn't exist.

llvm-svn: 373809
2019-10-04 23:08:20 +00:00
Louis Dionne fadc84ae9a [libc++] Localize common build flags into a single CMake function
Also, set those flags for the cxx_experimental target. Otherwise,
cxx_experimental doesn't build properly when neither the static nor
the shared library is compiled (yes, that is a weird setup).

llvm-svn: 373808
2019-10-04 22:50:23 +00:00
Sterling Augustine b3e3934347 Add an off-by-default option to enable testing for gdb pretty printers.
Summary:
The current version of the pretty printers are not python3 compatible,
so turn them off by default until sufficiently improved.

Reviewers: MaskRay, tamur

Subscribers: mgorny, christof, llvm-commits

Tags: #llvm

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

llvm-svn: 373796
2019-10-04 22:15:28 +00:00
Louis Dionne 13c4254714 [libc++] Make the modules-related flags PUBLIC instead of PRIVATE
It appears that those need to be propagated to targets that use libc++
as well, otherwise they don't build properly.

llvm-svn: 373773
2019-10-04 19:10:56 +00:00
Louis Dionne 432ae75f8b [libc++] Move more CMake flags to per-target definitions
This daily refactoring tackles flags related to modules,
exceptions and RTTI.

llvm-svn: 373767
2019-10-04 18:03:17 +00:00
Fangrui Song 4a71328f15 Make libc++ gdb pretty printer Python 3 compatible
llvm-svn: 373691
2019-10-04 04:47:33 +00:00
Eric Fiselier 5e7e6f16d9 Attempt to remove linker workaround on the buildbots: Attempt 2
The first commit removed the workaround in a old script.
This patch removes it in the file actually used by the bots.

I have no idea if this is still needed, but removing the
workaround seems like the easiest way to test.

I'll revert this change if the bots go red.

llvm-svn: 373653
2019-10-03 19:38:44 +00:00
Eric Fiselier bed690e370 Attempt to remove linker workaround on the buildbots.
I have no idea if this is still needed, but removing the
workaround seems like the easiest way to test.

I'll revert this change if the bots go red.

llvm-svn: 373650
2019-10-03 19:13:35 +00:00
Louis Dionne c5b74bf6e5 [libc++] Add a per-target flag to include the generated config_site
This allows propagating the include automatically to targets that
depend on one of the libc++ targets such as the benchmarks. Note
that the GoogleBenchmark build itself still needs to manually specify
the -include, since I don't know of any way to have an external project
link against one of the libc++ targets (which would propagate the -include
automatically).

llvm-svn: 373631
2019-10-03 17:20:50 +00:00
Louis Dionne 0961a152d8 [libc++] Add missing revision number in ABI changelog
llvm-svn: 373625
2019-10-03 16:50:05 +00:00
Fangrui Song c4b5e594b4 Fix libc++ pretty printer test for Python 3 after D67238 (take 2)
In both Python 2 and Python 3, gdb.Value.string returns a 'str'. We just
need to delete a `encode("utf-8")` which would return a 'bytes' in
Python 3.

llvm-svn: 373570
2019-10-03 06:19:50 +00:00
Louis Dionne 925d9d2e14 [libc++] Use functions instead of global variables to set libc++ build flags
This commit follows the trend of doing things per-target instead of
modifying the C++ flags globally. It does so for visibility-related
flags, other basic build flags and Windows-specific flags.

llvm-svn: 373517
2019-10-02 20:07:01 +00:00
Louis Dionne c78c0e08be [libc++] Use a function to set warning flags per target
This is part of a larger shift to move to per-target settings and
eradicate global variables from the CMake build. I'm starting small
with warnings only because those are easy to transition over and I
want to see how it pans out, but we can handle all flags like exceptions
and RTTI in the future.

llvm-svn: 373511
2019-10-02 19:31:30 +00:00
Louis Dionne 9cc90ec349 [libc++] Revert to using PUBLIC instead of PRIVATE when linking system libs
It turns out the benchmarks need to link against those libraries
explicitly too, so CMake's propagation of PUBLIC dependencies is
used.

llvm-svn: 373506
2019-10-02 19:11:08 +00:00
Louis Dionne ef315b5361 [libc++] Use PRIVATE instead of PUBLIC when linking against system libs
llvm-svn: 373487
2019-10-02 16:51:42 +00:00
Fangrui Song 619bcebc05 Fix libc++ pretty printer test for Python 3 after D67238
llvm-svn: 373452
2019-10-02 11:49:47 +00:00
Sterling Augustine 9b36c1cf27 Determine endianness at a time when it doesn't inadvertantly clear gdb's wrap_buffer via gdb.execute.
Summary:
I haven't managed a small reproduction for this bug, it involves
complicated and deeply nested data structures with a wide variety
of pretty printers. But in general, we shouldn't be combining
gdb's command line interface (via gdb.execute) with pretty-printers.

Subscribers: christof, llvm-commits

Tags: #llvm

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

llvm-svn: 373402
2019-10-01 22:42:37 +00:00
Louis Dionne 85ee0c2ec3 [NFC] Fix typos in libc++ documentation
llvm-svn: 373390
2019-10-01 20:34:50 +00:00
Louis Dionne bcab95182b [libc++] Re-apply workaround for D63883
In reality, this workaround is for the fact that LIBCXX_CXX_ABI=libcxxabi
can't be specified on Linux, since libc++abi isn't shipped with the system.
Since the build bots explicitly specify LIBCXX_CXX_ABI=libcxxabi, they fail
unless we apply the workaround.

llvm-svn: 373385
2019-10-01 19:27:38 +00:00
Louis Dionne 32f869e0ee [libc++] Remove workaround for D63883
I tried applying D63883 three times and could never get around to
making it work. I'm giving up on that for now, but soon this should
be irrelevant anyway since all builds will move to the monorepo
(where we're always using the in-tree libc++abi unless explicitly
specified otherwise).

llvm-svn: 373384
2019-10-01 19:13:52 +00:00
Louis Dionne 371ea70bb7 [libc++] Harden usage of static_assert against C++03
In C++03, we emulate static_assert with a macro, and we must parenthesize
multiple arguments.

llvm-svn: 373328
2019-10-01 12:12:21 +00:00
Eric Fiselier c8ad8686ac Refactor default constructor SFINAE in pair and tuple.
Refactor the  recent implicit default constructor changes to match the
existing SFINAE style.

llvm-svn: 373263
2019-09-30 20:55:30 +00:00
Louis Dionne 59e26308e6 [libc++] Take 2: Implement LWG 3158
Summary:
LWG 3158 marks the allocator_arg_t constructor of std::tuple as
conditionnally explicit based on whether the default constructors
of the tuple's members are explicitly default constructible.

This was previously committed as r372778 and reverted in r372832 due to
the commit breaking LLVM's build in C++14 mode. This issue has now been
addressed.

Reviewers: mclow.lists

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

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

llvm-svn: 373092
2019-09-27 15:06:52 +00:00
Louis Dionne e16f2cb678 [libc++] Take 2: Implement LWG 2510
Summary:
LWG2510 makes tag types like allocator_arg_t explicitly default
constructible instead of implicitly default constructible. It also
makes the constructors for std::pair and std::tuple conditionally
explicit based on the explicit-ness of the default constructibility
for the pair/tuple's elements.

This was previously committed as r372777 and reverted in r372832 due to
the commit breaking LLVM's build in C++14 mode. This issue has now been
addressed.

Reviewers: mclow.lists

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

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

llvm-svn: 372983
2019-09-26 14:51:10 +00:00
David Zarzycki a068601510 [libcxx] Do not implicitly #include assert.h
Users should only get the assert() macros if they explicitly include
them.

Found after switching from the GNU C++ stdlib to the LLVM C++ stdlib.

llvm-svn: 372963
2019-09-26 11:12:29 +00:00
Louis Dionne 45c935bd0b [libc++] Purge mentions of GCC 4 from the test suite
We don't support GCC 4 and older according to the documentation, so
we should pretend it doesn't exist.

This is a re-application of r372787.

llvm-svn: 372916
2019-09-25 19:40:48 +00:00
Eric Fiselier af4a29af01 Add forward declaration of operator<< in <string_view> as required.
This declaration was previously missing despite appearing in the
synopsis. Users are still required to include <ostream> to get the
definition of the streaming operator.

llvm-svn: 372909
2019-09-25 18:56:54 +00:00
Eric Fiselier a32717750d add tests that debug mode catches nullptr->string_view conversions in comparison operators
llvm-svn: 372907
2019-09-25 18:43:40 +00:00
Marshall Clow e3f89a989a Add a missing default parameter to regex::assign. This is LWG3296; reviewed as https://reviews.llvm.org/D67944
llvm-svn: 372896
2019-09-25 16:40:30 +00:00
Ilya Biryukov a3d337a9a7 Revert r372777: [libc++] Implement LWG 2510 and its follow-ups
This also reverts:
 - r372778: [libc++] Implement LWG 3158
 - r372782: [libc++] Try fixing tests that fail on GCC 5 and older
 - r372787: Purge mentions of GCC 4 from the test suite

Reason: the change breaks compilation of LLVM with libc++, for details see
http://lists.llvm.org/pipermail/libcxx-dev/2019-September/000599.html

llvm-svn: 372832
2019-09-25 09:10:38 +00:00
Louis Dionne de8609c62a [libc++] Purge mentions of GCC 4 from the test suite
We don't support GCC 4 and older according to the documentation, so
we should pretend it doesn't exist.

llvm-svn: 372787
2019-09-24 22:42:36 +00:00
Louis Dionne ee9a468d9c [libc++] Try fixing tests that fail on GCC 5 and older
llvm-svn: 372782
2019-09-24 22:13:17 +00:00
Zoe Carver 4278a9e6b5 [libc++] Remove C++03 variadics in shared_ptr
Summary: As suggested by @ldionne in D66178, this patch removes C++03 variadics //only//. Following patches will apply more updates.

    Reviewers: ldionne, EricWF, mclow.lists

    Subscribers: christof, dexonsmith, libcxx-commits, ldionne

    Tags: #libc

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

llvm-svn: 372780
2019-09-24 20:55:54 +00:00
Louis Dionne e9e1c88ed9 [libc++] Implement LWG 3158
Summary:
LWG 3158 marks the allocator_arg_t constructor of std::tuple as
conditionnally explicit based on whether the default constructors
of the tuple's members are explicitly default constructible.

Reviewers: EricWF, mclow.lists

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

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

llvm-svn: 372778
2019-09-24 20:22:34 +00:00
Louis Dionne 95411dd426 [libc++] Implement LWG 2510
Summary:
LWG2510 makes tag types like allocator_arg_t explicitly default
constructible instead of implicitly default constructible. It also
makes the constructors for std::pair and std::tuple conditionally
explicit based on the explicit-ness of the default constructibility
for the pair/tuple's elements.

Reviewers: mclow.lists, EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

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

llvm-svn: 372777
2019-09-24 20:18:54 +00:00
Louis Dionne 3e1480a03b [libc++] Mark CTAD tests as not failing on AppleClang 10.0.1
They do fail on AppleClang 10.0.0, but not AppleClang 10.0.1

llvm-svn: 372632
2019-09-23 17:22:13 +00:00
Louis Dionne f73ea05db0 [libc++] Mark iostreams test as XFAIL on older macOSes
llvm-svn: 372620
2019-09-23 15:40:47 +00:00
Marshall Clow ab8f77a73e Revert "Extension: Mark the default constructor of chrono::duration as conditionally noexcept"; this breaks the gcc5 bot for C++11
This reverts commit c8ca15c95c4c0d6d1356500d5fe49a319ea4ca01.

llvm-svn: 372546
2019-09-23 06:16:41 +00:00
Marshall Clow d8ac51ab8f Extension: Mark the default constructor of chrono::duration as conditionally noexcept
llvm-svn: 372539
2019-09-23 04:16:48 +00:00
Dan Albert 85e26f56cb Revert "Revert "Implement std::condition_variable via pthread_cond_clockwait() where available""
With the fix for non-Linux.

This reverts commit c1c519d2f1.

llvm-svn: 372242
2019-09-18 18:13:32 +00:00
Dan Albert c1c519d2f1 Revert "Implement std::condition_variable via pthread_cond_clockwait() where available"
This reverts commit 5e37d7f9ff.

llvm-svn: 372034
2019-09-16 21:20:32 +00:00
Dan Albert a7e9059967 Open fstream files in O_CLOEXEC mode when possible.
Reviewers: EricWF, mclow.lists, ldionne

Reviewed By: ldionne

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

Tags: #libc

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

llvm-svn: 372027
2019-09-16 19:26:41 +00:00
Dan Albert 5e37d7f9ff Implement std::condition_variable via pthread_cond_clockwait() where available
std::condition_variable is currently implemented via
pthread_cond_timedwait() on systems that use pthread. This is
problematic, since that function waits by default on CLOCK_REALTIME
and libc++ does not provide any mechanism to change from this
default.

Due to this, regardless of if condition_variable::wait_until() is
called with a chrono::system_clock or chrono::steady_clock parameter,
condition_variable::wait_until() will wait using CLOCK_REALTIME. This
is not accurate to the C++ standard as calling
condition_variable::wait_until() with a chrono::steady_clock parameter
should use CLOCK_MONOTONIC.

This is particularly problematic because CLOCK_REALTIME is a bad
choice as it is subject to discontinuous time adjustments, that may
cause condition_variable::wait_until() to immediately timeout or wait
indefinitely.

This change fixes this issue with a new POSIX function,
pthread_cond_clockwait() proposed on
http://austingroupbugs.net/view.php?id=1216. The new function is
similar to pthread_cond_timedwait() with the addition of a clock
parameter that allows it to wait using either CLOCK_REALTIME or
CLOCK_MONOTONIC, thus allowing condition_variable::wait_until() to
wait using CLOCK_REALTIME for chrono::system_clock and CLOCK_MONOTONIC
for chrono::steady_clock.

pthread_cond_clockwait() is implemented in glibc (2.30 and later) and
Android's bionic (Android API version 30 and later).

This change additionally makes wait_for() and wait_until() with clocks
other than chrono::system_clock use CLOCK_MONOTONIC.<Paste>

llvm-svn: 372016
2019-09-16 17:57:48 +00:00
Eric Fiselier 6bc1236d39 Add debug check for null pointers passed to <string_view>
llvm-svn: 371925
2019-09-14 19:55:28 +00:00
Eric Fiselier cb9216b908 Fix C++03 build failures due to >>
llvm-svn: 371894
2019-09-13 20:30:45 +00:00
Eric Fiselier e210c0383b Mark [[nodiscard]] test as unsupported with GCC 5
llvm-svn: 371886
2019-09-13 19:09:29 +00:00
Eric Fiselier 5560270855 Fix pretty printer test with GCC
llvm-svn: 371884
2019-09-13 19:04:33 +00:00
Eric Fiselier ffe8916cf2 Fix various test failures with GCC
llvm-svn: 371880
2019-09-13 18:40:46 +00:00
Eric Fiselier 7ff9a9353c Fix failing negative compilation test for some versions of Clang
llvm-svn: 371874
2019-09-13 17:39:06 +00:00
Eric Fiselier 2a573784f3 Recommit r370502: Make `vector` unconditionally move elements when
exceptions are disabled.

The patch was reverted due to some confusion about non-movable types. ie
types
that explicitly delete their move constructors. However, such types do
not meet
the requirement for `MoveConstructible`, which is required by
`std::vector`:

Summary:

`std::vector<T>` is free choose between using copy or move operations
when it
needs to resize. The standard only candidates that the correct exception
safety
guarantees are provided. When exceptions are disabled these guarantees
are
trivially satisfied. Meaning vector is free to optimize it's
implementation by
moving instead of copying.

This patch makes `std::vector` unconditionally move elements when
exceptions are
disabled. This optimization is conforming according to the current
standard wording.

There are concerns that moving in `-fno-noexceptions`mode will be a
surprise to
users. For example, a user may be surprised to find their code is slower
with
exceptions enabled than it is disabled. I'm sympathetic to this
surprised, but
I don't think it should block this optimization.

Reviewers: mclow.lists, ldionne, rsmith
Reviewed By: ldionne
Subscribers: zoecarver, christof, dexonsmith, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D62228

llvm-svn: 371867
2019-09-13 16:09:33 +00:00
Marshall Clow 7b81a13bfc Only initialize the streams cout/wcout/cerr/wcerr etc once, rather than any time Init::Init is called. Fixes PR#43300
llvm-svn: 371864
2019-09-13 15:28:06 +00:00
Eric Fiselier 24c1ab2633 Fix build in C++20
llvm-svn: 371863
2019-09-13 15:13:11 +00:00
Zoe Carver 31a1ea1772 [libc++] Mark issue 2587 resolved by issue 2567
Updates status. NFC.

llvm-svn: 371763
2019-09-12 19:50:06 +00:00
Zoe Carver b51d5605b1 Consolidate swap, swap_ranges, and iter_swap in <type_traits>.
NFC. Thanks to @Quuxplusone (Arthur O'Dwyer) for this change.

llvm-svn: 371639
2019-09-11 17:39:24 +00:00
Louis Dionne 340b725202 [libc++] Add a CMake cache for Apple-specific configuration options
llvm-svn: 371638
2019-09-11 16:57:19 +00:00
Dimitry Andric 5bd4a4806a Remove ::gets for FreeBSD 13 and later
Summary:
In https://svnweb.freebsd.org/changeset/base/351659 @emaste removed gets() from
FreeBSD 13's libc, and our copies of libc++ and libstdc++.  In that change, the
declarations were simply deleted, but I would like to propose this conditional
test instead.

Reviewers: EricWF, mclow.lists, emaste

Reviewed By: mclow.lists

Subscribers: krytarowski, christof, ldionne, emaste, libcxx-commits

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

llvm-svn: 371324
2019-09-07 22:18:20 +00:00
Sterling Augustine 3270941f1e Add gdb pretty printers for a wide variety of libc++ data structures (take 2).
Summary:
This patch is an exact duplicate of https://reviews.llvm.org/D65609, except
that it uses the newly introduced testing framework to detect if gdb is present
so that the tests won't fail on machines without gdb.

Reviewers: echristo, EricWF

Subscribers: christof, ldionne, llvm-commits

Tags: #llvm

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

llvm-svn: 371131
2019-09-05 21:35:05 +00:00
Sterling Augustine a127795617 Don't assume libcxx_gdb is always set.
libc++abi also uses this file, but doesn't use the same CMakeLists.txt.

llvm-svn: 371130
2019-09-05 21:34:54 +00:00
Vedant Kumar 1261f1b980 [libcxx] Codesign test executables if necessary
If LLVM_CODESIGNING_IDENTITY is set, test executables need to be
codesigned.

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

llvm-svn: 371126
2019-09-05 21:24:23 +00:00
Sterling Augustine bf7602b261 Add testing infrastructure to check if gdb is available for testing.
Reviewers: echristo, EricWF

Subscribers: mgorny, christof, llvm-commits

Tags: #llvm

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

llvm-svn: 371120
2019-09-05 20:44:08 +00:00
Louis Dionne b370e7691a [libc++] Revert "Make `vector` unconditionally move elements when exceptions are disabled."
This reverts r370502, which broke the use case of a copy-only T (with a
deleted move constructor) when exceptions are disabled. Until we figure
out the right behavior, I'm reverting the commit.

llvm-svn: 371068
2019-09-05 13:50:28 +00:00
Louis Dionne f1b4eba66f [libc++] Add a test for resizing of a vector with copy-only elements
See https://reviews.llvm.org/D62228#1658620

llvm-svn: 371067
2019-09-05 13:50:18 +00:00
Marshall Clow b7ebdbdb35 Reformat the beginning of the testing doc to make clear how to run all the tests.
llvm-svn: 371001
2019-09-05 00:38:36 +00:00
Louis Dionne 5afc5a6c1b [libc++] Only build with -fvisibility=hidden on Clang
The visibility annotations in libc++ are not quite right for GCC, which
results in symbols not being exported when -fvisibility=hidden is used.
To fix the GCC build bots, this commit reverts to the previous state of
not building with hidden visibility on GCC.

In the future, we can build with hidden visibility all the time and
export symbols explicitly using a list. See https://llvm.org/D66970
for one take at this.

llvm-svn: 370926
2019-09-04 16:41:31 +00:00
Louis Dionne b92deded87 [libc++] Move __clamp_to_integral to <cmath>, and harden against min()/max() macros
llvm-svn: 370900
2019-09-04 13:35:03 +00:00
Louis Dionne e8316372b9 [libc++] Add `__truncating_cast` for safely casting float types to integers
This is needed anytime we need to clamp an arbitrary floating point
value to an integer type.

Thanks to Eric Fiselier for the patch.

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

llvm-svn: 370891
2019-09-04 12:48:32 +00:00
Louis Dionne 801f6a495c [libc++] Use __extension__ in a portable manner
llvm-svn: 370889
2019-09-04 12:44:19 +00:00
Louis Dionne 79b476150b [libc++] Mark usage of _Atomic with __extension__
An upcoming change in Clang will flag _Atomic as being a C11 extension.
To avoid generating this warning in libc++, this commit marks the only
use of _Atomic with the __extension__ extension, which suppresses such
warnings.

llvm-svn: 370796
2019-09-03 17:52:18 +00:00
Nico Weber a627bd3a02 [libc++] Fix directory_iterator compilation on Win32
This patch fixes some typos and other small errors in
directory_iterator.cpp that prevented this file from being compiled for
Win32.

Patch by Stefan Schmidt <thrimbor.github@gmail.com>!

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

llvm-svn: 370599
2019-08-31 23:17:38 +00:00
Sterling Augustine 33e17db591 Revert "Add gdb pretty printers for a wide variety of libc++ data structures."
This reverts commit d8c9f2f572fe06a34ccfc28ee9223b64d7d275d3.

llvm-svn: 370553
2019-08-31 00:00:34 +00:00
Sterling Augustine d21a3e41a4 Add gdb pretty printers for a wide variety of libc++ data structures.
Summary: Also add a test suite.

Reviewers: EricWF

Subscribers: christof, llvm-commits

Tags: #llvm

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

Run a pep8 formatter.

Run pep8 formatter.

Convert to PEP8, address other comments from code review.

llvm-svn: 370551
2019-08-30 23:43:34 +00:00
Eric Fiselier 2dd37a31ce Make `vector` unconditionally move elements when exceptions are disabled.
Summary:
`std::vector<T>` is free choose between using copy or move operations when it needs to resize. The standard only candidates that the correct exception safety guarantees are provided. When exceptions are disabled these guarantees are trivially satisfied. Meaning vector is free to optimize it's implementation by moving instead of copying.

This patch makes `std::vector` unconditionally move elements when exceptions are disabled.

This optimization is conforming according to the current standard wording.

There are concerns that moving in `-fno-noexceptions`mode will be a surprise to users. For example, a user may be surprised to find their code is slower with exceptions enabled than it is disabled. I'm sympathetic to this surprised, but I don't think it should block this optimization.


Reviewers: mclow.lists, ldionne, rsmith

Reviewed By: ldionne

Subscribers: zoecarver, christof, dexonsmith, libcxx-commits

Tags: #libc

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

llvm-svn: 370502
2019-08-30 19:01:03 +00:00
Louis Dionne f7a544bca8 [libc++] Fix visibility of __vector_base_common on GCC
Since we build the library with -fvisibility=hidden, the shared object
wouldn't contain __vector_base_common<true>::__throw_length_error()
and __vector_base_common<true>::__throw_out_of_range(), leading to
link errors. This only happened on GCC for some reason.

https://llvm.org/PR43140

llvm-svn: 370240
2019-08-28 18:10:39 +00:00
Louis Dionne b5aefed40a [libc++] Add yet another test for inverted character classes
This was reported as part of a bug report that ended up being a
duplicate for r340609, but I'm adding the test case since it's
ever so slightly different from what we had before.

llvm-svn: 370109
2019-08-27 20:39:10 +00:00
Louis Dionne 236f8012c9 [libc++] Fix typo in documentation for LIBCXX_HERMETIC_STATIC_LIBRARY
Thanks to Yichen Yan for the patch.
Differential Revision: https://reviews.llvm.org/D66675

llvm-svn: 369800
2019-08-23 19:42:09 +00:00
Louis Dionne 344eee9227 [libc++] Improve Python 3 compatibility for merge_archives.py
Popen.communicate() method in Python 2 returns a pair of strings, and in
Python 3 it returns a pair of byte-like objects unless universal_newlines
is set to True. This led to an error when using Python 3. With this patch,
merge_archives.py works fine with Python 3.

Thanks to Sergej Jaskiewicz for the patch.
Differential Revision: https://reviews.llvm.org/D66649

llvm-svn: 369764
2019-08-23 15:05:54 +00:00
Nico Weber 01d7fe7605 libcxx: Make gen_link_script.py print contents only in --dryrun mode
The build should generally be quiet if there are no errors,
and this script has been around long enough that we can remove
the log output. If we ever need to debug something with this script,
we can put back the logging then.

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

llvm-svn: 369757
2019-08-23 13:40:54 +00:00
Louis Dionne b43923da5b [libc++] Fix broken <random> test
In r369429, I hoisted a floating point computation to a variable in order
to remove a warning. However, it turns out this doesn't play well with
floating point arithmetic. This commit reverts r369429 and instead casts
the result of the floating point computation to remove the warning.

Whether hoisting the computaiton to a variable should give the same
result can be investigated independently.

llvm-svn: 369693
2019-08-22 19:35:46 +00:00
Louis Dionne 347c7d682e [libc++] Mark lock_guard nodiscard test as unsupported in C++03
llvm-svn: 369672
2019-08-22 17:24:24 +00:00
Nico Weber 0f3efc4aab libcxx: Rename last two .hpp files in libcxx to .h
Differential Revision: https://reviews.llvm.org/D66544

llvm-svn: 369597
2019-08-21 22:38:38 +00:00
David Spickett e2b200b7bf [libcxx] Only declare contents of threading API when
_LIBCPP_HAS_THREAD_API_EXTERNAL is not defined.

When it is defined they will be declared by the
__external_threading header instead.

Differential revision: https://reviews.llvm.org/D66518

llvm-svn: 369537
2019-08-21 15:38:24 +00:00
Nico Weber f938755a33 libcxx: Rename .hpp files in libcxx/benchmarks to .h
LLVM uses .h as its extension for header files.

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

llvm-svn: 369487
2019-08-21 01:59:12 +00:00
Eric Fiselier 5b59295011 Fix missing __muloti4 function with UBSAN
llvm-svn: 369483
2019-08-21 00:16:33 +00:00
Eric Fiselier a6edef3563 Attempt to fix MSAN failures in benchmarks
llvm-svn: 369482
2019-08-21 00:14:48 +00:00
Nico Weber cc89063bff libcxx: Rename .hpp files in libcxx/test/support to .h
LLVM uses .h as its extension for header files.

Files renamed using:

    for f in libcxx/test/support/*.hpp; do git mv $f ${f%.hpp}.h; done

References to the files updated using:

    for f in $(git diff master | grep 'rename from' | cut -f 3 -d ' '); do
        a=$(basename $f);
        echo $a;
        rg -l $a libcxx | xargs sed -i '' "s/$a/${a%.hpp}.h/";
    done

HPP include guards updated manually using:

    for f in $(git diff master | grep 'rename from' | cut -f 3 -d ' '); do
      echo ${f%.hpp}.h ;
    done | xargs mvim

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

llvm-svn: 369481
2019-08-21 00:14:12 +00:00
Marshall Clow 4f41779cca Add a missing _VSTD:: before a call to merge. Fixes PR43034. Checked the rest of 'algorithm' looking for unqualified calls. Didn't find any.
llvm-svn: 369463
2019-08-20 22:23:35 +00:00
Marshall Clow 7fa6865392 Fix a couple of unguarded operator, calls in algorithm. Fixes PR#43063. Updated all the heap tests to check this.
llvm-svn: 369448
2019-08-20 21:31:51 +00:00
Zoe Carver 80ddfcb5b8 [libc++] Fix std::abs tests
On systems where sizeof(long) == sizeof(int)
the current tests failed. This commit updates
those tests to work on all systems.
std::abs has specific long specializations
which can be used instead.

llvm-svn: 369437
2019-08-20 20:44:59 +00:00
Louis Dionne c310e5a7ab [libc++] Avoid implicit conversion warning in a <random> test
By stashing the computation of `E::max() - E::min()` in a variable, we
avoid the warning introduced in r367497. Note that we use `auto` to
avoid having to deduce the type of the computation, which is not a
problem since Clang provides `auto` as an extension even in C++03 (and
we disable warnings related to using C++11 extensions in the test suite).

llvm-svn: 369429
2019-08-20 19:28:26 +00:00
Eric Fiselier bc2f425377 fix buildbot start script to no longer hang
llvm-svn: 369428
2019-08-20 19:06:23 +00:00
Louis Dionne fc4486c247 [libc++] Implement LWG 3199
Summary:
The resolution of LWG 3199 makes sure that input-streaming into an empty bitset
does not set the failbit on the input stream.

Reviewers: mclow.lists, EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

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

llvm-svn: 369422
2019-08-20 18:21:06 +00:00
Louis Dionne 958987bfdd [libc++] Precise XFAIL for AppleClang 11
This test doesn't fail on all patch levels of AppleClang 11

llvm-svn: 369420
2019-08-20 18:05:06 +00:00
Eric Fiselier 1d37ec1fda bump lld version used by buildbots
llvm-svn: 369416
2019-08-20 17:43:00 +00:00
Zoe Carver 86d560ff1b [libc++] fix test for unsigned char
On some systems char is unsigned.
If that is the case, we will now
test signed char twice in std::abs.
NFC. Fixes the build bots.

llvm-svn: 369413
2019-08-20 17:09:00 +00:00
Louis Dionne cb93f650b6 [libc++] Disable <chrono> ""d and ""y literal tests on AppleClang 10.0.0
In r368882, I enabled those tests for all AppleClang's above version 9.
However, it turns out that the feature is only supported starting with
AppleClang 10.0.1, not AppleClang 10.0.0. This commit fixes that hole.

llvm-svn: 369409
2019-08-20 16:45:27 +00:00
Louis Dionne ab50b830d0 [libc++] Populate a lit feature including the compiler patch level
If the compiler is (for example) AppleClang 10.0.1, we would previously
populate the following lit features:

    apple-clang
    apple-clang-10
    apple-clang-10.0

This patch additionally populates a feature called 'apple-clang-10.0.1',
which allows more precise enabling/disabling of tests.

llvm-svn: 369406
2019-08-20 16:41:38 +00:00
Marshall Clow 696630eaf2 Fix availability of __thread_id on builds with external threading. Reviewed as https://reviews.llvm.org/D66480
llvm-svn: 369399
2019-08-20 16:16:23 +00:00
Zoe Carver 6585f018ad [libc++] std::abs should not return double
Implement LWG Issue 2735 by adding std::abs
tests for several types and checking their
return value. NFC.

llvm-svn: 369394
2019-08-20 15:43:25 +00:00
Louis Dionne a47ca1ea6d [libc++] Explicitly cast in generate_canonical
A new clang warning introduced in r367497 was complaining about
the change in value.

Thanks to Brian Cain for the patch.
Differential Revision: https://reviews.llvm.org/D66422

llvm-svn: 369393
2019-08-20 15:39:20 +00:00
Mikhail Maltsev a83220c6f2 [libcxx] Fix build breakage on mips
Fixes https://bugs.llvm.org/show_bug.cgi?id=43011 caused by
https://reviews.llvm.org/D63284.

Committing as obvious.

llvm-svn: 369364
2019-08-20 10:19:55 +00:00
Louis Dionne 5a14c17221 Provide a meaningful diagnostic when LLVM_PATH doesn't point to a directory
llvm-svn: 369312
2019-08-19 23:51:26 +00:00
Louis Dionne 296757c07c [libc++] Add XFAIL for is_base_of test on AppleClang 11
llvm-svn: 369280
2019-08-19 17:29:42 +00:00
Zoe Carver 471bbb6e72 [libc++] reverts commit a5f5aad568.
The commit being reverted caused segfaults when building
with libc++ and GCC (and possibly other configurations).

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

llvm-svn: 369270
2019-08-19 15:47:16 +00:00
Marshall Clow 2e80d01fa7 Fix thread comparison by making sure we never pass our special 'not a thread' value to the underlying implementation. Fixes PR#42918.
llvm-svn: 368916
2019-08-14 20:54:56 +00:00
Louis Dionne 3f274d4a55 [libc++] Mark <chrono> test as unsupported on AppleClang 9
llvm-svn: 368914
2019-08-14 20:27:56 +00:00
Louis Dionne b4aebff4f1 [libc++] Mark std::tuple CTAD test as failing on AppleClang 9
Like CTAD for std::unordered_set, AppleClang 9's support for CTAD is
insufficient. I suspect the corresponding LLVM Clang is broken too,
but we don't seem to have testers using that Clang.

llvm-svn: 368911
2019-08-14 20:17:18 +00:00
Zoe Carver a5f5aad568 This commit removes std::shared_ptr::make_shared and std::shared_ptr::allocate_shared as they are not part of the standard. This commit also adds the helper function "__create_with_cntrl_block" which std::allocate_shared and std::make_shared have been updated to use.
llvm-svn: 368885
2019-08-14 17:19:25 +00:00
Louis Dionne 619172a818 [libc++] Enable <chrono> ""d and ""y literals for AppleClang 10 and up
AppleClang supports those literals starting in version 10.0.1.

llvm-svn: 368882
2019-08-14 17:04:31 +00:00
Louis Dionne 3555af7120 [libc++] Do not define _LIBCPP_CLANG_VER for non-LLVM Clang
In r292833, we started defining _LIBCPP_CLANG_VER to 0 for Apple Clang.
The result is that AppleClang is detected as being a very old version
of LLVM Clang (version 0), which is obviously incorrect.

I believe this was added so that we don't have to check whether
_LIBCPP_CLANG_VER is defined prior to comparing it with a number
(which can trigger a warning). This commit also fixes the two
places that use the macro correspondingly.

llvm-svn: 368880
2019-08-14 17:01:08 +00:00
Marshall Clow 2b1d42541f Rework recursive_timed_mutex so that it uses __thread_id instead of using the lower-level __libcpp_thread_id. This is prep for fixing PR42918. Reviewed as https://reviews.llvm.org/D65895
llvm-svn: 368867
2019-08-14 16:21:27 +00:00
Louis Dionne 10f0668b57 [libc++] Mark two <chrono> tests as unsupported on AppleClang 11
The operator""y and operator""d will eventually be supported by
AppleClang, but no released version supports them at the moment.

llvm-svn: 368749
2019-08-13 21:34:49 +00:00
Louis Dionne 8a033a9e3f [libc++] Always build with -fvisibility=hidden
Summary:
This avoids symbols being accidentally exported from the dylib when they
shouldn't. The next step is to use a pragma to apply hidden visibility
to all declarations (unless otherwise specified), which will allow us
to drop the per-declaration hidden visibility attributes we currently
have.

This also has the nice side effect of making sure the dylib exports the
same symbols regardless of the optimization level.

PR38138

Reviewers: EricWF, mclow.lists

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

Tags: #libc

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

llvm-svn: 368703
2019-08-13 15:02:53 +00:00
Louis Dionne fa8cb90e6f [libc++] Fix incorrect UNSUPPORTED annotation
The test was marked as UNSUPPORTED for clang-6 and clang-6, instead of
clang-6 and clang-7.

llvm-svn: 368666
2019-08-13 11:25:16 +00:00
Louis Dionne 86dd28a547 [libc++] Use [[nodiscard]] for lock_guard, as an extension
Summary:
D64914 added support for applying [[nodiscard]] to constructors. This
commit uses that capability to flag incorrect uses of std::lock_guard
where one forgets to actually create a variable for the lock_guard.

rdar://45790820

Reviewers: mclow.lists, EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits, Quuxplusone, lebedev.ri

Tags: #libc

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

llvm-svn: 368664
2019-08-13 11:12:28 +00:00
Louis Dionne 1308011e1b [libc++] Implement CTAD for std::tuple
Summary:
We were using implicit deduction guides instead of explicit ones,
however the implicit ones don't do work anymore when changing the
constructors.

This commit adds the actual guides specified in the Standard to make
libc++ (1) closer to the Standard and (2) more resistent to changes
in std::tuple's constructors.

Reviewers: Quuxplusone

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

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

llvm-svn: 368599
2019-08-12 18:30:31 +00:00
Eric Fiselier b0945e1bd2 Improve codegen for deque.
This patch rewrites a few loops in deque and split_buffer to better
optimize the codegen. For constructors like
`deque<unsigned char> d(500000, 0);` this patch results in a 2x speedup.

The patch improves the codegen  in roughly three ways:

1. Changes do { ... } while (...) loops into more typical for loops.
  The optimizer can reason about normal looking loops better.

2. Split the iteration over a range into (A) iteration over the blocks,
then (B) iteration within the block. This nested structure helps LLVM
lower the inner loop to `memset`.

3. Do fewer things each iteration. Some of these loops were incrementing
  or changing 4-5 variables every loop (in addition to the
  construction). Previously most loops would increment the end pointer,
  the size, and decrement the count of remaining items to construct.
  Now we only increment a single pointer for most iterations.

llvm-svn: 368547
2019-08-12 07:51:05 +00:00
Louis Dionne 5f92cb7014 [libc++] Fix environment variable passing in libc++'s `SSHExecutor` `lit` utility
Summary:
Quote the value of environment variables when passing them to the SSH
client in SSHExecutor in libc++'s lit utilities. Without the quotes,
an environment variable like FOO="buzz bar" gets passed incorrectly
like this, ssh env FOO=buzz bar, which causes bar to be treated as a
command to run, not part of the environment variable value.

We ran into this when using SSHExecutor to do bringup of our CUDA
libcu++ port on an embedded aarch64 system.

Patch by Bryce Adelstein Lelbach.

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

llvm-svn: 368317
2019-08-08 17:33:35 +00:00
Marshall Clow fde236b1f7 Implement hh_mm_ss from P1466R3. Reviewed as https://reviews.llvm.org/D65365.
llvm-svn: 368299
2019-08-08 14:36:07 +00:00
Louis Dionne bf4808439f [pstl] Add a __pstl_config_site header to record the CMake configuration
This commit adds a __pstl_config_site header that contains the value of
macros specified at CMake configuration time. It works similarly to
libc++'s __config_site header, except we always include it as a separate
file instead of concatenating it to the main configuration header.

It is necessary to thread the includes for that header into libc++'s
lit configuration, otherwise we'd be requiring an installation step
prior to running the test suite.

llvm-svn: 368284
2019-08-08 12:43:04 +00:00
Louis Dionne 80ef2f05d8 Revert "[libc++] Take 3: Do not cleverly link against libc++abi just because it happens to be there"
This also reverts "[libc++] Remove temporary hack for D63883".
Clearly, I don't understand how the Linux build bots are configured.

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

llvm-svn: 368238
2019-08-08 00:28:06 +00:00
Louis Dionne 127af283ab [libc++] Remove temporary hack for D63883
This should fix the build bots, who now specify explicitly that they're
building against libc++abi.

llvm-svn: 368216
2019-08-07 21:51:01 +00:00
Louis Dionne e0eed65e06 [libc++] Take 3: Do not cleverly link against libc++abi just because it happens to be there
Summary:
Otherwise, when libcxxabi is not an enabled project in the monorepo, we
get a link error because we try to link against non-existent cxxabi_shared.

More generally, we shouldn't change the behavior of the build based on
implicit things like whether a file happens to be at a specific path or
not.

This is a re-application of r365222 that had been reverted in r365233
and then r365359 because it broke the build bots. The build bots
should now specify explicitly what ABI library they want to use
(libc++abi), so this commit should now be OK to merge. It takes a while
for build bots to pick up configuration changes, which is why this failed
the last time around.

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

llvm-svn: 368213
2019-08-07 21:36:03 +00:00
Louis Dionne 956892433f [pstl][libc++] Provide uglified header names for interface headers
For the few (currently four) headers that make up the PSTL's interface
to other Standard Libraries, provide a stable uglified header file that
can be included by those Standard Libraries.

We can then more easily change the internal organization of the PSTL
without having to change the integration with Standard Libraries.

llvm-svn: 368088
2019-08-06 21:11:24 +00:00
Louis Dionne 53e9c2d76b [libc++] Use the monorepo for the back-deployment testing scripts
llvm-svn: 368077
2019-08-06 20:01:28 +00:00
Louis Dionne 8442252c49 [libc++] Use the monorepo in the macos-trunk CI script
llvm-svn: 368051
2019-08-06 15:28:34 +00:00
Louis Dionne d131713307 [libc++] Accept any non-zero return for .fail.cpp tests
llvm-svn: 367930
2019-08-05 21:26:50 +00:00
Louis Dionne 0a06eb911b [libc++] Take 2: Integrate the PSTL into libc++
Summary:
This commit allows specifying LIBCXX_ENABLE_PARALLEL_ALGORITHMS when
configuring libc++ in CMake. When that option is enabled, libc++ will
assume that the PSTL can be found somewhere on the CMake module path,
and it will provide the C++17 parallel algorithms based on the PSTL
(that is assumed to be available).

The commit also adds support for running the PSTL tests as part of
the libc++ test suite.

The first attempt to commit this failed because it exposed a bug in the
tests for modules. Now that this has been fixed, it should be safe to
commit this.

Reviewers: EricWF

Subscribers: mgorny, christof, jkorous, dexonsmith, libcxx-commits, mclow.lists, EricWF

Tags: #libc

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

llvm-svn: 367903
2019-08-05 18:29:14 +00:00
Eric Fiselier 278d593014 Revert "Suppress -Wctad-maybe-unsupported on types w/o deduction guides."
Some modules builds are issuing buggy diagnostics. The cause of which is
TBD.

This reverts commit r@367770.

llvm-svn: 367777
2019-08-04 07:13:43 +00:00
Eric Fiselier fcd549a7d8 Suppress -Wctad-maybe-unsupported on types w/o deduction guides.
There are a handful of standard library types that are intended
to support CTAD but don't need any explicit deduction guides to
do so.

This patch adds a dummy deduction guide to those types to suppress
-Wctad-maybe-unsupported (which gets emitted in user code).

llvm-svn: 367770
2019-08-03 23:54:29 +00:00
Eric Fiselier 208e8a1b66 Revert accidental change to __member_pointer_traits_imp.
A previous patch accidentally made the primary template
an incomplete type. This broke some C++03 constructs.

llvm-svn: 367762
2019-08-03 19:03:22 +00:00
Eric Fiselier 10bf563171 Simplify <type_traits> implementations.
This patch rewrites a number of old meta-function implementations
that assumed const/volatile could not be safely applied to all types.
This is no longer the case, though for some types (Ex function types),
the const qualifier can be ignored.

The largest improvement in this patch is the reduction of is_function.
Thanks to Matt Calabrese for the improved implementation.

llvm-svn: 367749
2019-08-03 05:01:34 +00:00
Eric Fiselier c4952da401 Add benchmarks to test the cost of allocator
llvm-svn: 367722
2019-08-02 21:13:38 +00:00
Eric Fiselier d544d1441d Refactor deque to centralize handling of spare blocks.
I have upcoming changes that modify how deque handles spare blocks.
This cleanup is intended to make those changes easier to review
and understand. This patch should have NFC.

llvm-svn: 367631
2019-08-01 23:11:18 +00:00
Eric Fiselier 8f2124b47a Teach malloc_allocator how to count bytes
llvm-svn: 367606
2019-08-01 19:52:46 +00:00
Eric Fiselier 3eb5aec61f Change default bucket count in hash_set/hash_map.
Previously these types rehashed to a table of 193 elements
upon construction. But this is non-ideal, first because default
constructors should not allocate unless necessary, and second
because 193 is big and can waste a bunch of memory.

This number had previously been chosen to match GCC's implementation.

llvm-svn: 367605
2019-08-01 19:48:29 +00:00
Roman Lebedev 1e4a094b37 [benchmark] Fix win32 link on case-sensitive fs
Summary: This fixes cross-builds with MinGW from case-sensitive file-systems (on Linux)

This is a cherry-pick from
https://github.com/google/benchmark/pull/840
8e48105d46

Original patch by: @jschueller (Julien Schueller) !

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

llvm-svn: 367356
2019-07-30 20:47:59 +00:00
Eric Fiselier 54bb5413e6 add more information to benchmark test failures
llvm-svn: 367319
2019-07-30 15:11:41 +00:00
Nico Weber 9aae539d4c libcxx: Define __STDCPP_THREADS__ to 1, not to __cplusplus.
[cpp.predefined]p2:

   __STDCPP_THREADS__
    Defined, and has the value integer literal 1, if and only if a program
    can have more than one thread of execution .

Also define it only if it's not defined already, since it's supposed
to be defined by the compiler.

Also move it from thread to __config (which requires setting it only
if _LIBCPP_HAS_NO_THREADS is not defined).

Part of PR33230. The intent is to eventually make the compiler define
this instead.

llvm-svn: 367316
2019-07-30 14:32:47 +00:00
Eric Fiselier b49d45925c Fix tests with modules enabled
llvm-svn: 367268
2019-07-29 22:48:51 +00:00
Eric Fiselier 0c045f135d Ensure __config_site definitions are passed to modules tests.
The test configuration contained a bug where we only raised
the __config_site commands to the command line if modules were
enabled for all of the libc++ tests. However there are special
modules-only tests, and these tests weren't getting the correct
defines.

This patch corrects that issue.

llvm-svn: 367267
2019-07-29 22:48:34 +00:00
Eric Fiselier d4ace50ed0 Fix PR35637: suboptimal codegen for `vector<unsigned char>`.
The optimizer is petulant and temperamental. In this case LLVM failed to lower
the the "insert at end" loop used by`vector<unsigned char>` to a `memset` despite
`memset` being substantially faster over a range of bytes.

LLVM has the ability to lower loops to `memset` whet appropriate, but the
odd nature of libc++'s loops prevented the optimization from taking places.

This patch addresses the issue by rewriting the loops from the form
`do [ ... --__n; } while (__n > 0);` to instead use a for loop over a pointer
range (For example: `for (auto *__i = ...; __i < __e; ++__i)`).

This patch also rewrites the asan annotations to unposion all additional memory
at the start of the loop instead of once per iterations. This could potentially
permit false negatives where the constructor of element N attempts to access
element N + 1 during its construction.

The before and after results for the `BM_ConstructSize/vector_byte/5140480_mean`
benchmark (run 5 times) are:

--------------------------------------------------------------------------------------------
Benchmark                                                 Time             CPU   Iterations
--------------------------------------------------------------------------------------------
Before
------
BM_ConstructSize/vector_byte/5140480_mean          12530140 ns     12469693 ns            N/A
BM_ConstructSize/vector_byte/5140480_median        12512818 ns     12445571 ns            N/A
BM_ConstructSize/vector_byte/5140480_stddev          106224 ns       107907 ns            5
-----
After
-----
BM_ConstructSize/vector_byte/5140480_mean            167285 ns       166500 ns            N/A
BM_ConstructSize/vector_byte/5140480_median          166749 ns       166069 ns            N/A
BM_ConstructSize/vector_byte/5140480_stddev            3242 ns         3184 ns            5

llvm-svn: 367183
2019-07-28 04:37:02 +00:00
Marshall Clow 736e8aa8ed Fix a bug in std::chrono::abs where it would fail when the duration's period had not been reduced.s
llvm-svn: 367120
2019-07-26 15:10:46 +00:00
Louis Dionne 568bb7eeb6 [NFC][libcxx] Add comments about making mutex/condition_variable trivial on Apple platforms
Leaving some comments behind so that we avoid re-having that discussion
in the future.

llvm-svn: 367048
2019-07-25 20:29:20 +00:00
Marshall Clow db99d3a2a2 Implement change #4 of P1466: Change weekday to accept both 0 and 7 as Sunday. Add accessors 'c_encoding' and 'iso_encoding' to provide different interpretations of the weekday. Remove 'operator unsigned'
llvm-svn: 366981
2019-07-25 03:26:05 +00:00
David Tenty b9179ff857 [AIX][lit] Don't depend on psutil on AIX
Summary:
On AIX psutil can run into problems with permissions to read the process
tree, which causes problems for python timeout tests which need to kill off
a test and it's children.

This patch adds a workaround by invoking shell via subprocess and using a
platform specific option to ps to list all the descendant processes so we can
kill them. We add some checks so lit can tell whether timeout tests are
supported with out exposing whether we are utilizing the psutil
implementation or the alternative.

Reviewers: hubert.reinterpretcast, andusy, davide, delcypher

Reviewed By: delcypher

Subscribers: davide, delcypher, christof, lldb-commits, libcxx-commits, llvm-commits

Tags: #lldb, #libc, #llvm

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

llvm-svn: 366912
2019-07-24 15:04:27 +00:00
Roger Ferrer Ibanez 09e6304440 [RISCV] Implement benchmark::cycleclock::Now
This is a cherrypick of D64237 onto llvm/utils/benchmark and
libcxx/utils/google-benchmark.

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

llvm-svn: 366868
2019-07-24 05:33:46 +00:00
Marshall Clow 30f12a4247 Implement most of P1612R1: Relocate endian. Moves the std::endian functionality from 'type-traits' to 'bit'. No other change. The reason that this is 'partial' is that P1621 also recommends a feature-test macro, but I don't have the value for that one yet. In a month or so, I'll add that
llvm-svn: 366776
2019-07-23 04:20:19 +00:00
Louis Dionne e35c5121da [NFC][libc++] Add missing EXPLICIT to pair and tuple synopsis
The constructors for std::pair and std::tuple have been made conditionally
explicit, however the synopsis in the headers do not reflect that.

llvm-svn: 366735
2019-07-22 20:45:23 +00:00
Yi Kong d8bdb9225c [runtimes] Don't depend on libpthread on Android
r362048 added support for ELF dependent libraries, but broke Android
build since Android does not have libpthread. Remove the dependency on
the Android build.

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

llvm-svn: 366734
2019-07-22 20:41:03 +00:00
Petr Hosek 89385633ba [libc++] Set __file_ to 0 in basic_filebuf::close() even if fclose fails
This issue was detected by ASan in one of our tests. This test manually
invokes basic_filebuf::cloe(). fclose(__h.release() returned a non-zero
exit status, so __file_ wasn't set to 0. Later when basic_filebuf
destructor ran, we would enter the if (__file_) block again leading to
heap-use-after-free error.

The POSIX specification for fclose says that independently of the return
value, fclose closes the underlying file descriptor and any further
access (including another call to fclose()) to the stream results in
undefined behavior. This is exactly what happened in our test case.

To avoid this issue, we have to always set __file_ to 0 independently of
the fclose return value.

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

llvm-svn: 366730
2019-07-22 19:54:34 +00:00
Louis Dionne c3e452acde [libc++] Do not infer support for C++17 in GCC < 7
libc++'s lit configuration infers the C++ language dialect when it is
not provided by checking which -std= flags that a compiler supports.
GCC 5 and GCC 6 have a -std=c++17 flag, however, they do not have full
C++17 support. The lit configuration has hardcoded logic that removes
-std=c++1z as an option to test for GCC < 7, but not -std=c++17.

This leads to a bunch of failures when running libc++ tests with GCC 5
or GCC 6. This patch adds -std=c++17 to the list of flags that are
discarded for GCC < 7 by lit's language dialect inference.

Thanks to Bryce Adelstein Lelbach for the patch.

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

llvm-svn: 366700
2019-07-22 16:24:48 +00:00
Marshall Clow 6e9dfc499d Update c++2a status page with post-Cologne information
llvm-svn: 366696
2019-07-22 15:13:14 +00:00
Louis Dionne 4e8c8aa959 [libc++] Mark libcpp_deallocate.sh.cpp as UNSUPPORTED instead of XFAIL on AppleClang 9
Some minor versions of AppleClang 9 appear not to fail the test. It's
such a mess that the only sane thing to do is to mark the test as
UNSUPPORTED.

llvm-svn: 366606
2019-07-19 19:41:40 +00:00
Louis Dionne a3c83b7511 Revert "[libc++] Integrate the PSTL into libc++"
This reverts r366593, which caused unforeseen breakage on the build bots.
I'm reverting until the problems have been figured out and fixed.

llvm-svn: 366603
2019-07-19 18:52:46 +00:00
Louis Dionne 3b1ef58128 [libc++] Allow passing additional CMake arguments in macOS trunk CI script
llvm-svn: 366601
2019-07-19 18:47:00 +00:00
Louis Dionne a5bd48939c [libc++] Use _EnableIf instead of std::enable_if in deduction guides for map and set
llvm-svn: 366594
2019-07-19 17:13:39 +00:00
Louis Dionne 910323e667 [libc++] Integrate the PSTL into libc++
Summary:
This commit allows specifying LIBCXX_ENABLE_PARALLEL_ALGORITHMS when
configuring libc++ in CMake. When that option is enabled, libc++ will
assume that the PSTL can be found somewhere on the CMake module path,
and it will provide the C++17 parallel algorithms based on the PSTL
(that is assumed to be available).

The commit also adds support for running the PSTL tests as part of
the libc++ test suite.

Reviewers: rodgert, EricWF

Subscribers: mgorny, christof, jkorous, dexonsmith, libcxx-commits, mclow.lists, EricWF

Tags: #libc

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

llvm-svn: 366593
2019-07-19 17:02:42 +00:00
Louis Dionne 9e6a42a185 [libc++] Add missing %link_flags to .sh.cpp test
Without the link flags, the test always fails on Linux. For some reason,
however, it works on Darwin -- which is why it wasn't caught at first.

llvm-svn: 366579
2019-07-19 14:01:48 +00:00
Louis Dionne e068c7463f [libc++] Fix link error with _LIBCPP_HIDE_FROM_ABI_PER_TU and std::string
Summary:
This is effectively a revert of r344616, which was a partial fix for
PR38964 (compilation of <string> with GCC in C++03 mode). However, that
configuration is explicitly not supported anymore and that partial fix
breaks compilation with Clang when per-TU insulation is provided.

PR42676
rdar://52899715

Reviewers: mclow.lists, EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

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

llvm-svn: 366567
2019-07-19 11:52:55 +00:00
Louis Dionne e1eabcdfad [libc++] Add C++17 deduction guides for std::function
Summary: http://llvm.org/PR39606

Reviewers: Quuxplusone

Subscribers: christof, dexonsmith, libcxx-commits

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

llvm-svn: 366484
2019-07-18 19:50:56 +00:00
Hans Wennborg 8f5b44aead Bump the trunk version to 10.0.0svn
and clear the release notes.

llvm-svn: 366427
2019-07-18 11:51:05 +00:00
Louis Dionne 66412df94f [libc++] XFAIL a test that does not behave properly on older Clang
rdar://53015486

llvm-svn: 366359
2019-07-17 18:54:29 +00:00
Louis Dionne e559f62506 [libcxx] Rejigger test for destroying delete feature-test macros
In r361572, we introduced library support for C++20 destroying delete
and decided to only define the library feature-test macro when the
compiler supports the underlying language feature. This patch reworks
the tests to mirror that.

llvm-svn: 366263
2019-07-16 21:13:40 +00:00
Louis Dionne 12154ee8f1 [libc++] Add missing UNSUPPORTED for CTAD tests
The tests for unordered_set and unordered_multiset were missing UNSUPPORTED
markup for Apple Clang 9.1, which is still being used on some CI bots.

llvm-svn: 366259
2019-07-16 20:41:33 +00:00
Zoe Carver a17b1aed6a Add contains method to associative containers. This patch implements P0458R2, adding contains to map, multimap, unordered_map, unordered_multimap, set, multiset, unordered_set, and unordered_multiset.
llvm-svn: 366170
2019-07-16 03:21:01 +00:00
Louis Dionne dfcd4384cb [libc++] Implement P0433: deduction guides for <unordered_map>
Thanks to Arthur O'Dwyer for the patch.

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

llvm-svn: 366124
2019-07-15 20:06:01 +00:00
Eric Fiselier c5d7b0c454 Constrain workaround to avoid affecting other buildbots
llvm-svn: 366122
2019-07-15 19:53:42 +00:00
Eric Fiselier 4066978cb7 Improve compile time of variant.
In particular, improve the compile time of the overload set builder
that variant uses to determine which alternative to construct.

Instead of having the __overload type construct itself recursively,
this patch uses a flat construction for the overload set.

llvm-svn: 366033
2019-07-14 21:29:39 +00:00
Eric Fiselier 3c0e2bb0cb Add test for variant construction with duplicate types.
llvm-svn: 366032
2019-07-14 20:59:51 +00:00
Eric Fiselier aae0cb67ed Cleanup whitespace in <variant>. NFC.
llvm-svn: 366026
2019-07-14 18:31:55 +00:00
Eric Fiselier 273857d1ea Harden variant test added in r366022
The test was brittle since it only went boom for one specific type, when
really it should go boom for all of them.

llvm-svn: 366025
2019-07-14 18:30:34 +00:00
Eric Fiselier 194b337f33 Avoid eager template instantiation caused by the variant narrowing checks.
The standard disallows narrowing conversions when constructing a variant.
This is checked by attempting to perform braced initialization of the
destination type from the argument type. However, braced initialization
can force the compiler (mostly clang) to eagerly instantiate the
constructors of the destintation type -- which can lead to errors in
a non-immediate context.

However, as variant is currently specified, the narrowing checks only
observably apply when the destination type is arithmetic. Meaning we can
skip the check for class types. Hense avoiding the hard errors.

In order to cause fewer build breakages, this patch avoids the narrowing
check except when the destination type is arithmetic.

llvm-svn: 366022
2019-07-14 18:21:15 +00:00
Eric Fiselier 882fdf68b7 Fix non-conformance it `std::tuple`.
Previously we implemented all one trillion tuple-like constructors using
a single generic overload. This worked fairly well, except that it
differed in behavior from the standard version because it didn't
consider both T&& and T const&. This was observable for certain
types.

This patch addresses that issue by splitting the generic constructor
in two. We now provide both T&& and T const& versions of the
tuple-like constructors (sort of).

llvm-svn: 365973
2019-07-12 23:01:48 +00:00
Eric Fiselier 128af31595 Add option to disable variant narrowing conversion changes.
The paper P0608R3 - "A sane variant converting constructor" disallows
narrowing conversions in variant. It was meant to address this
surprising problem:

  std::variant<std::string, bool> v = "abc";
  assert(v.index() == 1); // constructs a bool.

However, it also disables every potentially narrowing conversion. For
example:

  variant<unsigned> v = 0; // ill-formed
  variant<string, double> v2 = 42; // ill-formed (int -> double narrows)

These latter changes break code. A lot of code. Within Google it broke
on the order of a hundred thousand target with thousands of root causes
responsible for the breakages.

Of the breakages related to the narrowing restrictions, none of them
exposed outstanding bugs. However, the breakages caused by boolean
conversions (~13 root causes), all but one of them were bugs.

For this reasons, I am adding a flag to disable the narrowing conversion
changes but not the boolean conversions one.

One purpose of this flag is to allow users to opt-out of breaking changes
in variant until the offending code can be cleaned up. For non-trivial
variant usages the amount of cleanup may be significant.

This flag is also required to support automated tooling, such as
clang-tidy, that can automatically fix code broken by this change.
In order for clang-tidy to know the correct alternative to construct,
it must know what alternative was being constructed previously, which
means running it over the old version of std::variant.

Because this change breaks so much code, I will be implementing the
aforementioned clang-tidy check in the very near future.

Additionally I'm plan present this new information to the committee so they can
re-consider if this is a breaking change we want to make.

I think libc++ should very seriously consider pulling this change
before the 9.0 release branch is cut. But that's a separate discussion
that I will start on the lists.

For now this is the minimal first step.

llvm-svn: 365960
2019-07-12 21:32:11 +00:00
Louis Dionne 189639b1c3 [libc++] Add XFAILs for CTAD tests on older compilers
llvm-svn: 365923
2019-07-12 17:30:57 +00:00
Eric Fiselier d49103bd2f Mark destroying delete test as UNSUPPORTED with clang 7
llvm-svn: 365856
2019-07-12 01:16:08 +00:00
Eric Fiselier a780216fb3 Tolerate import errors in "not.py" implementation
llvm-svn: 365855
2019-07-12 01:13:05 +00:00
Marshall Clow f3b851f0b8 Reorganize the 'bit' header to make most of the facilities available for internal use pre-C++20. NFC for external users
llvm-svn: 365854
2019-07-12 01:01:55 +00:00
Eric Fiselier 02fdc51c04 Add another buildbot username to the workaround list
llvm-svn: 365848
2019-07-12 00:16:38 +00:00
Eric Fiselier ce13f67618 Attempt to override broken buildbot config for libc++abi.
The buildbots were changed to pass -DLIBCXX_CXX_ABI=libcxxabi, but
they don't provide an include path for the library, so cxxabi.h is
never found while building libc++.

This is a temporary change until the buildbots are updated or until
D63883 lands in a form that unbreaks the bots

llvm-svn: 365847
2019-07-12 00:02:49 +00:00
Eric Fiselier 41798c05cd Fix memory leak in set and map.
When assigning an initializer list into set/map, libc++ would
leak memory if the initializer list contained equivalent keys
because we failed to check if the insertion was successful.

llvm-svn: 365840
2019-07-11 23:13:38 +00:00
Louis Dionne 296a80102a [libc++] Implement deduction guides for <unordered_set>
Thanks to Arthur O'Dwyer for the patch.
Differential Revision: https://reviews.llvm.org/D58617

llvm-svn: 365788
2019-07-11 15:16:39 +00:00
Saleem Abdulrasool 97d6fcce4e build: use multiple `install` rather than building up a list
Rather than building up a list to iterate over later, just create multiple
install commands based on the configuration. This makes it easier to see what
is getting installed and allows for the install handling to be centralised. NFC

llvm-svn: 365562
2019-07-09 21:43:01 +00:00
Vitaly Buka a9d5c186e2 Revert "[libc++] Take 2: Do not cleverly link against libc++abi just because it happens to be there"
r365326 still breaks bots:
http://lab.llvm.org:8011/builders/netbsd-amd64/builds/20712/steps/ninja%20build%20local/logs/stdio
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/39477/steps/test%20tsan%20in%20debug%20compiler-rt%20build/logs/stdio

And probably others

This reverts commit 945b9ec069.

llvm-svn: 365359
2019-07-08 17:46:23 +00:00
Louis Dionne 945b9ec069 [libc++] Take 2: Do not cleverly link against libc++abi just because it happens to be there
Summary:
Otherwise, when libcxxabi is not an enabled project in the monorepo, we
get a link error because we try to link against non-existent cxxabi_shared.

More generally, we shouldn't change the behavior of the build based on
implicit things like whether a file happens to be at a specific path or
not.

This is a re-application of r365222 that had been reverted in r365233
because it broke the build bots. However, the build bots now specify
explicitly what ABI library they want to use (libc++abi), so this
commit should now be OK to merge.

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

llvm-svn: 365326
2019-07-08 14:49:35 +00:00
Marshall Clow f814dcbafb Make forward_list::remove/remove_if/unique all return void before C++20; undoes that bit of D58332. Thanks to Mikhail Maltsev for pointing this out
llvm-svn: 365290
2019-07-08 03:45:28 +00:00
Eric Fiselier 8cedf04a6c Make ~mutex and ~condition_variable trivial on Windows.
The implementations of __libcpp_mutex_destroy and __libcpp_condvar_destroy
are already NOPs, so this optimization is safe to perform.

See r365273 and PR27658 for more information.

llvm-svn: 365281
2019-07-07 17:24:03 +00:00
Eric Fiselier 8baf83839e Fix PR27658 - Make ~mutex trivial when possible.
Currently std::mutex has a constexpr constructor, but a non-trivial
destruction.

The constexpr constructor is required to ensure the construction of a
mutex with static storage duration happens at compile time, during
constant initialization, and not during dynamic initialization.
This means that static mutex's are always initialized and can be used
safely during dynamic initialization without the "static initialization
order fiasco".

A trivial destructor is important for similar reasons. If a mutex is
used during dynamic initialization it might also be used during program
termination. If a static mutex has a non-trivial destructor it will be
invoked during termination. This can introduce the "static
deinitialization order fiasco".

Additionally, function-local statics emit a guard variable around
non-trivially destructible types. This results in horrible codegen and
adds a runtime cost to every call to that function. non-local static's
also result in slightly worse codegen but it's not as big of a problem.

Example codegen can be found here: https://goo.gl/3CSzbM

Note: This optimization is not safe with every pthread implementation.
Some implementations allocate on the first call to pthread_mutex_lock
and free the allocation in pthread_mutex_destroy.

Also, changing the triviality of the destructor is not an ABI break.
At least to the best of my knowledge :-)

llvm-svn: 365273
2019-07-07 01:20:54 +00:00
Marshall Clow 1ab3fe8a7a Make list::remove/remove_if/unique all return void before C++20; undoes that bit of D58332. Thanks to Mikhail Maltsev for pointing this out
llvm-svn: 365261
2019-07-06 06:10:03 +00:00
Zoe Carver 28e0187175 This patch makes swap functions constexpr. Both swap overloads, swap_ranges and iter_swap are updated (with tests).
llvm-svn: 365238
2019-07-05 20:13:34 +00:00
Louis Dionne 51de516486 Revert "[libc++] Do not cleverly link against libc++abi just because it happens to be there"
This reverts r365222, which broke the libc++ build bots.

llvm-svn: 365233
2019-07-05 18:44:25 +00:00
Louis Dionne 4ba29e5fbe [libc++] Do not cleverly link against libc++abi just because it happens to be there
Summary:
Otherwise, when libcxxabi is not an enabled project in the monorepo, we
get a link error because we try to link against non-existent cxxabi_shared.

More generally, we shouldn't change the behavior of the build based on
implicit things like whether a file happens to be at a specific path or
not.

Reviewers: EricWF

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

Tags: #libc

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

llvm-svn: 365222
2019-07-05 17:06:23 +00:00
Saleem Abdulrasool bce9d8b138 docs: add documentation for `LIBCXX_INCLUDE_TESTS`
Add some missing documentation for the `LIBCXX_INCLUDE_TESTS` option.

Patch by Jean Heyd Meneide!

llvm-svn: 365154
2019-07-04 19:08:16 +00:00
Marshall Clow 7afe9ea96f Add tests for regex_match ambiguity (aka LWG2273). NFC. Reviewed as https://reviews.llvm.org/D63051
llvm-svn: 365080
2019-07-03 20:32:35 +00:00
Eric Fiselier f1807a7df6 Fix tuple's conditionally explicit constructors for very weird user
types.

It seems some people like to write types that can explicitly convert
to anything, but cannot be used to explicitly construct anything.

This patch makes tuple tolerate such types, as is required
by the standard.

llvm-svn: 365074
2019-07-03 19:21:40 +00:00
Louis Dionne 1c478d6e85 [libc++] Update availability markup for Filesystem on Apple platforms
llvm-svn: 365068
2019-07-03 18:29:02 +00:00
Marshall Clow 2a622b30e3 Update status of papers for upcoming WG21 meeting. NFC
llvm-svn: 364885
2019-07-02 03:23:06 +00:00
Marshall Clow bd7f84a482 Use new '__libcpp_is_constant_evaluated' call to remove an '#ifdef' from the bit code. NFC
llvm-svn: 364884
2019-07-02 03:21:16 +00:00
Marshall Clow 745379a0af Mark the newly added '__libcpp_is_constant_evaluated' as 'inline', since it can be included multiple times by multiple headers, and we don't want 'duplicate definition' errors.
llvm-svn: 364879
2019-07-02 00:20:06 +00:00
Marshall Clow 491ddc00ae Add a private call '__libcpp_is_constant_evaluated' which 'works' for old language versions and w/o any compiler support. 'Working', in this case, means that it returns false in those cases.
llvm-svn: 364873
2019-07-01 23:16:46 +00:00
Marshall Clow fc61db5a3e Update status for bit operations
llvm-svn: 364863
2019-07-01 23:00:34 +00:00
Marshall Clow a5c3485a58 Bit Operations: P0556, P0553 and P1355. Reviewed as: https://reviews.llvm.org/D51262
llvm-svn: 364862
2019-07-01 23:00:32 +00:00
Eric Fiselier d1523f7a8c Ensure bitset's string constructor doesn't poison the overload set.
llvm-svn: 364842
2019-07-01 19:59:34 +00:00
Marshall Clow 24edf8ef4b Implement P0646R1: Erase-Like Algorithms Should Return size_type. Reviewed as https://reviews.llvm.org/D58332, and then updated because I rewrote a couple of those routines to eliminate some UB. Thanks to Zoe for tghe patch.
llvm-svn: 364840
2019-07-01 19:22:00 +00:00
Marshall Clow 3c125fe821 Implement LWG2221: 'Formatted output for nullptr_t' Reviewed as: https://reviews.llvm.org/D63053
llvm-svn: 364802
2019-07-01 16:20:25 +00:00
Bruce Mitchener 4603460a39 __threading_support: Remove (void) in favor of ().
Summary:
This fixes a clang-tidy warning when building something that uses
this file.

Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

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

llvm-svn: 364799
2019-07-01 16:18:38 +00:00
Bruce Mitchener ba41d3b1fd Fix -Wdouble-promotion warnings.
Reviewers: mclow.lists

Subscribers: christof, ldionne, cfe-commits, libcxx-commits

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

llvm-svn: 364798
2019-07-01 16:13:31 +00:00
Billy Robert O'Neal III 0384a78054 [libcxx] [test] Add void cast to result of compare_exchange_weak to suppress [[nodiscard]].
llvm-svn: 364732
2019-07-01 08:09:02 +00:00
Marshall Clow 954014a0fa Add a missing '__uncvref_t' to the SFINAE constraints for optional's assignment operator. Fixes PR38638. Thanks to Jonathan Wakely for the report
llvm-svn: 364574
2019-06-27 18:40:55 +00:00
Marshall Clow 7d8274d54d Followup to revision 364545: Turns out that clang issues different errors for C++11 vs c++2a, so I tweaked the 'expected-error' bits that I added to match either of them.
llvm-svn: 364554
2019-06-27 15:37:31 +00:00
Marshall Clow 9318430237 Provide hashers for string_view only if they are using the default char_traits. Seen on SO: test/std/strings/string.view/string.view.hash/char_type.hash.fail.cpp
llvm-svn: 364545
2019-06-27 14:18:32 +00:00
Eric Fiselier ae9e42f614 Revert "Change the ABI version and ABI namespace to be `_LIBCPP_VERSION`"
There are some suspicious bot failures that I want to ensure aren't
caused by this patch.

I'll recommit tomorrow.

llvm-svn: 364363
2019-06-26 00:05:14 +00:00
Eric Fiselier 1fa0f4b942 Change the ABI version and ABI namespace to be `_LIBCPP_VERSION`
when _LIBCPP_ABI_UNSTABLE is defined.

User defined _LIBCPP_ABI_NAMESPACE will still be respected,
but the default version namespace in unstable mode will be the libc++ version
(Currently '__9000').

Previously  `_LIBCPP_ABI_VERSION` and `_LIBCPP_ABI_NAMESPACE` were
`1` and `__1` respectively, whuch conflicted with the stable ABI

llvm-svn: 364354
2019-06-25 22:13:39 +00:00
Richard Smith 4bd4acc969 Fix test failures due to modified wording in Clang diagnostics.
llvm-svn: 364241
2019-06-24 22:01:03 +00:00
Richard Smith 66e6e37447 Fix test failures when using a custom ABI namespace.
llvm-svn: 364239
2019-06-24 21:46:05 +00:00
Michal Gorny a5bb7b6c20 [libcxx] [test] Read files as bytestrings to fix py3 encoding issues
Use binary mode to read test files in libcxx LibcxxTestFormat class.
This ensures that tests are read correctly independently of encoding,
and therefore fixes UnicodeDecodeError when file is opened in Python 3
that defaults to pure ASCII encoding.

Technically this could be also fixed via conditionally appending
encoding argument when opening the file in Python 3.  However, since
the code in question only searches for fixed ASCII substrings reading
it in binary mode is simpler and more universal.

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

llvm-svn: 364170
2019-06-24 09:40:33 +00:00
Eric Fiselier fb2bd4a939 Use C++11 implementation of unique_ptr in C++03.
llvm-svn: 364161
2019-06-23 20:47:21 +00:00
Eric Fiselier 3359a17b3a Apply new meta-programming traits throughout the library.
The new meta-programming primitives are lower cost than the old versions. This patch removes those old versions and switches libc++ to use the new ones.

llvm-svn: 364160
2019-06-23 20:28:29 +00:00