Commit Graph

4891 Commits

Author SHA1 Message Date
Peter Collingbourne acd1f4e738 Condition usage of locale stdlib functions on Android API version
Some *_l functions were not available in some versions of Bionic. This CL
checks that the NDK version supports the functions, and if not, falls back
on the corresponding functions that don't take a locale.

Patch by Tom Anderson!

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

llvm-svn: 332543
2018-05-16 22:40:12 +00:00
Volodymyr Sapsai 85d3a702da Emit an error when include <atomic> after <stdatomic.h>
C11 defines `kill_dependency` as a macro in <stdatomic.h>. When you
include <atomic> after <stdatomic.h>, the macro clashes with
`std::kill_dependency` and causes multiple errors. Explicit error should
help in diagnosing those errors.

No change for working code that includes <atomic> before <stdatomic.h>.

rdar://problem/27435938

Reviewers: rsmith, EricWF, mclow.lists, jfb

Reviewed By: jfb

Subscribers: jfb, jkorous-apple, christof, bumblebritches57, JonChesterfield, smeenai, cfe-commits

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

llvm-svn: 332413
2018-05-15 22:38:31 +00:00
Volodymyr Sapsai 57e7470ab6 Update XFAIL so apple-clang-9.0 is the last version not implementing Core 2094.
The test is passing with apple-clang-9.1. rdar://problem/40222003

llvm-svn: 332282
2018-05-14 19:45:24 +00:00
Stephan T. Lavavej 79a7361367 [libcxx] [test] Update msvc_stdlib_force_include.hpp.
llvm-svn: 332159
2018-05-11 23:57:32 +00:00
Eric Fiselier f9fc9513bf Fix failing test due to incorrect use of noexcept
llvm-svn: 332066
2018-05-11 00:33:20 +00:00
Eric Fiselier 11a18a7902 Fix PR37407 - callable traits don't correctly check complete types.
Checking for complete types is really rather tricky when you consider
the amount of specializations required to check a function type. This
specifically caused PR37407 where we incorrectly diagnosed
noexcept function types as incomplete (but there were plenty of other
cases that would cause this).

This patch removes the complete type checking for now. I'm going
to look into adding a clang builtin to correctly do this for us.

llvm-svn: 332040
2018-05-10 20:59:35 +00:00
Marshall Clow d23dc0f01e More notes on Rapperswil issues
llvm-svn: 332000
2018-05-10 17:07:38 +00:00
David Bolvansky b89605db01 Allow copy elision in path concatenation
Summary:
Just port of libstdc++'s fix to libc++ fs: e6ac4004fe

Author of fix: Jonathan Wakely

Reviewers: EricWF, mclow.lists

Reviewed By: EricWF

Subscribers: smeenai, christof, cfe-commits, llvm-commits

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

llvm-svn: 331910
2018-05-09 18:57:17 +00:00
Volodymyr Sapsai cdb50bc93b Revert "Emit an error when mixing <stdatomic.h> and <atomic>"
It reverts commit r331379 because turned out `__ALLOW_STDC_ATOMICS_IN_CXX__`
doesn't work well in practice.

llvm-svn: 331818
2018-05-08 22:50:35 +00:00
Marshall Clow 23b242f910 Status updates for Rapperswil
llvm-svn: 331661
2018-05-07 18:59:04 +00:00
Marshall Clow b1f2396879 Update for Rapperswil
llvm-svn: 331638
2018-05-07 14:21:52 +00:00
Stephan T. Lavavej 00d83601b4 [libcxx] [test] Fix whitespace, NFC.
Strip trailing whitespace and untabify.

llvm-svn: 331576
2018-05-05 01:40:27 +00:00
Stephan T. Lavavej eb0fa1c054 [libcxx] [test] Fix MSVC x64 truncation warning.
warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data

Requesting post-commit review.

llvm-svn: 331575
2018-05-05 01:40:24 +00:00
Volodymyr Sapsai dea80d5174 Emit an error when mixing <stdatomic.h> and <atomic>
Atomics in C and C++ are incompatible at the moment and mixing the
headers can result in confusing error messages.

Emit an error explicitly telling about the incompatibility. Introduce
the macro `__ALLOW_STDC_ATOMICS_IN_CXX__` that allows to choose in C++
between C atomics and C++ atomics.

rdar://problem/27435938

Reviewers: rsmith, EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: jkorous-apple, christof, bumblebritches57, JonChesterfield, smeenai, cfe-commits

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

llvm-svn: 331379
2018-05-02 17:56:45 +00:00
Richard Smith c4f593ba1a Fix return type of isinf(double) and isnan(double) where possible.
When using an old version of glibc, a ::isinf(double) and ::isnan(double)
function is provided, rather than just the macro required by C and C++.
Displace this function using _LIBCPP_PREFERRED_OVERLOAD where possible.

The only remaining case where we should get the wrong return type is now
glibc + libc++ + a non-clang compiler.

llvm-svn: 331241
2018-05-01 03:05:40 +00:00
Billy Robert O'Neal III 6e083f628a [libcxx] [test] Remove non-portable assertions from filebuf tests
seekoff.pass.cpp:
libc++'s tests are asserting things about the buffer passed to pubsetbuf. [filebuf.virtuals]/12 says that what the filebuf does with the buffer you give it is completely implementation defined. The MSVC++ implementation takes that buffer and hands it off to the CRT (by calling ::setvbuf) and the CRT doesn't necessarily follow the pattern this test wants.
This change simply makes asserts against the buffer's contents use LIBCPP_ASSERT instead of assert.

pbackfail.pass.cpp:
libc++'s tests are asserting about what characters will and will not be available in the putback area. [filebuf.virtuals]/9 says "The function can alter the number of putback positions available as a result of any call." This change LIBCPP_ASSERTS libc++'s behavior, but checks invariants of the putback area independently.

llvm-svn: 330999
2018-04-26 22:18:33 +00:00
Marshall Clow 57e782535e Move old test into test/libcxx, and implement new version of test for ostreambuf_iterator::failed. Fixes PR#37245. Thanks to Billy O'Neill for the bug report.
llvm-svn: 330955
2018-04-26 16:16:45 +00:00
Volodymyr Sapsai aa208791bb [libcxx] func.wrap.func.con: Unset function before destroying anything
Be defensive against a reentrant std::function::operator=(nullptr_t), in case
the held function object has a non-trivial destructor.  Destroying the function
object in-place can lead to the destructor being called twice.

Patch by Duncan P. N. Exon Smith. C++03 support by Volodymyr Sapsai.

rdar://problem/32836603

Reviewers: EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits, arphaman

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

llvm-svn: 330885
2018-04-25 23:38:41 +00:00
Marshall Clow 0badc676cf Disable the test I just added when testing C++03.
llvm-svn: 330838
2018-04-25 16:09:47 +00:00
Marshall Clow 3df56fdd9b Fix static initialization of std::atomic_flag; Fixes PR#37226. Thanks to Ricky Zhou for the report and test case.
llvm-svn: 330828
2018-04-25 14:27:29 +00:00
Billy Robert O'Neal III 078611eed5 [libcxx] [test] Remove nonportable that errc::is_a_directory produces "Is a directory" from ios_base::failure tests
These io_error asserts that std::errc::is_a_directory has message "Is a directory". On MSVC++ it reports "is a directory" (with a lowercase I). That doesn't matter for the ios_failure component being tested, so just implement in terms of system_category().message().

Reviewed as https://reviews.llvm.org/D45715

llvm-svn: 330791
2018-04-25 01:58:55 +00:00
Tim Shen 403c667b4b Re-commit r330627 "[libcxx] implement <experimental/simd> declarations based on P0214R7."
There are 3 changes:
* Renamed genertor.pass.cpp to generator.pass.cpp
* Removed nothing_to_do.pass.cpp
* Mark GCC 4.9 as UNSUPPORTED for the test files that have negative
  narrowing conversion SFINAE test (see GCC PR63723).

llvm-svn: 330655
2018-04-23 21:54:06 +00:00
Tim Shen f72b208576 Revert "[libcxx] implement <experimental/simd> declarations based on P0214R7."
This reverts commit r330627.

This causes several bots to freak out.

llvm-svn: 330636
2018-04-23 19:56:20 +00:00
Tim Shen 6a72ef6c4b [libcxx] implement <experimental/simd> declarations based on P0214R7.
Summary:
The patch includes all declarations, and also implements the following features:
* ABI.
* narrowing-conversion related SFIANE, including simd<> ctors and (static_)simd_cast.

Reviewers: mclow.lists, EricWF

Subscribers: lichray, sanjoy, MaskRay, cfe-commits

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

llvm-svn: 330627
2018-04-23 18:47:07 +00:00
Reid Kleckner 6a2a5e0abb Don't do aligned allocations on MSVCRT before 19.12 (update 15.3)
Reviewers: EricWF, pcc

Subscribers: christof, cfe-commits

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

llvm-svn: 330372
2018-04-19 22:12:10 +00:00
Reid Kleckner 317a6ddea7 Remove impossible _MSC_VER check
Summary:
It is immediately preceded by this check:
  #if _MSC_VER < 1900
  #error "MSVC versions prior to Visual Studio 2015 are not supported"
  #endif

Reviewers: EricWF

Subscribers: christof, cfe-commits

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

llvm-svn: 330360
2018-04-19 19:40:12 +00:00
Saleem Abdulrasool a4e874c516 support: add missing locale stubs for android L, M
The strto* family was introduced in android O (API Level 26).  However,
the support headers were adjusted to indicate that all locale aware
functions were added in L.  Provide stubs for the locale aware strto*
family until O.

llvm-svn: 330045
2018-04-13 18:14:57 +00:00
Petr Hosek de2b464504 [CMake] Set the default ABI version for Fuchsia in CMake as well
This is neeeded since the CMake value is used for the SOVERSION.

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

llvm-svn: 329983
2018-04-13 01:59:15 +00:00
Stephan T. Lavavej 8fc5b84349 [libcxx] [test] Use TEST_IGNORE_NODISCARD.
Fixes D45595.

