Commit Graph

5618 Commits

Author SHA1 Message Date
Petr Hosek 81f433b48c [runtimes] Move libunwind, libc++abi and libc++ to lib/$target/c++ and include/c++
This change is a consequence of the discussion in "RFC: Place libs in
Clang-dedicated directories", specifically the suggestion that
libunwind, libc++abi and libc++ shouldn't be using Clang resource
directory. Tools like clangd make this assumption, but this is
currently not true for the LLVM_ENABLE_PER_TARGET_RUNTIME_DIR build.
This change addresses that by moving the output of these libraries to
lib/$target/c++ and include/c++ directories, leaving resource directory
only for compiler-rt runtimes and Clang builtin headers.

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

llvm-svn: 361432
2019-05-22 21:08:33 +00:00
Louis Dionne c44cd1e4ed [libcxx][test] Fix order checking in some more unordered_multimap tests
Some tests assume that iteration through an unordered multimap elements
will return them in the same order as at the container creation. This
assumption is not true since the container is unordered, so that no
specific order of elements is ever guaranteed for such container. This
patch is a continuation of D54838 and introduces checks verifying that
any iteration will return elements exactly from a set of valid values
and without repetition, but in no particular order.

Thanks to Andrey Maksimov for the patch.

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

llvm-svn: 361414
2019-05-22 18:10:32 +00:00
Eric Fiselier f8d2d87fbb Speculative fix for std stream destruction order on Windows.
The MSVC CRT uses TLS storage to implement per-thread locales.
This storage gets freed during program termination, and if we attempt
to do any io operations (like flushing the std streams) after this occurs
the program may abort.

This patch is a speculative fix for that issue.

The fix tries forcing the initialization of the locale TLS before
initializing the std streams. This should mean that the TLS is freed
after we destroy the streams.

llvm-svn: 361348
2019-05-22 03:45:49 +00:00
Marshall Clow d75a0450ad Ensure that hash<basic_string> uses char_traits. Fixes PR#41876. Reviewed as https://reviews.llvm.org/D61954
llvm-svn: 361201
2019-05-20 21:56:51 +00:00
Eric Fiselier 236317d216 Fix missing std:: qualifier in __gnu_cxx::hash_map in C++03
llvm-svn: 361075
2019-05-17 20:59:57 +00:00
Eric Fiselier 549ddae58f Remove `using namespace std;` in __gnu_cxx namespace.
The `using namespace std;` opens us up to ambiguity
when any of the std:: names are also present in the global namespace.
Instead we should properly qualify names we use from std::.

llvm-svn: 361074
2019-05-17 20:46:00 +00:00
Marshall Clow 402ca78c43 Improve the test coverage for std::is_base_of
llvm-svn: 360911
2019-05-16 15:56:26 +00:00
Michal Gorny 87ae6bf80b [libc++] [test] Use std::nextafter() instead of std::nexttoward()
Use std::nextafter() instead of std::nexttoward() in midpoint tests.
In the context of this test, this should not cause any difference.
Since nexttowardl() is not implemented on NetBSD 8, the latter function
combined with 'long double' type caused test failure.  nextafterl() does
not have this problem.

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

llvm-svn: 360673
2019-05-14 13:56:20 +00:00
Brian Cain 9423ba8121 [libcxx] teach type_traits test about long uint32_t
Patch by Ben Craig.

llvm-svn: 360590
2019-05-13 15:41:18 +00:00
Marshall Clow 98c7c4fad2 Add a test for LWG#3204 and mark it as complete. Reviewed as https://reviews.llvm.org/D61829 Thanks to Zoe for the patch.
llvm-svn: 360586
2019-05-13 14:56:02 +00:00
Eric Fiselier 7d402732c2 force the bots to cycle
llvm-svn: 360306
2019-05-09 02:34:37 +00:00
Marshall Clow 51497fb8b3 Mark private function __sign as constexpr.
llvm-svn: 360167
2019-05-07 16:07:24 +00:00
Eric Fiselier ac6843cea2 Remove unneeded <algorithm> include in cmath.
It's a remnant from an earlier version of the lerp change
and is unneeded.

