Commit Graph

5566 Commits

Author SHA1 Message Date
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