llvm-svn: 329979
2018-04-13 00:07:48 +00:00
Stephan T. Lavavej ad9545eb30 [libcxx] [test] Fix whitespace, NFC.
test/std almost always uses spaces; now it is entirely tab-free.

llvm-svn: 329978
2018-04-12 23:56:22 +00:00
Stephan T. Lavavej 9e5283f27f [libcxx] [test] Use TEST_COMPILER_C1XX.
Also TEST_COMPILER_CLANG in one place. (More could be changed.)

llvm-svn: 329977
2018-04-12 23:56:17 +00:00
Stephan T. Lavavej 23e82831e5 [libcxx] [test] Silence MSVC warning C4146.
This test code triggers the MSVC warning:

"unary minus operator applied to unsigned type, result still unsigned"

Although it would be possible to change the test code to avoid
this warning, I have chosen to simply silence it.

Fixes D45594.

llvm-svn: 329976
2018-04-12 23:56:14 +00:00
Stephan T. Lavavej cf017f0451 [libcxx] [test] Fix nodiscard warnings.
MSVC's STL has marked to_bytes/from_bytes as nodiscard.

Fixes D45595.

llvm-svn: 329975
2018-04-12 23:56:12 +00:00
Stephan T. Lavavej 3ed719bb63 [libcxx] [test] Avoid unary_function.
Replace unary_function inheritance (which was never required,
even in C++98) with argument_type and result_type typedefs.
This increases portability, as unary_function was removed in C++17
and MSVC has implemented that removal.

Fixes D45596.

llvm-svn: 329974
2018-04-12 23:56:10 +00:00
Stephan T. Lavavej 0f66190aef [libcxx] [test] Avoid MSVC truncation warnings.
MSVC emits "warning C4244: 'initializing': conversion from 'int'
to 'short', possible loss of data" when it sees pair<Whatever, short>
constructed from (whatever, 4), because int is being truncated to
short within pair's constructor. (The compiler doesn't take into
account the fact that 4 is a literal at the callsite; it generates
this warning when the constructor is instantiated, because it might
be called with a runtime-valued int that would actually truncate.)

Instead of static_cast<short>, we can simply change short to int
in these tests, without affecting the pair operations that they're
trying to test: move assignment, convert copy construction, and
convert move construction.

Fixes D45016.

llvm-svn: 329973
2018-04-12 23:56:07 +00:00
Petr Hosek 2b3846306d [libcxx] Set ABI version 2 as default for Fuchsia
This avoids the need for a custom generated config file which is desired
because the custom config files differs per-target which means we cannot
reuse headers across different targets.

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

llvm-svn: 329770
2018-04-11 01:06:28 +00:00
Billy Robert O'Neal III 34ab26d62a [libcxx] [test] Use the correct type from strlen. Include correct header.
llvm-svn: 329665
2018-04-10 03:04:07 +00:00
Casey Carter e5b6400b54 [test] [NFC] cleanup aligned_storage test
* `s/"" )/"")/g`
* Don't redundantly test triviality for `TEST_STD_VER > 17`

llvm-svn: 329618
2018-04-09 20:41:45 +00:00
Petr Hosek f73514c810 Revert "[CMake] Use custom command and target to install libc++ headers"
This reverts commit r329544 which is failing on libcxx standalone bots.

llvm-svn: 329545
2018-04-09 04:36:04 +00:00
Petr Hosek e10ef3548f [CMake] Use custom command and target to install libc++ headers
Using file(COPY FILE...) has several downsides. Since the file command
is only executed at configuration time, any changes to headers made
after the initial CMake execution are ignored. This can lead to subtle
errors since the just built Clang will be using stale libc++ headers.
Furthermore, since the headers are copied prior to executing the build
system, this may hide missing dependencies on libc++ from other LLVM
components.

This changes replaces the use of file(COPY FILE...) command with a
custom command and target which addresses all aforementioned issues and
matches the implementation already used by other LLVM components that
also install headers like Clang builtin headers.

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

llvm-svn: 329544
2018-04-09 04:23:04 +00:00
Eric Fiselier ba0543b32b [test] Fix Container::insert(value_type const&) tests
Patch from Joe Loser.

Several unit tests meaning to test the behavior of lvalue insertion incorrectly
pass rvalues. Fixes bug PR # 27394

Reviewed as https://reviews.llvm.org/D44411

llvm-svn: 329541
2018-04-08 21:57:35 +00:00
Roman Lebedev 6669e59f88 [libcxx][test] Silence -Wself-assign diagnostics
Summary:
D44883 extends -Wself-assign to also work on C++ classes.
These new warnings pop up in the test suite, so they have to be silenced.

Please refer to the D45082 for disscussion on whether this is the right way to solve this.

Testing: `ninja check-libcxx check-libcxxabi` in stage-2 build.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: Quuxplusone, cfe-commits

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

llvm-svn: 329490
2018-04-07 10:36:03 +00:00
Eric Fiselier d1324fdff0 Use void() to create a void expression type
llvm-svn: 329484
2018-04-07 04:28:11 +00:00
Eric Fiselier b12cc2003a Work around missing braces in init warning
llvm-svn: 329474
2018-04-07 01:28:54 +00:00
Eric Fiselier 0913ca1978 Implement P0768r1: Library support for the Spaceship Operator.
this patch adds the <compare> header and implements all of it
except for [comp.alg].

As I understand it, the header is needed by the compiler in
when implementing the semantics of operator<=>. For that reason
I feel it's important to land this header early, despite
all compilers lacking support.