llvm-svn: 360098
2019-05-06 23:14:31 +00:00
Petr Hosek 741f52ca62 [libcxx] Don't use -fvisibility-global-new-delete-hidden when not defining them
When builing the hermetic static library, the compiler switch
-fvisibility-global-new-delete-hidden is necessary to get the new and
delete operator definitions made correctly. However, when those
definitions are not included in the library, then this switch does harm.
With lld (though not all linkers) setting STV_HIDDEN on SHN_UNDEF
symbols makes it an error to leave them undefined or defined via dynamic
linking that should generate PLTs for -shared linking (lld makes this a
hard error even without -z defs). Though leaving the symbols undefined
would usually work in practice if the linker were to allow it (and the
user didn't pass -z defs), this actually indicates a real problem that
could bite some target configurations more subtly at runtime. For
example, x86-32 ELF -fpic code generation uses hidden visibility on
declarations in the caller's scope as a signal that the call will never
be resolved to a PLT entry and so doesn't have to meet the special ABI
requirements for PLT calls (setting %ebx). Since these functions might
actually be resolved to PLT entries at link time (we don't know what the
user is linking in when the hermetic library doesn't provide all the
symbols itself), it's not safe for the compiler to treat their
declarations at call sites as having hidden visibility.

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

llvm-svn: 360003
2019-05-06 01:22:28 +00:00
Nico Weber 30649ce09b Mark is_trivially_destructible as unsupported with apple-clang-9
See discussion on https://reviews.llvm.org/D48292

llvm-svn: 359907
2019-05-03 17:26:17 +00:00
Casey Carter b574e11217 [libc++][test] Remove non-portable assumption that thread's constructor allocates with ::new
Drive-by:
* Fix potential race between check and update of `throw_one` in `operator new`
* Fix latent bug in `operator delete`, which shouldn't decrement `outstanding_new` when passed a null pointer
* Specifically catch the expected `bad_alloc` in `main` instead of `...`

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

llvm-svn: 359827
2019-05-02 21:19:41 +00:00
Louis Dionne 223ed705d0 [libc++][CMake] Link against libSystem on Apple platforms
Instead of manually linking against libm/librt/libpthread, we should be
linking against libSystem on Apple platforms, and only that. libm and
libpthread are symlinks to libSystem anyway.

llvm-svn: 359808
2019-05-02 17:43:48 +00:00
Petr Hosek fa3c328c51 [gn] Support for building libc++
This change introduces support for building libc++. The library
build should be complete, but not all CMake options have been
replicated in GN. We also don't support tests yet.

We only support two stage build at the moment.

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

llvm-svn: 359806
2019-05-02 17:29:41 +00:00
Brian Cain 9d744bcde9 [libcxx] cmake - guard list remove
REMOVE_ITEM fails if CMAKE_REQUIRED_LIBRARIES is empty on some
versions of cmake.

llvm-svn: 359755
2019-05-02 03:49:50 +00:00
Dan Albert dfa7af5b6b Add missing locale requirement to test.
Linux is failing even though the test runner does report this locale
is available, but the test still isn't expected to work on platforms
without the locale (like Android).

llvm-svn: 359726
2019-05-01 21:02:32 +00:00
Dan Gohman 3efd6e37e4 [WebAssembly] WASI support for libcxx
This adds explicit support for the WASI platform to libcxx.

WASI libc uses some components from musl, however it's not fully compatible
with musl, so we're planning to stop using _LIBCPP_HAS_MUSL_LIBC and
customize for WASI libc specifically.

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

Reviewers: sbc100, ldionne
llvm-svn: 359703
2019-05-01 16:47:30 +00:00
Marshall Clow ccbe567f46 Get rid of a bunch of 'unused variable' warnings in test when run with debug_level set. NFC
llvm-svn: 359672
2019-05-01 11:25:58 +00:00
Petr Hosek f80c4b6348 [libcxx] Move CMake file to src, avoid using globs
This addresses the longstanding FIXME and makes libc++ build more
similar to other runtimes.

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

llvm-svn: 359656
2019-05-01 06:40:36 +00:00
Marshall Clow 3740ca1e7f Fix a bunch of unordered container tests that were failing when _LIBCPP_DEBUG was set.
llvm-svn: 359642
2019-05-01 01:52:51 +00:00
Eric Fiselier 71aa67506b Support overaligned types in `aligned_storage`.
Summary:
The current implementation of aligned storage was written before we had `alignas`, so it used a list of builtin types to force the alignment. But this doesn't work overaligned requests.

This patch adds a fallback case supporting over-alignment. It only affects case that were previously ill-formed.

Reviewers: rsmith, ldionne, dlj, mclow.lists

Reviewed By: mclow.lists

Subscribers: mclow.lists, dexonsmith, libcxx-commits

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

llvm-svn: 359596
2019-04-30 18:44:45 +00:00
Louis Dionne 68924e6be7 [libc++][CMake] Refactor how we link against system libraries
Summary:
Instead of populating the global LIBCXX_LIBRARIES, we use the link-time
dependency management built into CMake to propagate link flags. This
leads to a cleaner and easier-to-follow build.

Reviewers: phosek, smeenai, EricWF

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

Tags: #libc

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

llvm-svn: 359571
2019-04-30 15:44:19 +00:00
Marshall Clow 39084db328 Implement LWG 2960: nonesuch is insufficiently useless
llvm-svn: 359526
2019-04-30 00:54:38 +00:00
Marshall Clow fafbddc275 Mark LWG#2977 as 'Nothing to do'. NFC
llvm-svn: 359525
2019-04-30 00:54:26 +00:00
Marshall Clow 8a02f8d928 Add tests specifically for LWG2164. We already did this; but now we have tests. NFC
llvm-svn: 359458
2019-04-29 15:38:07 +00:00
Eric Fiselier a1f420de8c Fix permission error while running bots
llvm-svn: 359405
2019-04-28 17:00:46 +00:00
Eric Fiselier 290a3a3648 attempt to unbreak build bots
llvm-svn: 359404
2019-04-28 16:42:49 +00:00
Eric Fiselier 2f5f9a159b Attempt to switch to auto-scaling bots
llvm-svn: 359403
2019-04-28 15:54:50 +00:00
Marshall Clow c29db2d83e Add '_LIBCPP_ASSERT(ready())' to several match_results method that have this precondtion. Fix several tests which did not honor this precondition. Thanks to Andrey Maksimov for pointing this out.
llvm-svn: 359324
2019-04-26 17:10:03 +00:00
Louis Dionne f30f261dc5 [libc++] Relax libc++-only test on regex_constants
The standard requires the following for the std::regex_constants::error_type
values: "The type error_type is an implementation-defined enumerated type."

The values of this enumerated type are not required to be non-zero.
This patch makes such checks in tests libc++-specific to let the tests
pass for other conforming implementations.

Thanks to Andrey Maksimov for the patch.
Differential Revision: https://reviews.llvm.org/D61195

llvm-svn: 359320
2019-04-26 16:46:37 +00:00
Chandler Carruth dd0a2e4461 Fix r359229 which tried to fix r359159...
When r359229 added noexcept to the declaration of `~mutex`, it didn't
add it to the definition which caused -Wimplicit-exception-spec-mismatch
to fire. This just adapts the definition to agree with the declaration.

llvm-svn: 359275
2019-04-26 05:04:33 +00:00
Eric Fiselier eea2287f83 add tuple_cat test for const T
llvm-svn: 359256
2019-04-26 01:06:32 +00:00
Eric Fiselier 7e528bc4ce Fix return type of std::tuple_cat.
When the arguments to tuple cat were const, the const was incorrectly
propagated into the type of the resulting tuple. For example:

const std::tuple<int> t(42);
auto r = std::tuple_cat(t, t);
// Incorrect! should be std::tuple<int, int>.
static_assert(is_same_v<decltype(r), std::tuple<const int, const int>>);

llvm-svn: 359255
2019-04-26 01:02:18 +00:00
Richard Smith de329354aa Remove incorrect explicit instantiation declarations for valarray
libc++ ABI v1 provides three valarray symbols as part of the shared library:

valarray<size_t>::valarray(size_t)
valarray<size_t>::~valarray()
valarray<size_t>::resize(size_t, size_t)

The first two of these are intended to be removed in V2 of the ABI: they're
attributed _LIBCPP_HIDE_FROM_ABI_AFTER_V1, and  it appears that the intention
is that these symbols from the library are not used even when building using
the V1 ABI. However, there are explicit instantiation declarations for all
three symbols in the header, which are not correct as we do not intend to find
an instantiation of these functions that is provided elsewhere.

(A recent change to clang to properly diagnose explicit instantiation
declarations of internal linkage functions -- required by [temp.explicit]p13 --
had to be rolled back because it diagnosed these explicit instantiations.)

Remove the explicit instantiation declarations, and remove the explicit
instantiation definitions for V2 of the libc++ ABI onwards.

llvm-svn: 359243
2019-04-25 21:31:58 +00:00
Richard Smith ae62727a28 Remove libc++ checks and workarounds for unsupported old versions of GCC (<4.9).
Differential Revision: https://reviews.llvm.org/D61107

llvm-svn: 359232
2019-04-25 20:02:10 +00:00
Richard Smith 65d4d5e9e7 Fix buildbot failures after r359159.
std::mutex was not actually is_nothrow_default_constructible in C++98/C++03,
because the variable declaration

  std::mutex M;

... could throw an exception from the mutex destructor. Fix it by marking the
destructor as non-throwing. This has no effect in C++11 onwards, because
destructors are non-throwing by default in those language modes.

llvm-svn: 359229
2019-04-25 20:00:06 +00:00
Martin Storsjo 2bbb7feda8 Set _LIBCPP_DLL_VIS on _LIBCPP_EXTERN_TEMPLATE_TYPE_VIS in MinGW mode
Contrary to MSVC, MinGW compilers wants the dllexport attribute on
the declaration of an explicit template instantiation, not on the
definition.

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

llvm-svn: 359227
2019-04-25 19:46:28 +00:00
Casey Carter 413732354d [libc++][test] Fix noexcept assertions in variant's get tests
All constant expressions are non-potentially-throwing in C++14, but that is *not* the case in C++17. Change these tests of the `variant`-flavored overloads of `std::get` to expect the correct behavior when the compiler is not GCC or is GCC 9+.

Credit to Jonathan Wakely for providing an improved version of my initial change that validates the incorrect behavior on GCC < 9 as well as validating the correct behavior on other compilers.

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

llvm-svn: 359220
2019-04-25 18:36:29 +00:00
Marshall Clow b0e2daf64b Implement 'lerp'; which is the last bit of P0811. Mark that paper as complete.
llvm-svn: 359211
2019-04-25 17:44:18 +00:00
Marshall Clow d3d0ecbfd5 Implement midpoint for floating point types. Reviewed as https://reviews.llvm.org/D61014.
llvm-svn: 359184
2019-04-25 12:11:43 +00:00
Marshall Clow 07161d6de3 Update test to better check for the non-constexpr-ness of a move constructor. Fixes PR#41577.
llvm-svn: 359162
2019-04-25 02:12:51 +00:00
Richard Smith d8b01111a0 Use modern type trait implementations when available.
Teach libcxx to stop using various deprecated __has_* type traits, in favor of
the ("modern", C++11 era) __is_* type traits.

This is mostly just a simplification, but fixes at least one bug: _Atomic T
should be considered trivially-destructible, but is not considered to be POD by
Clang, and __has_trivial_destructor is specified in the GCC documentation as
returning false for non-POD non-class types.

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

llvm-svn: 359159
2019-04-25 00:35:01 +00:00
Eric Fiselier 2fc5a786be Add std::is_constant_evaluated.
Clang recently added __builtin_is_constant_evaluated() and GCC 9.0
has it as well.

This patch adds support for it in libc++.

llvm-svn: 359119
2019-04-24 17:54:25 +00:00
Marshall Clow bce10f159c Make the test object callable. libstdc++'s bind checks that (libc++ currently does not). Thanks to Jonathan Wakely for the fix.
llvm-svn: 359108
2019-04-24 15:33:55 +00:00
Marshall Clow a14b76707c Fix a one more compare test that assumed -1/0/1 instsad of <0/0/>0. NFC.
llvm-svn: 359106
2019-04-24 15:26:45 +00:00
Marshall Clow 98b15320e4 Fix a couple of tests that assumed that compare retunred -1/0/1 instead of <0/0/>0. Thanks to Jonathan Wakely for the report.
llvm-svn: 359104
2019-04-24 15:14:14 +00:00
Marshall Clow c564c16308 Add an any_cast test for array types. Thanks to Jonathan Wakely for the suggestion.
llvm-svn: 359085
2019-04-24 12:11:12 +00:00
Eric Fiselier 6886f1e39b Avoid name conflict with kernel headers
llvm-svn: 359080
2019-04-24 09:43:44 +00:00
Petr Hosek 80b578c732 [libcxx] Use relative path for libc++ library when generating script
This addresses the issue introduced in D60309 which leads to linker
scripts being generated with absolute paths.

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

llvm-svn: 359045
2019-04-23 22:55:28 +00:00
Eric Fiselier 433eecadee Fix namespace name conflict with GCC
llvm-svn: 359023
2019-04-23 18:23:33 +00:00
Eric Fiselier 1670772adc Fix implementation of ::abs and std::abs LWG 2192.
Summary:
All overloads of `::abs` and `std::abs` must be present in both `<cmath>` and `<cstdlib>`. This is problematic to implement because C defines `fabs` in `math.h` and `labs` in `stdlib.h`. This introduces a circular dependency between the two headers. 

This patch implements that requirement by moving `abs` into `math.h` and making `stdlib.h` include `math.h`. In order to get the underlying C declarations from the "real" `stdlib.h` inside our `math.h` we need some trickery. Specifically we need to make `stdlib.h` include next itself.

Suggestions for a cleaner implementation are welcome.

Reviewers: mclow.lists, ldionne

Reviewed By: ldionne

Subscribers: krytarowski, fedor.sergeev, dexonsmith, jdoerfert, jsji, libcxx-commits

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

llvm-svn: 359020
2019-04-23 18:01:58 +00:00
Louis Dionne d524fe5b3a [libc++] Remove redundant conditionals for Apple platforms
Summary:
In a bunch of places, we used to check whether LIBCXX_BUILDING_LIBCXXABI
is defined OR we're building for an Apple platform. This used to
be necessary in a time when Apple's build script did NOT define
LIBCXX_BUILDING_LIBCXXABI. However this is not relevant anymore
since Apple's build does define LIBCXX_BUILDING_LIBCXXABI.

Reviewers: EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

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

llvm-svn: 358988
2019-04-23 14:05:04 +00:00
Petr Hosek e9a2d1c392 [libcxx] Update gen_link_script.py to support different input and output
This enables the use of this script from other build systems like
GN which don't support post-build actions as well as for static
archives.

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

llvm-svn: 358915
2019-04-22 19:51:33 +00:00
Casey Carter e3f7074c7e [libc++][test] Update some wstring_convert tests for MSVC quirks
Due to MSVC's decision to encode `wchar_t` as UTF-16, it rejects wide
character/string literals that expect a character value greater than
`\xffff`. UTF-16 `wchar_t` is clearly non-conforming, given that the
standard requires wchar_t to be capable of representing all characters
in the supported wide character execution sets, but rejecting e.g.
`\x40003` is a reasonably sane compromise given that encoding choice:
there's an expectation that `\xFOO` produces a single character in the
resulting literal. Consequently `L'\x40003'`/`L"\x40003"` are ill-formed
literals on MSVC. `L'\U00040003'` is a high surrogate (and produces a
warning about ignoring the "second character" in a multi-character
literal), and `L"\U00040003"` is a perfectly-valid `const wchar_t[3]`.

This change updates these tests to use universal-character-names instead
of raw values for the intended character values, which technically makes
them portable even to implementations that don't use a unicode
transformation format encoding for their wide character execution
character set. The two-character literal `L"\u1005e"` is awkward - the
`e` looks like part of the UCN's hex encoding - but necessary to compile
in '03 mode since '03 didn't allow UCNs to be used for members of the
basic execution character set even in character/string literals.

I've also eliminated the extraneous `\x00` "bonus null-terminator" in
some of the string literals which doesn't affect the tested behavior.

I'm sorry about using `*L"\U00040003"` in `conversions.string/to_bytes.pass.cpp`,
but it's correct for platforms with 32-bit wchar_t, *and* doesn't
trigger narrowing warnings as did the prior `CharT(0x40003)`.

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

llvm-svn: 358908
2019-04-22 19:08:13 +00:00
Casey Carter c8eb2d0354 [libc++] [test] Silence C++20 deprecation warnings in the MSVC STL
... when including msvc_stdlib_force_include.hpp.

llvm-svn: 358782
2019-04-19 20:39:41 +00:00
Thomas Anderson 6ab51de08e [libc++] Make __debug_less::operator() constexpr
This is a followup to [1] which added a new `__debug_less::operator()` overload.
[2] added `_LIBCPP_CONSTEXPR_AFTER_CXX17` to the original
`__debug_less::operator()` between the time of writing [1] and landing it.  This
change adds `_LIBCPP_CONSTEXPR_AFTER_CXX17` to the new overload too.

[1] https://reviews.llvm.org/rL358423
[2] https://reviews.llvm.org/rL358252

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

llvm-svn: 358725
2019-04-19 00:52:54 +00:00
Louis Dionne 4664916017 [libc++] Link against libc++abi in the libc++abi tests
PR27405

llvm-svn: 358712
2019-04-18 20:59:49 +00:00
Billy Robert O'Neal III bd7db5ac95 [libc++] [test] Add missing required headers to midpoint.integer.pass.cpp
This change authored by Paolo Torres <t-pator@microsoft.com>

llvm-svn: 358698
2019-04-18 18:02:14 +00:00
Louis Dionne 549048f390 [libc++] Make sure we re-export some missing libc++abi symbols from libc++
Summary:
Ensure we re-export __cxa_throw_bad_array_new_length and
__cxa_uncaught_exceptions from libc++, since they are now
provided by libc++abi.

Doing this allows us to stop linking explicitly against libc++abi in
the libc++abi tests, since libc++ re-exports all the necessary symbols.
However, there is one caveat to that. We don't want libc++ to re-export
__cxa_uncaught_exception (the singular form), since it's only provided
for backwards compatibility. Hence, for the single test where we check
this backwards compatibility, we explicitly link against libc++abi.

PR27405
PR22654

Reviewers: EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

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

llvm-svn: 358690
2019-04-18 17:18:15 +00:00
Louis Dionne ebaf1d5e2b [libc++] Unconditionally enable the __pad_and_output optimization
This used to be guarded on whether the deployment target was greater
than macosx10.8, however testing against the dylibs for 10.8 and earlier
with the function enabled works too. The revision that introduced
__pad_and_output is r164241 and it does not mention a reason for the
guard.

llvm-svn: 358677
2019-04-18 15:19:35 +00:00
Louis Dionne 17a75f7e55 [libc++][CMake] Always provide new/delete in libc++ unless specified otherwise
Summary:
Let's not try to be clever and detect it based on the libc++abi setting.
The only build that puts new/delete in libc++abi is Apple's and we set
this CMake option explicitly in both libc++ and libc++abi. Complicated
dependent options hurt, let's avoid them when possible.

Reviewers: phosek, EricWF

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

Tags: #libc

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

llvm-svn: 358671
2019-04-18 14:47:46 +00:00
Louis Dionne a4bd340bf5 [libc++][CMake] Remove unnecessary conditional for defining new handlers
It turns out that whether the new handlers should be provided is orthogonal
to whether new/delete are provided in libc++ or libc++abi. The reason why
I initially added this conditional is because of an incorrect understanding
of the path we're taking when building on Apple platforms. In fact, we
always build libc++ on top of libc++abi on Apple platforms, so we take
the branch for `LIBCXX_BUILDING_LIBCXXABI` there.

llvm-svn: 358616
2019-04-17 21:57:49 +00:00
Petr Hosek 1788b89b4f [CMake] Split linked libraries for shared and static libc++
Some linker libraries are only needed for shared libc++, some only
for static libc++, combining these together in LIBCXX_LIBRARIES and
LIBCXX_INTERFACE_LIBRARIES can introduce unnecessary dependencies.

This changes splits those up into LIBCXX_SHARED_LIBRARIES and
LIBCXX_STATIC_LIBRARIES matching what libc++abi already does.

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

llvm-svn: 358614
2019-04-17 21:41:09 +00:00
Louis Dionne 09ef420d62 [libc++] (Take 2) Add a test that uses the debug database from multiple threads
In r358591, I added a test that uses the debug database from multiple
threads and that helped us uncover the problem that was fixed in r355367.
However, the test broke the tsan CI bots, and I think the problem is the
test allocator that was used in the test (which is not thread safe).

I'm committing again without using the test allocator, and in a separate
test file.

llvm-svn: 358610
2019-04-17 20:07:39 +00:00
Louis Dionne 7a5eae15a1 [libc++][CMake] Allow building neither the shared nor the static library
It's possible to build just the headers, and we actually do it.

llvm-svn: 358608
2019-04-17 19:47:27 +00:00
Louis Dionne 81875a67b0 [libc++] Use the no_destroy attribute to avoid destroying debug DB statics
Summary:
Otherwise, we can run into problems when the program has static variables
that need to use the debug database during their deinitialization, if
the debug DB has already been deinitialized.

Reviewers: EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

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

llvm-svn: 358602
2019-04-17 18:20:19 +00:00
Louis Dionne 840197e5ed Revert "[libc++] Add a test that uses the debug database from multiple threads"
This reverts r358591, which seems to have uncovered an actual bug and
causes the tsan CI to fail. We need to fix the bug and re-commit the
test.

llvm-svn: 358593
2019-04-17 16:43:03 +00:00
Louis Dionne 00f2ab1c2f [libc++] Add a test that uses the debug database from multiple threads
This test helped us concurrently discover the problem that was fixed
in r355367.

llvm-svn: 358591
2019-04-17 16:21:55 +00:00
Louis Dionne cb843f5b55 [libc++][NFC] Make size of allocation more self-documenting
llvm-svn: 358588
2019-04-17 16:11:41 +00:00
Eric Fiselier c3d6a929fd Fix visibility for coroutine types on Windows
llvm-svn: 358551
2019-04-17 04:31:46 +00:00
Marshall Clow 83465c7938 Add tests for stability to list::sort and forward_list::sort. Thanks to Jonathan Wakely for the notice
llvm-svn: 358541
2019-04-17 00:11:00 +00:00
Marshall Clow 896b0c7b99 Fix list/forward_list implementations of remove_if and unique to deal with predicates that are part of the sequence passed in. We already do this for remove.
llvm-svn: 358534
2019-04-16 22:11:26 +00:00
Louis Dionne 4eff3de994 [NFC] Build libc++ verbosely in the macOS CI
llvm-svn: 358529
2019-04-16 21:16:58 +00:00
Louis Dionne 4b9c19e42d [libc++] Make sure we use new/delete from libc++abi on CI for Apple platforms
llvm-svn: 358524
2019-04-16 20:46:03 +00:00
Louis Dionne 3084db3bb1 [libc++] Remove old workaround for buildit
Summary:
I'm not sure what the problem was at the time, however I don't think
this is necessary since buildit doesn't exist anymore.

Instead of the workaround, the correct thing to do is to leave out
the get_new_handler/set_new_handler definitions from libc++ when
we're getting them from libc++abi.

Reviewers: EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

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

llvm-svn: 358518
2019-04-16 19:26:56 +00:00
Louis Dionne e1e1bd7f9c [libc++] Fix debug_less test in C++03
We were using C++11 features but the test needs to work in C++03 too.

llvm-svn: 358433
2019-04-15 18:00:01 +00:00
Thomas Anderson 3c3ccc0049 [libc++] Fix build failure with _LIBCPP_DEBUG=0 when iterators return values instead of references
There are many STL algorithms (such as lexicographical_compare) that compare
values pointed to by iterators like so:
    __comp(*it1, *it2);
	
When building with `_LIBCPP_DEBUG=0`, comparators are wrapped in `__debug_less`
which does some additional validation.  But `__debug_less::operator()` takes
non-const references, so if the type of `*it1` is int, not int&, then the build
will fail.

This change adds a `const&` overload for `operator()` to fix the build.

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

llvm-svn: 358423
2019-04-15 17:02:15 +00:00
Louis Dionne 5e165fba3a [NFC] Add missing revision number in libc++ ABI changelog
llvm-svn: 358411
2019-04-15 14:29:33 +00:00
Louis Dionne f3e4f24ed7 [libc++] Make sure that the symbol differ takes into account symbol types
Summary:
Otherwise, it doesn't take into account things like whether the symbol
is defined or undefined, and whether symbols are indirect references
(re-exports) or not.

Reviewers: EricWF

Subscribers: christof, jkorous, dexonsmith, libcxx-commits

Tags: #libc

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

llvm-svn: 358408
2019-04-15 14:04:52 +00:00
Louis Dionne e4d6ac5d19 [libc++] Run back-deployment CI against previously-released libc++abi dylibs
We used to do it against the current system's libc++abi, which is not as
good as doing it with the libc++abi that matches the libc++ we're running
against.

Note that I made sure we were indeed picking up the provided libc++abi
by replacing it by something that doesn't work and watching it burn.

llvm-svn: 358294
2019-04-12 16:58:25 +00:00
Eric Fiselier aa1cad1591 Cleanup how debug comparators are created in <algorithm>
Instead of having an `#if` block in every algorithm using a debug
comparator, this patch introduces the __comp_ref_type trait that
selects __debug_less in debug mode and _Comp& otherwise.

This patch should have no observable functionality change.

llvm-svn: 358252
2019-04-12 05:18:19 +00:00
Louis Dionne 7c142fcc06 [libc++] Make sure we don't eagerly diagnose non-const comparators for containers of incomplete types
Summary:
In r348529, I improved the library-defined diagnostic for using containers
with a non-const comparator/hasher. However, the check is now performed
too early, which leads to the diagnostic being emitted in cases where it
shouldn't. See PR41360 for details.

This patch moves the diagnostic to the destructor of the containers, which
means that the diagnostic will only be emitted when the container is instantiated
at a point where the comparator and the key/value are required to be complete.
We still retain better diagnostics than before r348529, because the diagnostics
are performed in the containers themselves instead of __tree and __hash_table.

As a drive-by fix, I improved the diagnostic to mention that we can't find
a _viable_ const call operator, as suggested by EricWF in PR41360.

Reviewers: EricWF, mclow.lists

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

Tags: #libc

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

llvm-svn: 358189
2019-04-11 16:14:56 +00:00
Jonathan Metzman ff79ee144c Remove repeated words from BuildingLibcxx.rst
Summary: Remove repeated words from docs.

Reviewers: phosek

Reviewed By: phosek

Subscribers: christof

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

llvm-svn: 358147
2019-04-10 23:44:27 +00:00
Martin Storsjo c90045bf10 [CMake] Fix statically linking in libcxxabi if built separately
In this case, CMake doesn't know about the c++abi target within the
same CMake run.

This reverts this aspect back to how it was before SVN r357811.

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

llvm-svn: 358009
2019-04-09 14:31:09 +00:00
Louis Dionne fecbf5918b [libc++] Remove install_name and compatibility_version on OS X
CMake already specifies those, and we never actually want those to be
used. In fact, r357811 re-ordered those flags in a way that the
explicitly-provided install_name was overriding the CMake-provided
install_name (instead of the other way around). This caused the dylib
to be considered a system dylib, and hence the explicitly provided rpath
to be ignored. This, in turn, caused some unit tests to start linking
against the system libc++.dylib instead of the freshly-built one.
Specifically, the unit tests that started linking against the system
dylib are those that didn't specify a DYLD_LIBRARY_PATH, such as
last_write_time.sh.cpp.

llvm-svn: 357946
2019-04-08 21:37:42 +00:00
Louis Dionne cd9a528886 [libc++][CMake] Make sure the benchmarks link against libc++abi
The refactoring in r357811 made it so that we didn't add the ABI library
to the list of LIBCXX_LIBRARIES. As a result, benchmarks didn't link to
the ABI library and were missing symbols. This broke the build bots.

As a drive-by fix, we also provide the SHARED ABI library to the linker
script instead of the STATIC ABI library.

This couldn't be discovered on Apple platforms because libc++.dylib
re-exports libc++abi.dylib symbols there.

llvm-svn: 357818
2019-04-05 21:05:32 +00:00
Louis Dionne 6e68a79110 [libc++] Localize CMake code only related to the shared library
Summary:
There's a lot of CMake logic that's only relevant to the shared library,
yet it was using a code path and setting variables that impact both the
shared and the static libraries. This patch moves this logic so that it
clearly only impacts the shared library.

Reviewers: phosek, smeenai, EricWF

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

Tags: #libc

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

llvm-svn: 357811
2019-04-05 20:29:54 +00:00
Louis Dionne 19c44c5a00 [libc++] Add XFAILs for istream tests that were added in r357775
We fixed incorrect behavior of input streams in r357775 and tests were
added accordingly. However, older versions of macOS don't have the
change in the dylib yet, so the tests fail on those platforms.

llvm-svn: 357794
2019-04-05 18:50:47 +00:00
Louis Dionne 396145d0da [libc++] Fix error flags and exceptions propagated from input stream operations
Summary:
This is a re-application of r357533 and r357531. They had been reverted
because we thought the commits broke the LLDB data formatters, but it
turns out this was because only r357531 had been included in the CI
run.

Before this patch, we would only ever throw an exception if the badbit
was set on the stream. The Standard is currently very unclear on how
exceptions should be propagated and what error flags should be set by
the input stream operations. This commit changes libc++ to behave under
a different (but valid) interpretation of the Standard. This interpretation
of the Standard matches what other implementations are doing.

This effectively implements the wording in p1264r0. It hasn't been voted
into the Standard yet, however there is wide agreement that the fix is
correct and it's just a matter of time before the fix is standardized.

PR21586
PR15949
rdar://problem/15347558

Reviewers: mclow.lists, EricWF

Subscribers: christof, dexonsmith, cfe-commits

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

llvm-svn: 357775
2019-04-05 16:33:37 +00:00
Eric Fiselier 9d75d88d30 Handle TLS values in sym_check
llvm-svn: 357705
2019-04-04 15:37:10 +00:00
Nico Weber ea3f97d278 Try to suppress nodiscard_extension failures with Xcode 9
See https://crbug.com/949509 for the error message.

llvm-svn: 357692
2019-04-04 13:37:15 +00:00
Eric Fiselier 4d50879d9c Cleanup test failures in no discard tests.
llvm-svn: 357637
2019-04-03 21:17:34 +00:00
Eric Fiselier 8f34658b87 Attempt to upgrade compiler used by appveyor builds
llvm-svn: 357632
2019-04-03 20:40:01 +00:00
Eric Fiselier 191da93447 disable appveyor config for MSVC 2015
llvm-svn: 357631
2019-04-03 20:36:51 +00:00
Nico Weber 1362d7ef88 libcxx: Add _LIBCPP_NODISCARD_EXT to 38 more functions
This builds on the work done in r342808 and adds _LIBCPP_NODISCARD_EXT
to 37 more functions, namely:

adjacent_find, all_of, any_of, binary_search, clamp, count_if, count,
equal_range, equal, find_end, find_first_not_of, find_first_of, find_if,
find, includes, is_heap_until, is_heap, is_partitioned, is_permutation,
is_sorted_until, is_sorted, lexicographical_compare, lower_bound,
max_element, max, min_element, min, minmax_element, minmax, mismatch,
none_of, remove_if, remove, search_n, search, unique, upper_bound

The motivation here is that we noticed that find_if is nodiscard with
Visual Studio's standard library, and we deemed that useful
(https://crbug.com/948122).
https://devblogs.microsoft.com/cppblog/c17-progress-in-vs-2017-15-5-and-15-6/
says "Our criteria for emitting the warning are: discarding the return
value is a guaranteed leak [...], discarding the return value is
near-guaranteed to be incorrect (e.g. remove()/remove_if()/unique()), or
the function is essentially a pure observer (e.g. vector::empty() and
std::is_sorted())." so I went through algorithm and tried to apply these
criteria.

Some of these, like vector::empty() are already nodiscard per C++
standard and didn't need changing.

I didn't (yet?) go over std::string::find* methods which should probably
have _LIBCPP_NODISCARD_EXT too (but not as part of this change).

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

llvm-svn: 357619
2019-04-03 18:13:08 +00:00
Louis Dionne 6c49e1ce26 [libc++] Use std::is_nothrow_callable for std::invoke according to LWG 2807
Thanks to Zoe Carver for the patch.
Differential Revision: https://reviews.llvm.org/D58097

llvm-svn: 357616
2019-04-03 17:54:37 +00:00