llvm-svn: 329460
2018-04-06 21:37:23 +00:00
Marshall Clow 1b25a3994e Mark <span> as "In progress"
llvm-svn: 329375
2018-04-06 04:43:27 +00:00
Gor Nishanov 8f310655af [coroutines] libcxx, noop_coroutine, make bots even more happy
llvm-svn: 329245
2018-04-05 00:18:37 +00:00
Gor Nishanov 3a7fdb7d04 [coroutines] libcxx noop_coroutine. Make bots happier
llvm-svn: 329240
2018-04-04 23:43:50 +00:00
Gor Nishanov b1e985db53 [coroutines] Allow compilation under c++03
llvm-svn: 329239
2018-04-04 22:51:57 +00:00
Gor Nishanov 0f87a80795 [coroutines] Add noop_coroutine to <experimental/coroutine>
A recent addition to Coroutines TS (https://wg21.link/p0913) adds a pre-defined
coroutine noop_coroutine that does nothing.

This patch implements require library types in <experimental/coroutine>

Related clang and llvm patches:

https://reviews.llvm.org/D45114
https://reviews.llvm.org/D45120

llvm-svn: 329237
2018-04-04 22:18:03 +00:00
Jan Korous 3abc515dc2 [libcxx][test] Fix fs::proximate tests on platforms where /net exists.
Following Eric's patch.

llvm-svn: 329199
2018-04-04 14:23:51 +00:00
Jan Korous b5fc2b1433 [libcxx][test] Improve assert message
llvm-svn: 329194
2018-04-04 13:31:39 +00:00
Simon Dardis 6487c3b012 [libcxx][cmake] Remove libatomic temporarily from CMAKE_REQUIRED_LIBRARIES when configuring
When libcxx is built in tree for a host which requires libatomic, LLVM's
configuration steps will determine it is required and add it to
CMAKE_REQUIRED_LIBRARIES. When libcxx is later configured, it tests if it
has C++ atomics without libatomic. The test erroneously passes as libatomic
is already part of the set of required libraries.

In turn, a number of the atomic tests will fail as they require libatomic
but the test suite is configured not to use libatomic.

Address this by always dropping libatomic from the set of required libraries
before determining if LIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB is true,
then restoring the set of required libraries.

Reviewers: EricWF

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

llvm-svn: 329167
2018-04-04 11:05:03 +00:00
Eric Fiselier c18fe4cf41 Fix undefined macro issue in locale tests; Try 2
llvm-svn: 329149
2018-04-04 04:48:26 +00:00
Eric Fiselier 06091cfa7a Fix undefined macro issue in locale tests
llvm-svn: 329148
2018-04-04 04:39:38 +00:00
Eric Fiselier b5d2937d5f Update Clang version on Appveyor bots
llvm-svn: 329145
2018-04-04 04:33:09 +00:00
Eric Fiselier acc32abb11 Touch up tests for new <version> header; fix module.modulemap.
This patch does some housekeeping for the new <version> header.
It adds it to the module.modulemap, and the double_include.sh.cpp test.

Additionally it corrects the // UNSUPPORTED options for the libc++
specific test. The header needs to compile under C++03 to support
modules, and it should compile under all available compilers.

llvm-svn: 329144
2018-04-04 04:21:54 +00:00
Eric Fiselier fcc1e6d978 Fix locale test data for GLIBC 2.27 and newer.
GLIBC 2.27 changed the locale data for fr_FR and ru_RU. In particular
they change the decimal and thousands separators used. This patch
makes the locale tests tolerate the updated locales.

llvm-svn: 329143
2018-04-04 04:00:14 +00:00
Marshall Clow 082229eb0f Implement P0754R2: The <version> header.
llvm-svn: 329075
2018-04-03 15:48:24 +00:00
Eric Fiselier 9085c6fcd8 Fix fs::proximate tests on platforms where /net exists.
The proximate tests depended on `/net` not being a valid path,
however, on OS X it is.

Correct the tests to handle this.

llvm-svn: 329038
2018-04-03 01:52:12 +00:00
Eric Fiselier d491a6960a Implement P0430R2 - File system library on non-POSIX systems.
This patch implements P0430R2, who's largest change is adding the path::format
enumeration for supporting path format conversions in path constructors.

However, since libc++'s filesystem only really supports POSIX like systems,
there are no real changes needed. This patch simply adds the format enum
and then ignores it when it's passed to constructors.

llvm-svn: 329031
2018-04-02 23:35:24 +00:00
Eric Fiselier d7fae181c3 Implement filesystem NB comments, relative paths, and related issues.
This is a fairly large patch that implements all of the filesystem NB comments
and the relative paths changes (ex. adding weakly_canonical). These issues
and papers are all interrelated so their implementation couldn't be split up
nicely.

This patch upgrades <experimental/filesystem> to match the C++17 spec and not
the published experimental TS spec. Some of the changes in this patch are both
API and ABI breaking, however libc++ makes no guarantee about stability for
experimental implementations.

The major changes in this patch are:

* Implement NB comments for filesystem (P0492R2), including:
  * Implement `perm_options` enum as part of NB comments, and update the
    `permissions` function to match.
  * Implement changes to `remove_filename` and `replace_filename`
  * Implement changes to `path::stem()` and `path::extension()` which support
    splitting examples like `.profile`.
  * Change path iteration to return an empty path instead of '.' for trailing
    separators.
  * Change `operator/=` to handle absolute paths on the RHS.
  * Change `absolute` to no longer accept a current path argument.

* Implement relative paths according to NB comments (P0219r1)

* Combine `path.cpp` and `operations.cpp` since some path functions require
  access to the operations internals, and some fs operations require access
  to the path parser.

llvm-svn: 329028
2018-04-02 23:03:41 +00:00
Volodymyr Sapsai 24a77396a9 [libcxx] Disable testing with system lib for 2 tests verifying debug mode.
llvm-svn: 329023
2018-04-02 22:09:57 +00:00
Eric Fiselier 02eb974af5 fix typo in align_const_pair_U_V.pass.cpp
llvm-svn: 328760
2018-03-29 03:44:01 +00:00
Eric Fiselier f8aa23879e Move libc++ pair/tuple assign test to libcxx/ test directory.
Libc++ implements the pair& operator=(pair<U, V>) assignment operator
using a single template that handles assignment from all tuple-like types.

This patch moves the test for that to the libcxx test directory since
it's non-standard. It also adds additional tests to the std/.../pair
directory to test the standard behavior this template implements.

llvm-svn: 328758
2018-03-29 03:30:00 +00:00
Eric Fiselier bc3a21f823 Fix PR36914 - num_get::get(unsigned) incorrectly handles negative numbers.
This patch corrects num_get for unsigned types to support strings
with a leading `-` character. According to the standard the
number should be parsed as an unsigned integer and then
negated.

llvm-svn: 328751
2018-03-29 01:18:53 +00:00
Eric Fiselier ed27554079 Fix test case initialization issues in permissions test
llvm-svn: 328477
2018-03-26 07:06:25 +00:00
Eric Fiselier 4d334c4cdd Implement filesystem::perm_options specified in NB comments.
The NB comments for filesystem changed permissions and added
a new enum `perm_options` which control how the permissions
are applied.

This implements than NB resolution

llvm-svn: 328476
2018-03-26 06:23:55 +00:00
Eric Fiselier 19aae8fe2f Make filesystem tests generic between experimental and std versions.
As I move towards implementing std::filesystem, there is a need to
make the existing tests run against both the std and experimental versions.
Additionally, it's helpful to allow running the tests against other
implementations of filesystem.

This patch converts the test to easily target either. First, it
adds a filesystem_include.hpp header which is soley responsible
for selecting and including the correct implementation. Second,
it converts existing tests to use this header instead of including
filesystem directly.

llvm-svn: 328475
2018-03-26 05:46:57 +00:00
Eric Fiselier 98acdde59a avoid new/delete ellision in construct.pass.cpp
llvm-svn: 328445
2018-03-25 03:00:42 +00:00
Eric Fiselier cd5e6a35bf Partially Revert "Workaround GCC bug PR78489 - SFINAE order is not respected."
This partially reverts commit r328261. The GCC bug has been fixed in
trunk and has never existed in a released version. Therefore the changes
to variant are unneeded.

However, the additional tests have been left in place.

llvm-svn: 328388
2018-03-23 23:42:30 +00:00
Eric Fiselier 561e75738b Add temporary printouts to test to help debug failures.
Some debian libc++ bots started having failures in the locale
tests due to what I assume is a change in the locale data for fr_FR
in glibc.

This change prints the actual value from the test to help debugging.
It should be reverted once the bots cycle.

llvm-svn: 328268
2018-03-22 23:14:20 +00:00
Eric Fiselier 5bdf02f4fc Avoid Clang error about throwing _LIBCPP_ASSERT in noexcept function.
This fixes a couple of tests which produced a warning that a 'throw'
occurred in a noexcept function (by way of _LIBCPP_ASSERT). It does
so by hiding the 'throw' across an opaque function boundary.

This fix isn't ideal, since we still have _LIBCPP_ASSERT's in functions
marked noexcept -- and this problem should be addressed in the future.
However, throwing _LIBCPP_ASSERT is really only meant to allow testing
of the assertions, and is not yet ready for general use.

llvm-svn: 328265
2018-03-22 23:01:08 +00:00
Stephan T. Lavavej d0eba7f2a5 [libcxx] [test] Strip trailing whitespace. NFC.
llvm-svn: 328264
2018-03-22 22:59:02 +00:00
Eric Fiselier a595456731 Workaround GCC bug PR78489 - SFINAE order is not respected.
This patch works around variant test failures which are new to
GCC 8. GCC 8 either doesn't perform SFINAE in lexical order, or
it doesn't halt after encountering the first failure. This
causes hard error to occur instead of substitution failure.

See gcc.gnu.org/PR78489

llvm-svn: 328261
2018-03-22 22:32:55 +00:00
Eric Fiselier 107d6d6845 Use DoNotOptimize to prevent new/delete elision.
The new/delete tests, in particular those which test replacement
functions, often fail when the optimizer is enabled because the
calls to new/delete may be optimized away, regardless of their side-effects.

This patch converts the tests to use DoNotOptimize in order to prevent
the elision.

llvm-svn: 328245
2018-03-22 21:28:09 +00:00
Eric Fiselier 6f14127eed Un-XFAIL a test under new GCC version; the GCC bug has been fixed
llvm-svn: 328229
2018-03-22 19:18:08 +00:00
Marshall Clow a4122be549 Fix improperly failing test - and the code it was testing. Thanks to Stephan Lavavej for the catch.
llvm-svn: 328225
2018-03-22 18:27:28 +00:00
Eric Fiselier 843a3caa71 commit temporary workaround for new Clang exception warning
llvm-svn: 328186
2018-03-22 07:53:47 +00:00
Eric Fiselier 5d4624983d Correct TEST_HAS_NO_ALIGNED_ALLOCATION macro definition
llvm-svn: 328185
2018-03-22 06:21:07 +00:00
Eric Fiselier deb7e4e009 Fix dynarray test failures after changing __libcpp_allocate/deallocate
llvm-svn: 328182
2018-03-22 05:44:48 +00:00
Eric Fiselier f2918d1c24 Fix PR22634 - std::allocator doesn't respect over-aligned types.
This patch fixes std::allocator, and more specifically, all users
of __libcpp_allocate and __libcpp_deallocate, to support over-aligned
types.

__libcpp_allocate/deallocate now take an alignment parameter, and when
the specified alignment is greater than that supported by malloc/new,
the aligned version of operator new is called (assuming it's available).

When aligned new isn't available, the old behavior has been kept, and the
alignment parameter is ignored.

This patch depends on recent changes to __builtin_operator_new/delete which
allow them to be used to call any regular new/delete operator. By using
__builtin_operator_new/delete when possible, the new/delete erasure optimization
is maintained.

llvm-svn: 328180
2018-03-22 04:42:56 +00:00
Marshall Clow 4a6f3c4710 Implement LWG3034: P0767R1 breaks previously-standard-layout types
llvm-svn: 328064
2018-03-21 00:36:05 +00:00
Marshall Clow e0742c4abf Implement LWG3035: std::allocator's constructors should be constexpr.
llvm-svn: 328059
2018-03-20 23:02:53 +00:00
Marshall Clow 69f1072ba2 Implement LWG 3039 and 3041 - 'Treating Unnecessary decay'.
llvm-svn: 328054
2018-03-20 22:37:37 +00:00
Marshall Clow c8faf3a93c Updated C++2a status with changes from Jacksonville WG21 meeting
llvm-svn: 327806
2018-03-18 19:29:21 +00:00
Mike Edwards 8e94aeb5f8 [libcxx][test] Adding apple-clang-9 to UNSUPPORTED in iter_alloc_deduction.fail.cpp.
After two failed attempts last week to make this work I am
going back to a known good method of making this test pass on
macOS...adding the current apple-clang version to the
UNSUPPORTED list.

During a previous patch review (https://reviews.llvm.org/D44103)
it was suggested to just XFAIL libcpp-no-deduction-guides
as was done to iter_alloc_deduction.pass.cpp. However
this caused a an unexpected pass on:
http://lab.llvm.org:8011/builders/libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std/builds/214

I then attempted to just mark libcpp-no-deduction-guides
as UNSUPPORTED, however this caused an additional bot
failure.  So I reverted everything (https://reviews.llvm.org/rCXX327191).

To solve this and get work unblocked I am adding
apple-clang-9 to the original UNSUPPORTED list.

llvm-svn: 327304
2018-03-12 18:06:37 +00:00
Petr Hosek aaabea0636 [CMake] Copy the generated __config header into build directory
When the generated __config file is being used, it is currently only
copied during installation process. However, that means that the file
that gets copied into LLVM build directory is the vanilla __config file,
and any parts of the build that depend on the just built toolchain like
sanitizers will get that instead of the generated version. To avoid this
issue, we need to copy the generated header into the LLVM build
directory as well.

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

llvm-svn: 327194
2018-03-10 01:20:11 +00:00
Mike Edwards b9abf3d299 [libcxx][test] Reverting r327178 and r327190.
Reverting changes made to iter_alloc_deduction.fail.cpp
as my changes seem to be making several Linux bots angry.

llvm-svn: 327191
2018-03-10 00:53:05 +00:00
Mike Edwards 231e19ce52 [libcxx][test] Marking libcpp-no-deduction-guides unsupported.
This fixes linux bot failures with r327178.

llvm-svn: 327190
2018-03-10 00:19:25 +00:00
Mike Edwards d0f595d77c XFAIL: libcpp-no-deduction-guides in libcxx/test/std/strings/basic.string/string.cons/iter_alloc_deduction.fail.cpp
Summary: Refactor the previous version method of marking each apple-clang version as UNSUPPORTED and just XFAIL'ing the libcpp-no-deduction-guides instead.  This brings this test inline with the same style as iter_alloc_deduction.pass.cpp

Reviewers: EricWF, dexonsmith

Reviewed By: EricWF

Subscribers: EricWF, vsapsai, vsk, cfe-commits

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

llvm-svn: 327178
2018-03-09 22:13:12 +00:00
Vedant Kumar fb36d079e5 Low-hanging fruit optimization in string::__move_assign().
shrink_to_fit() ends up doing a lot work to get information that we
already know since we just called clear(). This change seems concise
enough to be worth the couple extra lines and my benchmarks show that it
is indeed a pretty decent win. It looks like the same thing is going on
twice in __copy_assign_alloc(), but I didn't want to go overboard since
this is my first contribution to llvm/libc++.

Patch by Timothy VanSlyke!

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

llvm-svn: 327064
2018-03-08 21:15:26 +00:00
Marshall Clow 6d1aec1260 Implement LWG#2518 - Non-member swap for propagate_const should call member swap
llvm-svn: 327005
2018-03-08 15:01:50 +00:00
Marshall Clow 4fe52c7178 Include <system_error> since we use it. Thanks to Andrey Maksimov for the catch.
llvm-svn: 326958
2018-03-07 22:51:16 +00:00
Marshall Clow a9daa969c1 One more test for P0767:
llvm-svn: 326802
2018-03-06 15:01:55 +00:00
Marshall Clow 042f07eed8 Implement P0767R1 - Deprecate POD
llvm-svn: 326801
2018-03-06 15:01:19 +00:00
Marshall Clow aadaabe649 Added P0805 to the list of ready bits
llvm-svn: 326485
2018-03-01 21:16:07 +00:00
Volodymyr Sapsai ff9595a002 [libcxx] Fix last_write_time test for filesystems that don't support very small times.
APFS minimum supported file write time is -2^63 nanoseconds, which doesn't go
as far as `file_time_type::min()` that is equal to -2^63 microseconds on macOS.

This change doesn't affect filesystems that support `file_time_type` range only
for in-memory file time representation but not for on-disk representation. Such
filesystems are considered as `SupportsMinTime`.

rdar://problem/35865151

Reviewers: EricWF, Hahnfeld

Subscribers: jkorous-apple, mclow.lists, cfe-commits, christof

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

llvm-svn: 326383
2018-02-28 23:27:40 +00:00
Stephan T. Lavavej c1fcd97ede [libcxx] [test] Fix MSVC warnings and errors.
test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan.pass.cpp
test/std/numerics/numeric.ops/exclusive.scan/exclusive_scan_init_op.pass.cpp
test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan.pass.cpp
test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op.pass.cpp
test/std/numerics/numeric.ops/inclusive.scan/inclusive_scan_op_init.pass.cpp
test/std/numerics/numeric.ops/transform.exclusive.scan/transform_exclusive_scan_init_bop_uop.pass.cpp
test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp
test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop_init.pass.cpp
Fix MSVC x64 truncation warnings.
warning C4267: conversion from 'size_t' to 'int', possible loss of data

test/std/strings/basic.string/string.modifiers/string_append/push_back.pass.cpp
Fix MSVC uninitialized memory warning.
warning C6001: Using uninitialized memory 'vl'.

test/std/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.pass.cpp
Include <cassert> for the assert() macro.

Fixes D43273.

llvm-svn: 326120
2018-02-26 20:47:46 +00:00
Logan Chien 2b772b930e Cleanup __config indention NFC
This commit indents each level by two space characters, e.g.

#if defined(CONDITION)
#  define _LIBCPP_NAME VALUE
#else
#  define _LIBCPP_NAME VALUE
#endif

The simple #ifndef, #define, and #endif sequences are not indented, e.g.

#ifndef _LIBCPP_NAME
#define _LIBCPP_NAME ...
#endif

llvm-svn: 326027
2018-02-24 07:57:32 +00:00
Alexander Richardson 504d23551e Allow passing additional compiler/linker flags for the tests
Summary:
These flags can be specified using the CMake variables
LIBCXX_TEST_LINKER_FLAGS and LIBCXX_TEST_COMPILER_FLAGS.
When building the tests for CHERI I need to pass additional
flags (such as -mabi=n64 or -mabi=purecap) to the compiler
for our test configurations

Reviewers: EricWF

Reviewed By: EricWF

Subscribers: christof, mgorny, cfe-commits

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

llvm-svn: 325914
2018-02-23 15:19:48 +00:00
Mikhail Maltsev 61ccaf6ddd [libcxx] Do not include the C math.h header before __config
Summary:
Certain C libraries require configuration macros defined in __config
to provide the correct functionality for libc++. This patch ensures
that the C header math.h is always included after the __config
header. It also adds a Windows-specific #if guard for the case when
the C math.h file is included the second time, as suggested by
Marshall in https://reviews.llvm.org/rL323490.

Fixes PR36382.

Reviewers: mclow.lists, EricWF

Reviewed By: mclow.lists

Subscribers: cfe-commits, pcc, christof, rogfer01

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

llvm-svn: 325760
2018-02-22 09:34:08 +00:00
Marshall Clow 3c83937370 Add another test case to the deduction guide for basic_string.
llvm-svn: 325740
2018-02-22 05:14:20 +00:00
Peter Collingbourne 2a129dc31b libcxx: Unbreak external thread library configuration.
Differential Revision: https://reviews.llvm.org/D42503

llvm-svn: 325723
2018-02-21 21:36:18 +00:00
Mikhail Maltsev 477b5f688c [libcxx] Improve accuracy of complex asinh and acosh
Summary:
Currently std::asinh and std::acosh use std::pow to compute x^2. This
results in a significant error when computing e.g. asinh(i) or
acosh(-1).

This patch expresses x^2 directly via x.real() and x.imag(), like it
is done in libstdc++/glibc, and adds tests that checks the accuracy.

Reviewers: EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: christof, cfe-commits

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

llvm-svn: 325510
2018-02-19 15:41:36 +00:00
Eric Fiselier 9491643c4b Fix test failure on compilers w/o deduction guides
llvm-svn: 325205
2018-02-15 02:41:19 +00:00
Marshall Clow 36c4862a37 Add a catch for std::length_error for the case where the string can't handle 2GB. (like say 32-bit big-endian)
llvm-svn: 325147
2018-02-14 18:05:25 +00:00
Bruce Mitchener 56f6352354 Fix incorrect indentation.
Reviewers: mclow.lists

Subscribers: cfe-commits

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

llvm-svn: 325087
2018-02-14 00:29:38 +00:00
Dimitry Andric 267e0f4d5f Make the ctype_byname::widen test cases pass on FreeBSD.
llvm-svn: 325028
2018-02-13 17:43:24 +00:00
Dimitry Andric 1b1b80f45f Put type attributes after class keyword
Summary:
Compiling `<functional>` in C++17 or higher mode results in:

```
functional:2500:1: warning: attribute '__visibility__' is ignored, place it after "class" to apply attribute to type declaration [-Wignored-attributes]
_LIBCPP_TYPE_VIS
^
__config:701:46: note: expanded from macro '_LIBCPP_TYPE_VIS'
#    define _LIBCPP_TYPE_VIS __attribute__ ((__visibility__("default")))
                                             ^
1 warning generated.
```

Fix it by putting the attribute after the `class` keyword.

Reviewers: EricWF, mclow.lists

Reviewed By: EricWF

Subscribers: cfe-commits

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

llvm-svn: 325027
2018-02-13 17:40:59 +00:00
Bruce Mitchener f684c9c83c Fix typos.
Reviewers: mclow.lists, EricWF

Subscribers: cfe-commits

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

llvm-svn: 324989
2018-02-13 08:12:00 +00:00
Stephan T. Lavavej 6b1ae9b854 [libcxx] [test] Strip trailing whitespace, NFC.
llvm-svn: 324959
2018-02-12 22:54:35 +00:00
Marshall Clow 5012793e05 Implement LWG 2835 - fix <tgmath.h>
llvm-svn: 324923
2018-02-12 19:13:24 +00:00
Marshall Clow c0db07299e Implement LWG#2908 - The less-than operator for shared pointers could do more, and mark 2878 as complete as well (we already do that)
llvm-svn: 324911
2018-02-12 17:26:40 +00:00
Marshall Clow 8ea7ede725 While implementing P0777 - preventing unnecessary decay, I found some non-public uses of decay that could be replaced by __uncvref. NFC intented
llvm-svn: 324895
2018-02-12 15:41:25 +00:00
Dimitry Andric 35479ffb12 Add default C++ ABI libname and include paths for FreeBSD
Summary:
As noted in a discussion about testing the LLVM 6.0.0 release candidates
(with libc++) for FreeBSD, many tests turned out to fail with
"exception_ptr not yet implemented".  This was because libc++ did not
choose the correct C++ ABI library, and therefore it fell back to the
`exception_fallback.ipp` header.

Since FreeBSD 10.x, we have been using libcxxrt as our C++ ABI library,
and its headers have always been installed in /usr/include/c++/v1,
together with the (system) libc++ headers.  (Older versions of FreeBSD
used GNU libsupc++ by default, but these are now unsupported.)

Therefore, if we are building libc++ for FreeBSD, set:
* `LIBCXX_CXX_ABI_LIBNAME` to "libcxxrt"
* `LIBCXX_CXX_ABI_INCLUDE_PATHS` to "/usr/include/c++/v1"
by default.

Reviewers: emaste, EricWF, mclow.lists

Reviewed By: EricWF

Subscribers: mgorny, cfe-commits, krytarowski

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

llvm-svn: 324855
2018-02-11 22:31:05 +00:00
Eric Fiselier 2328c589f1 Fix libcxx MSVC C++17 redefinition of 'align_val_t'
Patch from 	charlieio@outlook.com

Reviewed as https://reviews.llvm.org/D42354

When the following command is used:

> clang-cl -std:c++17 -Iinclude\c++\v1 hello.cc c++.lib

An error occurred:

In file included from hello.cc:1:
In file included from include\c++\v1\iostream:38:
In file included from include\c++\v1\ios:216:
In file included from include\c++\v1\__locale:15:
In file included from include\c++\v1\string:477:
In file included from include\c++\v1\string_view:176:
In file included from include\c++\v1\__string:56:
In file included from include\c++\v1\algorithm:643:
In file included from include\c++\v1\memory:656:
include\c++\v1\new(165,29):  error: redefinition of 'align_val_t'
enum class _LIBCPP_ENUM_VIS align_val_t : size_t { };
                            ^
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.12.25827\include\vcruntime_new.h(43,16):  note:
      previous definition is here
    enum class align_val_t : size_t {};
               ^
1 error generated.
vcruntime_new.h has defined align_val_t, libcxx need hide align_val_t.

This patch fixes that error.

llvm-svn: 324853
2018-02-11 22:00:19 +00:00
Eric Fiselier 6808a59244 Mark two issues as complete
llvm-svn: 324852
2018-02-11 21:57:25 +00:00
Marshall Clow 026b75f209 Fix a typo in the synopsis comment. NFC. Thanks to K-ballo for the catch
llvm-svn: 324851
2018-02-11 21:51:49 +00:00
Eric Fiselier 9bfdb770cc Use multi-key tree search for {map, set}::{count, equal_range}
Patch from ngolovliov@gmail.com
Reviewed as: https://reviews.llvm.org/D42344

As described in llvm.org/PR30959, the current
implementation of std::{map, key}::{count, equal_range} in libcxx is
non-conforming. Quoting the C++14 standard [associative.reqmts]p3

> The phrase “equivalence of keys” means the equivalence relation imposed by
> the comparison and not the operator== on keys. That is, two keys k1 and k2 are
> considered to be equivalent if for the comparison object comp,
> comp(k1, k2) == false && comp(k2, k1) == false.

In the same section, the requirements table states the following:

> a.equal_range(k) equivalent to make_pair(a.lower_bound(k), a.upper_bound(k))
> a.count(k) returns the number of elements with key equivalent to k

The behaviour of libstdc++ seems to conform to the standard here.

llvm-svn: 324799
2018-02-10 02:53:47 +00:00
Marshall Clow 7f7891c427 The apple versions of clang don't support deduction guides yet.
llvm-svn: 324640
2018-02-08 19:33:03 +00:00
Marshall Clow 6aafc8b308 Once more, with feeling. Spell 'clang-4.0' correctly this time
llvm-svn: 324624
2018-02-08 17:06:08 +00:00
Marshall Clow 2a81d30471 Clean up string's deduction guides tests. Mark old versions of clang as unsupported, b/c they don't have deduction guides, even in C++17 mode
llvm-svn: 324619
2018-02-08 16:25:57 +00:00
Marshall Clow 2583976e81 Update the status of removed components
llvm-svn: 324609
2018-02-08 14:51:22 +00:00
Mikhail Maltsev 2b20304def [libcxx] Avoid spurious construction of valarray elements
Summary:
Currently libc++ implements some operations on valarray by using the
resize method. This method has a parameter with a default value.
Because of this, valarray may spuriously construct and destruct
objects of valarray's element type.
    
This patch fixes this issue and adds corresponding test cases.


Reviewers: EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: rogfer01, cfe-commits

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

llvm-svn: 324596
2018-02-08 11:33:48 +00:00
Marshall Clow b0c4bb74a8 Temporarily comment out deduction guide tests while I figure out what to do with old bots
llvm-svn: 324573
2018-02-08 07:20:45 +00:00
Marshall Clow 6d9f750dec Implement deduction guide for basic_string as described in P0433
llvm-svn: 324569
2018-02-08 06:34:03 +00:00
Marshall Clow a217e505c3 Improve a test. NFC
llvm-svn: 324566
2018-02-08 05:47:40 +00:00
Eric Fiselier 1a78ae3c89 Fix size and alignment of array<T, 0>.
An array T[1] isn't necessarily the same say when it's
a member of a struct. This patch addresses that problem and corrects
the tests to deal with it.

llvm-svn: 324545
2018-02-07 23:50:25 +00:00
Dan Albert 9bc04e98c5 Stop using __strtonum_fallback on Android.
Fallback implementations are now provided by bionic when necessary,
which these may conflict with.

llvm-svn: 324534
2018-02-07 21:58:48 +00:00
Marshall Clow fc940277cb Fix PR#31454 - 'basic_string<T>::push_back() crashes if sizeof(T)>sizeof(long long)'. We were mishandling the small-string optimization calculations for very large 'characters'. This may be an ABI change (change the size of) strings of very large 'characters', but since they never worked, I'm not too concerned.
llvm-svn: 324531
2018-02-07 21:30:17 +00:00
Eric Fiselier ebf8a0985f Fix -verify static assert messages for older Clang versions
llvm-svn: 324529
2018-02-07 21:25:25 +00:00
Eric Fiselier 59cdf90ac8 [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.
Summary:
This patch fixes llvm.org/PR35491 and LWG2157  (https://cplusplus.github.io/LWG/issue2157)

The fix attempts to maintain ABI compatibility by replacing the array with a instance of `aligned_storage`.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: lichray, cfe-commits

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

llvm-svn: 324526
2018-02-07 21:06:13 +00:00
Marshall Clow 1d4546c0ad Comment on 'Review' issues
llvm-svn: 324503
2018-02-07 19:24:37 +00:00
Marshall Clow a3d37f0716 Remove more of the std::experimental bits that are now in std::. All the _v type aliases, conjunction/disjunction, apply, etc. See https://libcxx.llvm.org/TS_deprecation.html
llvm-svn: 324423
2018-02-06 23:13:48 +00:00
Marshall Clow f9ab87e9cc Mark P0777 as complete
llvm-svn: 324399
2018-02-06 21:00:58 +00:00
Marshall Clow 655c4695cf Implement P0777: Treating unnecessay decay
llvm-svn: 324398
2018-02-06 20:56:55 +00:00
Nico Weber 6ef990e9ce Fix building libc++ with the macOS 10.13 SDK with -mmacosx-version-min=10.12 or lower.
The 10.13 SDK always defines utimensat() (with an availability(macosx=10.13) annotation)
and unconditionally defines UTIME_OMIT, so use the compile-time availability macros
on Apple platforms instead.

For people statically linking libc++, it might make sense to also provide an opt-in
option for using __builtin_available() to dynamically check for the OS version,
but for now let's do the smallest thing needed to unbreak the build.

Based on a patch by Eric Fiselier <eric@efcs.ca>: https://reviews.llvm.org/D34249
Fixes PR33469.

llvm-svn: 324385
2018-02-06 19:17:41 +00:00
Marshall Clow f951fc399f Fix misleading indentation; replace a couple of NULLs with nullptr. Resolves https://reviews.llvm.org/D42945 ; thanks to Bruce Mitchener for the patch.
llvm-svn: 324378
2018-02-06 18:58:05 +00:00
Marshall Clow cefa05d39f No, really this time mark 3034 as 'Patch Ready'
llvm-svn: 324312
2018-02-06 03:24:21 +00:00
Marshall Clow 4d170c801b Mark issue 3034 as 'Patch Ready'
llvm-svn: 324310
2018-02-06 03:23:16 +00:00
Nirav Dave 936ff58476 Revert "[libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types."
Revert "Fix initialization of array<const T, 0> with GCC."
Revert "Make array<const T, 0> non-CopyAssignable and make swap and fill ill-formed."

This reverts commit r324182, r324185, and r324194 which were causing issues with zero-length std::arrays.

llvm-svn: 324309
2018-02-06 03:03:37 +00:00
Marshall Clow 0fc039df1e More patches ready
llvm-svn: 324307
2018-02-06 01:59:28 +00:00
Marshall Clow 50dd98cb2b Add issues in 'Review'
llvm-svn: 324292
2018-02-05 23:50:49 +00:00
Marshall Clow 372d4183cb Remove <experimental/string_view>; use <string_view> instead. See https://libcxx.llvm.org/TS_deprecation.html
llvm-svn: 324290
2018-02-05 23:43:34 +00:00
Eric Fiselier c6b3c7bb63 Fix initialization of array<const T, 0> with GCC.
Previously, when handling zero-sized array of const objects we
used a const version of aligned_storage_t, which is not an array type.
However, GCC complains about initialization of the form: array<const T, 0> arr = {};

This patch fixes that bug by making the dummy object used to represent
the zero-sized array an array itself. This avoids GCC's complaints
about the uninitialized const member.

llvm-svn: 324194
2018-02-04 08:02:35 +00:00
Eric Fiselier 4f0c85310d Mark LWG 3014 as complete. No code changes needed
llvm-svn: 324193
2018-02-04 07:37:09 +00:00
Eric Fiselier e3690ba586 Implement LWG 3014 - Fix more noexcept issues in filesystem.
This patch removes the noexcept declaration from filesystem
operations which require creating temporary paths or
creating a directory iterator. Either of these operations
can throw.

llvm-svn: 324192
2018-02-04 07:35:36 +00:00
Eric Fiselier 309f8b1168 Mark LWG 3013 as already complete. See r316941
llvm-svn: 324191
2018-02-04 07:29:53 +00:00
Eric Fiselier b96def4eb1 Remove debug println from rec.dir.itr.increment test
llvm-svn: 324190
2018-02-04 03:26:55 +00:00
Eric Fiselier be71d336bd Implement LWG2989: path's streaming operators allow everything under the sun.
Because path can be constructed from a ton of different types, including string
and wide strings, this caused it's streaming operators to suck up all sorts
of silly types via silly conversions. For example:

using namespace std::experimental::filesystem::v1;
std::wstring w(L"wide");
std::cout << w; // converts to path.

This patch tentatively adopts the resolution to LWG2989 and fixes the issue
by making the streaming operators friends of path.

llvm-svn: 324189
2018-02-04 03:10:53 +00:00
Eric Fiselier 21f2004991 Mark issue 2851 as complete
llvm-svn: 324188
2018-02-04 02:45:33 +00:00
Eric Fiselier 0f8c8f59df Address LWG 2849 and fix missing failure condition in copy_file.
Previously copy_file didn't handle the case where the input and
output were the same file.

llvm-svn: 324187
2018-02-04 02:43:32 +00:00
Eric Fiselier e1c661f344 correct comment about C++03 assignment operators
llvm-svn: 324186
2018-02-04 02:22:33 +00:00
Eric Fiselier 192622dc49 Make array<const T, 0> non-CopyAssignable and make swap and fill ill-formed.
The standard isn't exactly clear how std::array should handle zero-sized arrays
with const element types. In particular W.R.T. copy assignment, swap, and fill.

This patch takes the position that those operations should be ill-formed,
and makes changes to libc++ to make it so.

This follows up on commit r324182.

llvm-svn: 324185
2018-02-04 02:17:02 +00:00
Eric Fiselier afeda5c251 [libc++] Fix PR35491 - std::array of zero-size doesn't work with non-default constructible types.
Summary:
This patch fixes llvm.org/PR35491 and LWG2157  (https://cplusplus.github.io/LWG/issue2157)

The fix attempts to maintain ABI compatibility by replacing the array with a instance of `aligned_storage`.

Reviewers: mclow.lists, EricWF

Reviewed By: EricWF

Subscribers: lichray, cfe-commits

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

llvm-svn: 324182
2018-02-04 01:03:08 +00:00
Eric Fiselier f892166a1d Work around GCC constexpr initialization bug
llvm-svn: 324165
2018-02-03 01:48:21 +00:00
Eric Fiselier 9b5ff7a6bc Work around Clang bug introduced in r324062
When Clang encounters an already invalid class declaration, it can
emit incorrect diagnostics about the exception specification on
some of its members. This patch temporarily works around that
incorrect diagnostic.

The clang bug was introduced in r324062.

llvm-svn: 324164
2018-02-03 01:45:35 +00:00
Eric Fiselier bfbafa541a Fix has_unique_object_representation after Clang commit r324134.
Clang previously reported an empty union as having a unique object
representation. This was incorrect and was fixed in a recent Clang commit.

This patch fixes the libc++ tests.

llvm-svn: 324153
2018-02-02 22:39:59 +00:00
Richard Smith c7ef5656ff Disable test in C++<11 mode due to use of alignas.
llvm-svn: 324033
2018-02-01 23:31:22 +00:00
Richard Smith 4e3195c9b3 Make std::get_temporary_buffer respect overaligned types when possible
Patch by Chris Kennelly!

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

llvm-svn: 324020
2018-02-01 22:24:45 +00:00
Marshall Clow b87adec4bd Put the exception classes for experimental::optional and experimental::any back in the dylib for binary compatibility
llvm-svn: 323989
2018-02-01 18:45:57 +00:00
Marshall Clow 14082fcc42 Remove std::experimental::sample; use std::sample instead. See https://libcxx.llvm.org/TS_deprecation.html
llvm-svn: 323979
2018-02-01 16:36:08 +00:00
Marshall Clow 91af9048b2 Remove <experimental/numeric>; use <numeric> instead. See https://libcxx.llvm.org/TS_deprecation.html
llvm-svn: 323975
2018-02-01 15:49:27 +00:00
Marshall Clow 5d8babe30d Remove <experimental/any>; use <any> instead. See https://libcxx.llvm.org/TS_deprecation.html
llvm-svn: 323972
2018-02-01 15:21:14 +00:00
Marshall Clow 040533215a Remove <experimental/optional>; use <optional> instead. See https://libcxx.llvm.org/TS_deprecation.html
llvm-svn: 323971
2018-02-01 14:54:25 +00:00
Marshall Clow 1a6493b4e0 Add static_asserts to basic_ios and basic_stream_buf to ensure that that the traits match the character type. This is a requirement on the user - now we get consistent failures at compile time instead of incomprehensible error messages or runtime failures. This is also LWG#2994 - not yet adopted.
llvm-svn: 323945
2018-02-01 03:55:27 +00:00
Marshall Clow 0551d83ed5 Implement LWG2870: Default value of parameter theta of polar should be dependent
llvm-svn: 323918
2018-01-31 21:42:39 +00:00
Marshall Clow 9eb338c42e Add LWG3051
llvm-svn: 323822
2018-01-30 21:49:17 +00:00
Marshall Clow d0eb3092ac First cut at issue statuses for JAX
llvm-svn: 323720
2018-01-30 00:48:39 +00:00
Marshall Clow aafb3151a8 Add tests to make sure that <string_view> provides std::size/data/empty in C++17 mode. This is LWG#3009, coming up for a vote in JAX - but we already do it, just don't have tests
llvm-svn: 323719
2018-01-30 00:47:43 +00:00
Marshall Clow 6f73cf45df Minor updated to the main libcxx page; add a link to the deprecation page
llvm-svn: 323694
2018-01-29 21:28:46 +00:00
Don Hinton 88434fe05f LLVM_FOUND isn't always set, so just test if llvm_setup_rpath() is
available instead.

llvm-svn: 323599
2018-01-27 18:55:30 +00:00
Peter Collingbourne 939b16233b Fix the BinaryPredicate form of std::is_permutation to not rely on operator==
According to [1], forms 2 and 4 of std::is_permutation should use the passed in
binary predicate to compare elements. operator== should only be used for forms
1 and 3 which do not take a binary predicate.

This CL fixes forms 2 and 4 which relied on operator== for some comparisons.

[1] http://en.cppreference.com/w/cpp/algorithm/is_permutation

Patch by Thomas Anderson!

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

llvm-svn: 323563
2018-01-26 21:23:27 +00:00
Don Hinton d21aeffc86 Reland: [cmake] [libcxx] Call llvm_setup_rpath() when adding shared libraries.
Clang and llvm already use llvm_setup_rpath(), so this change will
help standarize rpath usage across all projects.

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

llvm-svn: 323492
2018-01-26 01:34:51 +00:00
Peter Collingbourne 1634c15e3c libcxx: Use vcruntime declarations for typeinfo on Windows.
We need to use the vcruntime declarations on Windows to avoid an
ODR violation involving rtti.obj, which provides the definition of
the runtime function implementing dynamic_cast and depends on the
vcruntime implementations of bad_cast and bad_typeid.

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

llvm-svn: 323491
2018-01-26 01:22:17 +00:00
Peter Collingbourne 0aa71a4f86 libcxx: Move #include_next <math.h> out of header guard in wrapper header.
Code on Windows expects to be able to do:

 #define _USE_MATH_DEFINES
 #include <math.h>

and receive the definitions of mathematical constants, even if <math.h>
has previously been included. To support this scenario, re-include
<math.h> every time the wrapper header is included.

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

llvm-svn: 323490
2018-01-26 01:19:23 +00:00
Marshall Clow 8abbc96c18 Mark 2903 as complete; we already do this
llvm-svn: 323479
2018-01-25 22:33:17 +00:00
Don Hinton 7e9453d583 Revert [libcxx] r323453 - [cmake] [libcxx] Call llvm_setup_rpath() when adding shared libraries.
Shoaib Meenai pointed out this will break standalone builds when built without llvm.

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

llvm-svn: 323459
2018-01-25 19:22:23 +00:00
Don Hinton 7b4be6f9d8 [cmake] [libcxx] Call llvm_setup_rpath() when adding shared libraries.
Clang and llvm already use llvm_setup_rpath(), so this change will
help standarize rpath usage across all projects.

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

llvm-svn: 323453
2018-01-25 18:13:26 +00:00
Eric Fiselier d053b59730 Fix PR35564 - std::list splice/erase incorrectly throw in debug mode.
There was a bug in the implementation of splice where the container
sizes were updated before decrementing one of the iterators. Afterwards,
the result of decrementing the iterator was flagged as UB by the debug
implementation because the container was reported to be empty.

This patch fixes that bug by delaying the updating of the container
sizes until after the iterators have been correctly constructed.

llvm-svn: 323390
2018-01-25 00:02:48 +00:00
Eric Fiselier b1539e0a0d Fix missing return in __tuple_leaf::__can_bind_reference when __reference_binds_to_temporary added in r323380.
llvm-svn: 323389
2018-01-24 23:10:02 +00:00
Marshall Clow e34f5ffe4b Implement LWG2783: stack::emplace() and queue::emplace() should return decltype(auto)
llvm-svn: 323385
2018-01-24 22:42:25 +00:00
Eric Fiselier 292617e700 [libc++] Fix PR20855 -- libc++ incorrectly diagnoses illegal reference binding in std::tuple.
Summary:
See https://bugs.llvm.org/show_bug.cgi?id=20855

Libc++ goes out of it's way to diagnose `std::tuple` constructions which are UB due to lifetime bugs caused by reference creation. For example:

```
// The 'const std::string&' is created *inside* the tuple constructor, and its lifetime is over before the end of the constructor call.
std::tuple<int, const std::string&> t(std::make_tuple(42, "abc"));
```

However, we are over-aggressive and we incorrectly diagnose cases such as:

```
void foo(std::tuple<int const&, int const&> const&);
foo(std::make_tuple(42, 42));
```

This patch fixes the incorrectly diagnosed cases, as well as converting the diagnostic to use the newly added Clang trait `__reference_binds_to_temporary`. The new trait allows us to diagnose cases we previously couldn't such as:

```
std::tuple<int, const std::string&> t(42, "abc");
```

Reviewers: rsmith, mclow.lists

Reviewed By: rsmith

Subscribers: cfe-commits

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

llvm-svn: 323380
2018-01-24 22:14:01 +00:00
Mikhail Maltsev 48c63d879b [libcxx] Correctly handle invalid regex character class names
Summary:
Currently when a regular expression contains an invalid character
class name std::regex constructors throw an std::regex_error with
std::regex_constants::error_brack code.

This patch changes the code to std::regex_constants::error_ctype and
adds a test.

Reviewers: EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

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

llvm-svn: 323322
2018-01-24 12:45:18 +00:00
Marshall Clow ae21466138 include <cstdint> to get uint32_t
llvm-svn: 323306
2018-01-24 05:38:51 +00:00
Peter Collingbourne fcac3c9642 libcxx: Allow auto-linking to be disabled with a macro.
Some users may have a custom build system which gives a different
name to the libc++ archive (or does not create an archive at all,
instead passing the object files directly to the linker). Give those
users a way to disable auto-linking.

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

llvm-svn: 323300
2018-01-24 04:30:19 +00:00
Marshall Clow a277d024f7 Implement P0463R1: 'Endian just Endian'. Reviewed as https://reviews.llvm.org/D35472
llvm-svn: 323296
2018-01-24 01:53:24 +00:00
Peter Collingbourne 2f97aab6ea libcxx: Rename vasprintf function to __libcpp_vasprintf.
The language standard does not define a function with this name,
so it is part of the user's namespace. This change fixes a duplicate
symbol error that occurs when a user attempts to define a function
with this name.

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

llvm-svn: 323237
2018-01-23 18:53:33 +00:00
Don Hinton 66ddb50e44 [cmake] Always respect existing CMAKE_REQUIRED_FLAGS when adding additional ones.
* Previously part of https://reviews.llvm.org/D41622.

llvm-svn: 323171
2018-01-23 03:30:23 +00:00
Peter Collingbourne 4801624ee3 libcxx: Provide overloads for basic_filebuf::open() et al that take wchar_t* filenames on Windows.
This is an MSVC standard library extension. It seems like a reasonable
enough extension to me because wchar_t* is the native format for
filenames on that platform.

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

llvm-svn: 323170
2018-01-23 02:07:27 +00:00
Peter Collingbourne ac15ae6d6b libcxx: Move Windows threading support into a .cpp file.
This allows us to avoid polluting the namespace of users of <thread>
with the definitions in windows.h.

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

llvm-svn: 323169
2018-01-23 01:59:43 +00:00
Marshall Clow d161ac9ea6 Update cxx2a status
llvm-svn: 323160
2018-01-22 23:17:20 +00:00
Marshall Clow 8da1a487ae Last batch of P0202 constexpr additions: includes/set_intersection/exchange
llvm-svn: 323159
2018-01-22 23:10:40 +00:00
Marshall Clow e8ea8296fc Another batch of P0202 constepr algirithms. remove/remove_if/remove_copy/remove_copy_if/reverse_copy, and tests (commented out) for rotate_copy, because that depends on std::copy
llvm-svn: 323152
2018-01-22 21:43:04 +00:00
Marshall Clow 1b9a4ffd6b Still more P0202 constexpr-ifying. This batch is: for_each/for_each_n/lexicographical_compare
llvm-svn: 323147
2018-01-22 20:44:33 +00:00
Don Hinton 98bb420559 [cmake] [libcxx] Fix find_path() problems when cross compiling.
When CMAKE_SYSROOT or CMAKE_FIND_ROOT_PATH is set, cmake
recommends setting CMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY
globally which means find_path() always prepends CMAKE_SYSROOT or
CMAKE_FIND_ROOT_PATH to all paths used in the search.

However, this find_path() invocation is looking for a path in the
libcxxabi project on the host system, not the target system,
which can be done by passing NO_CMAKE_FIND_ROOT_PATH.

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

llvm-svn: 323143
2018-01-22 19:26:38 +00:00
Marshall Clow cbe768ec69 Add (commented out) constexpr tests for copy/copy_backwards/copy_if/copy_n. These will be enabled when that part of P0202 is implemented. NFC at this time.
llvm-svn: 323137
2018-01-22 18:38:18 +00:00
Marshall Clow ac471d6db2 Really comment out the constexpr tests.
llvm-svn: 323072
2018-01-22 01:51:49 +00:00
Marshall Clow 785ae3e8c0 Change a static_assert to check for is_trivial instead of is_pod, as is mandated by P0767.
llvm-svn: 323071
2018-01-22 00:17:48 +00:00
Marshall Clow 85642c2bea implement (but leave commented out) the constexpr tests from P0202 for std::merge. merge requires std::copy, which isn't constexpr yet.
llvm-svn: 323070
2018-01-22 00:11:44 +00:00
Marshall Clow 4bfb9313c1 More P0202 constexpr work. This commit adds fill/fill_n/generate/generate_n/unique/unique_copy. I removed a specialization of fill_n that recognized when we were dealing with raw pointers and 1 byte trivially-assignable types and did a memset, because the compiler will do that optimization for us.
llvm-svn: 323050
2018-01-20 20:14:32 +00:00
Marshall Clow 12c7423ff9 More P0202 constexpr-ifying in <algorithm>. This commit handles replace/replace_if/replace_copy/replace_copy_if.
llvm-svn: 322975
2018-01-19 18:07:29 +00:00
Marshall Clow 99894b61ba More P0202 constexpr-ifying in <algorithm>. This commit handles 'transform'.
llvm-svn: 322970
2018-01-19 17:45:39 +00:00
Marshall Clow c6b908d0bb Wrote my own version of is_permutation; that was dominating the timings
llvm-svn: 322920
2018-01-19 03:17:45 +00:00
Marshall Clow 1885052589 Add memory tracking
llvm-svn: 322872
2018-01-18 18:37:11 +00:00
Marshall Clow a9bf43b1fe Use high_resolution_clock instead of steady_clock. Also now builds with gcc 7.2 (for comparison purposes)
llvm-svn: 322864
2018-01-18 17:01:34 +00:00
Marshall Clow 4f0de28c77 A simple program for testing OSS-Fuzz test cases locally.
llvm-svn: 322863
2018-01-18 16:52:19 +00:00
Eric Fiselier 1903976d37 Update Google Benchmark library
llvm-svn: 322812
2018-01-18 04:23:01 +00:00
Eric Fiselier decf22e50f Fix most GCC test failures.
This patch fixes almost all currently failing tests when
using GCC ToT.

The specific changes are:

(A) Workaround gcc.gnu.org/PR83921 which rejects variables w/o initializers
in constexpr contexts -- even when the variable is an empty class. This
bug has been worked around at all callsites by adding an initializer.
Additionally a new test, constexpr_init.pass.cpp, has been added to
test that Clang doesn't suffer from these bugs.

(B) Fix streambuf.assign/swap.pass.cpp. This test was never actually
calling the swap method as intended. In fact, the swap function it
intended to call was ill-formed when instantiated. GCC diagnosed
this ill-formedness w/o needing an instantiation.

(C) size_delete11.pass.cpp was fixed by adding c++2a to the list of
unsupported dialects.

llvm-svn: 322810
2018-01-18 03:41:06 +00:00
Peter Collingbourne 5e27cce467 libcxx: Define set_unexpected, _get_unexpected and __uncaught_exceptions without dllimport.
It turns out that the MSVC headers define these functions without
dllimport even when compiling with /MD. This change fixes the resulting
compile-time error.

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

llvm-svn: 322794
2018-01-18 00:33:35 +00:00
Eric Fiselier 6b3e48b46a Fix nodiscard failure tests on compilers w/o -verify.
Previously .fail.cpp tests for nodiscard were run with -Wunused-result
being a warning, not an error, when the compiler didn't support -verify.

When -verify isn't enabled this change judiciously adds -Werror=unused-result
when to only the failure tests containing the // expected-error string for nodiscard.

As a drive-by change, this patch also adds a missing // UNSUPPORTED: c++2a to
a test which was only supposed to run in C++ <= 11.

llvm-svn: 322776
2018-01-17 22:48:09 +00:00
Peter Collingbourne b89956c812 libcxx: Disable CFI in function std::get_temporary_buffer.
The specification of this function mandates a cast to uninitialized
T*, which is forbidden under CFI.

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

llvm-svn: 322744
2018-01-17 19:32:35 +00:00
Peter Collingbourne 4bdb80faf2 libcxx: Stop using private MSVC macros in the exception implementation.
Inline the provided "fallback" definitions (which seem to always be
taken) that expand to __cdecl into users. The fallback definitions
for the *CRTIMP* macros were wrong in the case where the CRT is being
linked statically, so define our own macro as a replacement.

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

llvm-svn: 322617
2018-01-17 04:37:04 +00:00
Marshall Clow 12f0a77902 More constexpr algorithms from P0202. search/search_n
llvm-svn: 322566
2018-01-16 15:48:27 +00:00
Marshall Clow a58bdf9f69 Change an internal table of constants for the poisson distribution from
type 'result_type' to 'double'. The only thing that we ever do with
these numbers is to promote them to 'double' and use them in a division.
For small result_types, the values were getting truncated, skewing the
results. Thanks to James Nagurne for the suggestion.

llvm-svn: 322556
2018-01-16 14:54:36 +00:00
Marshall Clow d57c03ddca More constexpr algorithms from P0202: lower_bound, upper_bound, equal_range, binary_search
llvm-svn: 322529
2018-01-16 02:34:41 +00:00
Marshall Clow a38c495f22 Actually CALL the constexpr tests.
llvm-svn: 322528
2018-01-16 02:11:13 +00:00
Marshall Clow 6538e28d5d More constexpr (re P0202) - equal and mismatch
llvm-svn: 322527
2018-01-16 02:04:10 +00:00
Marshall Clow da97ec6c10 Fix constexpr failure on C++11-based buildbots.
llvm-svn: 322507
2018-01-15 19:59:09 +00:00
Marshall Clow 056f15e3c5 More constexpr from P0202. count and count_if. Also fix a comment that Morwenn noted.
llvm-svn: 322506
2018-01-15 19:40:34 +00:00
Marshall Clow 404ee020f0 Some of the tests from earlier today had 'int' as the return type when it should have been 'bool'. Fix that. It doesn't change the behavior of any of the tests, but it's more accurate.
llvm-svn: 322505
2018-01-15 19:32:32 +00:00
Marshall Clow 8694428e36 More P0202 constexpr-ifying. All the find_XXX algorithms in this commit.
llvm-svn: 322504
2018-01-15 19:26:05 +00:00
Marshall Clow 674f9128b7 partition_point gets the P0202 treatment
llvm-svn: 322493
2018-01-15 17:53:34 +00:00
Marshall Clow 706ffef713 More constexpr algorithms from P0202. any_of/all_of/none_of.
llvm-svn: 322492
2018-01-15 17:20:36 +00:00
Marshall Clow 49c7643c39 First part of P0202: Adding constexpr modifiers to functions in <algorithm> and <utility>. This commit is all the is_XXX algorithms.
llvm-svn: 322489
2018-01-15 16:16:32 +00:00
Ekaterina Vaartis b848122b5e Add error code handling to remove_all test
As mentioned by EricWF in revision D41830

llvm-svn: 322351
2018-01-12 05:02:06 +00:00
Volodymyr Sapsai a051024cac [libcxx] Make std::basic_istream::get 0-terminate input array in case of error.
It covers the cases when the sentry object returns false and when an exception
was thrown. Corresponding standard paragraph is C++14 [istream.unformatted]p9:
  [...] In any case, if n is greater than zero it then stores a null
  character into the next successive location of the array.

rdar://problem/35566567

Reviewers: EricWF, mclow.lists

Reviewed By: mclow.lists

Subscribers: cfe-commits

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

llvm-svn: 322326
2018-01-11 23:23:49 +00:00
Marshall Clow 0e22bf8cb9 Implement an _is_allocator type trait for use in deduction guides.
llvm-svn: 322306
2018-01-11 19:36:22 +00:00
Marshall Clow 31163f629b Fix some too-big local arrays. Thanks to dcdillon for the patch. Reviewed as D28217
llvm-svn: 322295
2018-01-11 17:16:52 +00:00
Ekaterina Vaartis e44cbaf704 Make std::experimental::filesystem::remove and remove_all return false or 0 if the file doesn't exist
Differential Revision: https://reviews.llvm.org/D41830

llvm-svn: 322293
2018-01-11 17:04:29 +00:00
Peter Collingbourne 4566d827a1 libcxx: Stop providing a definition of __GLIBC_PREREQ.
An application may determine whether the C standard library is glibc
by testing whether __GLIBC_PREREQ is defined. This breaks if libc++
provides its own definition. Instead, define our own macro in our
namespace with the desired semantics.

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

llvm-svn: 322201
2018-01-10 18:16:58 +00:00
Marshall Clow 6b40646bec Fix misspelled macro name - thanks to andrew@ispras.ru for the catch
llvm-svn: 322196
2018-01-10 16:25:04 +00:00
Stephan T. Lavavej 04576cc060 [libcxx] [test] Improve MSVC portability.
test/support/msvc_stdlib_force_include.hpp
When testing MSVC's STL with C1XX, simulate a couple more compiler feature-test macros.

When testing MSVC's STL, simulate a few library feature-test macros.

test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
The vector_size attribute is a non-Standard extension that's supported by Clang and GCC,
but not C1XX. Therefore, guard this with `__has_attribute(vector_size)`.

Additionally, while these tests pass when MSVC's STL is compiled with Clang,
I don't consider this to be a supported scenario for our library,
so also guard this with defined(_LIBCPP_VERSION).

test/std/utilities/function.objects/func.not_fn/not_fn.pass.cpp
N4713 23.14.10 [func.not_fn]/1 depicts only `call_wrapper(call_wrapper&&) = default;`
and `call_wrapper(const call_wrapper&) = default;`. According to
15.8.2 [class.copy.assign]/2 and /4, this makes call_wrapper non-assignable.
Therefore, guard the assignability tests as libc++ specific.

Add a (void) cast to tolerate not_fn() being marked as nodiscard.

Fixes D41213.

llvm-svn: 322144
2018-01-10 00:39:46 +00:00
Petr Hosek 0f03c79b6d [libcxx] Support the use of compiler-rt in lit tests
Don't link tests against libgcc when compiler-rt is being used.

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

llvm-svn: 322044
2018-01-08 23:36:53 +00:00
Dan Albert 553b09b515 Revert "Make rehash(0) work with ubsan's unsigned-integer-overflow."
Seems to have broken some tests since I first wrote this a while
back. Will reland after checking what went wrong with the tests.

This reverts commit 7023194c8d11a081fd01ed25308b3d60193c6a06.

llvm-svn: 322039
2018-01-08 22:57:12 +00:00
Marshall Clow e426a832dd Apparently 'C++14' is different than 'c++14'
llvm-svn: 322034
2018-01-08 22:16:30 +00:00
Dan Albert 0802327a39 Make rehash(0) work with ubsan's unsigned-integer-overflow.
Reviewers: mclow.lists, EricWF

Reviewed By: mclow.lists

Subscribers: cfe-commits

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

llvm-svn: 322031
2018-01-08 21:49:12 +00:00
Billy Robert O'Neal III b6e3c55465 Change add_ten to add_one to avoid triggering ubsan integer overflow.
llvm-svn: 322021
2018-01-08 19:45:16 +00:00
Marshall Clow d835e59211 Add the C++17 extensions to std::search. Include the default searcher, but not the Boyer-Moore or Boyer-Moore-Horspool searcher (yet). BUT put the BM and BMH tests in place, marked to XFAIL. The other searchers will follow soon
llvm-svn: 322019
2018-01-08 19:18:00 +00:00
Marshall Clow 86de37aee6 Document upcoming TS feature removal
llvm-svn: 322011
2018-01-08 17:43:46 +00:00
Marshall Clow 464de6ca09 Mark the transparent version set::count() as const. Thanks to Ivan Matek for the bug report.
llvm-svn: 321966
2018-01-07 17:39:57 +00:00
Dimitry Andric 672f7adce5 Add pre-C++11 is_constructible wrappers for 3 arguments
Summary:
After rL319736 for D28253 (which fixes PR28929), gcc cannot compile `<memory>` anymore in pre-C+11 modes, complaining:

```
In file included from /usr/include/c++/v1/memory:648:0,
                 from test.cpp:1:
/usr/include/c++/v1/memory: In static member function 'static std::__1::shared_ptr<_Tp> std::__1::shared_ptr<_Tp>::make_shared(_A0&, _A1&, _A2&)':
/usr/include/c++/v1/memory:4365:5: error: wrong number of template arguments (4, should be at least 1)
     static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in make_shared" );
     ^
In file included from /usr/include/c++/v1/memory:649:0,
                 from test.cpp:1:
/usr/include/c++/v1/type_traits:3198:29: note: provided for 'template<class _Tp, class _A0, class _A1> struct std::__1::is_constructible'
 struct _LIBCPP_TEMPLATE_VIS is_constructible
                             ^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/v1/memory:648:0,
                 from test.cpp:1:
/usr/include/c++/v1/memory:4365:5: error: template argument 1 is invalid
     static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in make_shared" );
     ^
/usr/include/c++/v1/memory: In static member function 'static std::__1::shared_ptr<_Tp> std::__1::shared_ptr<_Tp>::allocate_shared(const _Alloc&, _A0&, _A1&, _A2&)':
/usr/include/c++/v1/memory:4444:5: error: wrong number of template arguments (4, should be at least 1)
     static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in allocate_shared" );
     ^
In file included from /usr/include/c++/v1/memory:649:0,
                 from test.cpp:1:
/usr/include/c++/v1/type_traits:3198:29: note: provided for 'template<class _Tp, class _A0, class _A1> struct std::__1::is_constructible'
 struct _LIBCPP_TEMPLATE_VIS is_constructible
                             ^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/v1/memory:648:0,
                 from test.cpp:1:
/usr/include/c++/v1/memory:4444:5: error: template argument 1 is invalid
     static_assert((is_constructible<_Tp, _A0, _A1, _A2>::value), "Can't construct object in allocate_shared" );
     ^
```

This is also reported in https://bugs.freebsd.org/224946 (FreeBSD is apparently one of the very few projects that regularly builds programs against libc++ with gcc).

The reason is that the static assertions are invoking `is_constructible` with three arguments, while gcc does not have the built-in `is_constructible` feature, and the pre-C++11 `is_constructible` wrappers in `<type_traits>` only provide up to two arguments.

I have added additional wrappers for three arguments, modified the `is_constructible` entry point to take three arguments instead, and added a simple test to is_constructible.pass.cpp.

Reviewers: EricWF, mclow.lists

Reviewed By: EricWF

Subscribers: krytarowski, cfe-commits, emaste

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

llvm-svn: 321963
2018-01-07 16:45:11 +00:00
Saleem Abdulrasool ae20590c17 Correct mistake in pragma usage for Windows
The autolink pragma was missing the pragma name itself.  This would
result in the pragma being silently dropped.

llvm-svn: 321937
2018-01-06 18:47:03 +00:00
Billy Robert O'Neal III 231d15e086 Add casts to prevent narrowing warnings.
llvm-svn: 321923
2018-01-06 02:50:03 +00:00
Billy Robert O'Neal III 1e1195dce5 [libcxx] [test] Remove nonstandard things and resolve warnings in Xxx_scan tests
Reviewed as https://reviews.llvm.org/D41748

* These tests use function objects from functional, back_inserter from iterator, and equal from algorithm, so add those headers.
* The use of iota targeting vector<unsigned char> with an int parameter triggers warnings on MSVC++ assigning an into a unsigned char&; so change the parameter to unsigned char with a static_cast.
* Avoid naming unary_function in identity here as that is removed in '17. (This also fixes naming _VSTD, _NOEXCEPT_, and other libcxx-isms)
* Change the predicate in the transform tests to add_ten so that problems with multiple application are caught.

llvm-svn: 321922
2018-01-06 02:18:20 +00:00
Martin Storsjo bf02a09103 [cmake] Add a config option LIBCXX_HAS_WIN32_THREAD_API for enforcing win32 threads
This allows keeping libcxx using win32 threads even if a
version of pthread.h is installed.

This matches the existing cmake option LIBCXX_HAS_PTHREAD_API.

Also add missing documentation about the internal define
_LIBCPP_HAS_THREAD_API_WIN32.

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

llvm-svn: 321896
2018-01-05 20:48:29 +00:00
Billy Robert O'Neal III 3770e403ee Move + and * operators of MoveOnly into MoveOnly.h.
llvm-svn: 321852
2018-01-05 01:32:00 +00:00
Billy Robert O'Neal III 4958692ad9 Fix incorrect handling of move-only types in transform_reduce iter iter iter init, and add test.
llvm-svn: 321851
2018-01-05 01:31:57 +00:00
Billy Robert O'Neal III ca444e13dc Automated trailing whitespace removal by VS Code.
llvm-svn: 321850
2018-01-05 01:31:55 +00:00